Max Views

Availability conditions ::: availability_maxviews
Maintained by Picture of Daniel Neis AraujoDaniel Neis Araujo
An availability condition for Moodle that limits the number of views of activities and resources by users
Latest release:
137 sites
16 fans
Moodle 3.3, 3.4, 3.5, 3.6, 3.7, 3.8

With this plugin you can limit your users to view any type of activity or resource a certain amount of times. The limit is applied to each user individually and is based on events for the associated context module.


Screenshot #0


Picture of Daniel Neis Araujo
Daniel Neis Araujo (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Daniel Neis Araujo
    Wed, Aug 5, 2015, 10:56 PM

    you must have Legacy Logs disabled to use this plugins, since for some reason,
    the sql_reader does not count correctly from standard log if you have legacy log enabled too.

    also, you must try to use the plugin with a non-admin user or with an user that cannot view hidden activities,
    since in these cases moodle has an strange default of "false" for "is_available_for_all" function that makes the activities
    "dimmed" by default. i think it is not a good default because conditiosn like groups does not have all the parameter available
    for "is_available_for_all" that we have for "is_available" so, groups restrictions also show dimmed by default. the date restrictions
    does not show dimmed because it does not need any information about users and course_module info, it just rely on the current date.

    Kind regards,
  • Picture of Dan Marsden
    Thu, Aug 6, 2015, 4:13 PM
    Hi Daniel, those sorts of complexities should be well documented within the plugin and possibly in the description above but ideally it would be better to modify your code to work without the complexity. Many existing 3rd party plugins rely on legacy logs so many sites will have them enabled.

    I was previously testing with a student account that had not made any views to an activity and set the maxviews availability setting to "1" both with "Must" and "Must not" settings but it did not seem to allow the student access to the activity to make the first view. (I'll test with your version from github tonight)

    leave the core strings as-is for now - but make sure you have a different string in your plugin for the "Must" and "Must not" values as I think they will need to be different. Once we get your plugin approved we can then create a bug in the tracker(if there isn't one already) to modify the core lang to remove the word "unless" and make it more generic.
  • Picture of Dan Marsden
    Thu, Aug 6, 2015, 4:40 PM
    Hi Daniel, I found a few issues which I have reported to your github account. I don't think this is easy enough for people to use yet and there's still some room for improvement before it can be approved here in the plugins db. If you can't get it to work with Legacy logs enabled the plugin should check to see if it is enabled and display useful information to the admin/teacher and disable the plugin from the interface.

  • Picture of David Mudrák
    Thu, Jun 9, 2016, 4:07 AM

    After installation to Moodle 3.0, attempting to edit a module settings throws

    Fatal error: Cannot redeclare availability_maxviews\frontend::allow_add() in /availability/condition/maxviews/classes/frontend.php on line 75

    Note the same method is already present there in the class. Should not your Behat test catch that?

  • Picture of Daniel Neis Araujo
    Thu, Jun 9, 2016, 4:42 AM
    Hello, David

    don't know why the behat tests are not catching this error.
    I've fixed it and now it works:

    Kind regards,
  • Picture of David Mudrák
    Fri, Jul 15, 2016, 3:44 PM

    Thanks Daniel. I am approving the plugin now. You are cleared to land, welcome to the Plugins directory.

  • Carlos
    Wed, Jul 20, 2016, 6:30 PM
    This plugins generated yesterday in one of our test campus the following messages in our security system.
    The campus, after install thos plugins, did not permit edit acction in all campus.
    We can see the resources, but dont edit and dont insert new resource.

    The status back to normal situation after un-install the plugin

    [Tue Jul 19 14:18:04 2016] [error] [client XX.XX.XX.XX] ModSecurity: Access denied with code 500 (phase 2). Match of "rx ^OPTIONS$" against "REQUEST_METHOD" required. [file "/etc/apache2/modsecurity/modsecurity_crs_21_protocol_anomalies.conf"] [line "41"] [id "960015"] [msg "Request Missing an Accept Header"] [severity "CRITICAL"] [tag "PROTOCOL_VIOLATION/MISSING_HEADER"] [hostname ""] [uri "/"] [unique_id "V45gzAoCAwQAAGrRjZgAAABg"]

    PLease, verify bebfore install this pluging.
    We verify that the pluging its the problem with second test in another campus installation.


  • Picture of Karan Khanna
    Wed, Jun 7, 2017, 4:45 AM
    Thanks for this wonderful plugin which I liked a lot, using it on
  • Picture of Sam AG
    Sun, Dec 10, 2017, 6:12 PM
    hi ,
    I am using in our moodle site i am able to restrict but as i save the it in the course
    next time i am not able to access the restriction its completely disabled for the admin

    later i need to go to plugins and disable the MAXVIEW, then the whole restrict tab starts working.

    Some one please help me..
  • Picture of abdelmajid jalal
    Sat, Dec 30, 2017, 8:42 PM
    A wonderful plugin well worth the experience
    Do you work on Wordpress and Joomla?
  • Picture of Daniel Neis Araujo
    Tue, Jan 9, 2018, 9:19 PM
    Hello, Sam AG

    which Moodle version are you using?
    Can you enable de debugging mode in Moodle and share the info showed with us?
  • Picture of Andres Ramos
    Wed, Jan 10, 2018, 11:04 PM
    Sam AG and Daniel, it happens in version 3.3+ and 3.4. I was able to fix the issues and made some improvements. Let me know how can I send you the fixes for the plugin and you can test on your end.
  • Picture of Daniel Neis Araujo
    Wed, Jan 10, 2018, 11:46 PM
    Hello, Andres

    please send a pull request to the github repository:

    Thank you in advance!
  • Picture of Andres Ramos
    Wed, Feb 7, 2018, 12:11 AM
    Pull request done.
1 2
Please login to post comments