Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Activity Locking

From MoodleDocs

Overview

This page is an attempt to consolidate and explain the available activity locking (AL) code that is present for Moodle 1.5.x and 1.6.x. This page will hopefully help explain all the available versions and their respective features. Some of the reference here will overlap with the existing MoodleDoc page covering Conditional activities.

Please be patient as this page is new and under development. See page comments for reference material.

Types of activity locking code

For the purpose of this MoodleDoc article: AL is any code that allows the user to make decisions on the next available resource or item the student will see based on student events or quiz performance. There is some activity locking code that is very quick and dirty to simply lock future activities and then there is much more complex code based on the conditional activity though structure which attempts to progress the student through the course in a thought out progression based on activities and performance. Again we hope to clarify some of this here..

AL Branch 2.1 for Moodle 1.6 (Stuart Mayor)

This has been virtually a complete rewrite and as such there are areas of functionality the were available in older versions of AL that are not in this.

  • Conditional locking: Lock based on a user's performance in previous activities. You can also choose to unlock and activity if a user scores less than a certain grade.
  • Show activity completion: The checkbox that appears before each activity to show it have been done.
  • A variation on this also hides future activities ALV2_1_debug.ZIP (John).

Installation for 2.1 for Moodle 1.6(Stuart Mayor)

activitylocking20051201.zip the initial version

  • Firstly, you need the stable build of Moodle 1.6. This version of AL might work on earlier releases but I didn't write it with them in mind and I certainly can't support them.

Next, you need to modify one table in the database and add a new one (I use phpmyadmin for this).

  • The table you need to modify is mdl_course_modules and you need to add the following fields:

completedbox TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' completedscore VARCHAR(255) NOT NULL completedstyle VARCHAR(255) NOT NULL lockedbox TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' lockedstyle VARCHAR(255) NOT NULL DEFAULT 'locked' lockedvisible TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' delay INT(10) UNSIGNED NOT NULL DEFAULT '0'

  • The table you need to create is as follows:

CREATE TABLE `mdl_course_locks` ( `id` int(10) unsigned NOT NULL auto_increment, `courseid` int(10) unsigned NOT NULL default '0', `locktype` varchar(10) NOT NULL default , `targetid` int(10) unsigned NOT NULL default '0', `locks` longtext NOT NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM COMMENT='Contains locks for sections and modules';

  • Lastly, you need to copy the following files from the zip file:

lib/moodlelib.php to moodle/lib/moodlelib.php lib/locklib.php to moodle/lib/locklib.php course/lib.php to moodle/course/lib.php course/lock.php to moodle/course/lock.php course/mod.php to moodle/course/mod.php course/settings.html to moodle/course/settings.html pix/t/open.gif to moodle/pix/t/open.gif pix/t/closed.gif to moodle/pix/t/closed.gif lang/en/lock.php to moodle/lang/en/lock.php

AL Branch 3.s for Moodle 1.6 (Stuart Mayor)

AL Branch 3.d for Moodle 1.5 or 1.6 David Delgado)

Details and discussed in the thread "NEW research on CONDITIONAL ACTIVITIES in Moodle"

Table of Versions, to be completed...

Activity Locking
AL Version Moodle version MySql Installation Docs Feature Feature Feature Feature Feature Bug Bug Bug
2.1 1.6 ? [1]
3.0 1.5.2 ? [2]

See Also

Please visit the Moodle Forum for more information concerning Activity Locking and Conditional Activities-

There is a very specialized-limited type of activity locking under a lesson (activity) setting called dependency in 1.6. See: *https://docs.moodle.org/en/Adding/editing_a_lesson#Dependent_on .