Conditional activities: Activity Locking V 2.0 for 1.8.1 only

Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Bernard Boucher -
Number of replies: 43
Hi all,
you will find a new version of activity locking for Moodle 1.8.1 only there.

Features are described in that table.

Activity locking is not intended to replace nor to be compatible with the Moodle Quiz most wanted feature or official moodle conditionnal activities expected in Moodle 2.0.

Activity locking use the function require_login() in moodlelib with depreciated "role" functions like isteacher() to work. A full use of new moodle role should be better but it is not implemented yet.


Please don't test it on a production server.

Let me know if it works fine ( I don't use 1.8.1 yet )

I hope it may help,

Bernard
Average of ratings: -
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by John Brady -

Thank you very much for updating this.

Moodle 1.8.1+ (2007021510) Windows XP SP2

It is working well when I lock a Certificate based on Quiz Grades.

However, when there is no quiz (grade lock), it doesn’t seem to be working.
I set up 2 PDF resources and Locked PDF2 based on the user accessing PDF1.
1) I can access PDF2 before accessing PDF1
2) After accessing PDF1, it shows no completion
3) When I add a quiz to the course, the completion marks appear for PDF1 and PDF2. At this point I have not set any locks on the quiz, I just set up the quiz.

In reply to John Brady

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by John Brady -

Again thank you for working on this.

Another test

Setup
PDF1:
  Show activity completion: Yes
PDF2:
  User must access this activity = PDF1
  Show activity completion: Yes
Quiz:
  Show activity completion: Yes
Certificate:
  User must access this activity PDF1 
  User must access this activity PDF2
  Quiz Required Grade: 10
  Show activity completion: Yes

Step 1 Open PDF2: It opened, I expected it to be locked, It did not show activity complete
Step 2: Open PDF1: It opened; it did not show activity complete
Step 3: Pass Quiz It did not show activity complete
So there are no Activity Complete Check Marks at this point.
Step 4: Select Certificate (I didn’t view the certificate)
Step 5 Select Back (to course)

All completion check marks are now present.
Let me know if you would like some other combination tested.

Thanks for working on this

In reply to John Brady

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Chris Collman -
Picture of Documentation writers
Hi John,
Didn't we have issues in the past about the order of loading non-standard modules? Don't know, but I wonder if Certificate and AL have some sort of conflict, especially if Certificate has been used by students before AL was installed. Wild guess that wide eyes

See my next post to Benard.

Best Chris

In reply to John Brady

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Bernard Boucher -
Hi John,

I downloaded a new Moodle and reistall it and it works fine here with a combination of txt pdf lessons and quiz. As you notice I don't use the certificate.



.


Few things to remember:

1 - Login as feature don't works with Activity Locking, you must be the real student

2 - Conditions like "User must access this activity " works only one time, after that the access is done and the activity is granted.

3 - Activity Locking is not upgradable nor de-installable.

4 - You must respect the combinasions of versions of that table.

I hope it may help,

Bernard




In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Chris Collman -
Picture of Documentation writers
Bernard,
Add my thanks to those of John and others. First blush seems to work for my limited test. I will try duplicating John's error.

In my test this morning, I downloaded a fresh windows package and set it up as a localhost in a folder moodle181_AL and installed it. I brought in a special 1.8 course with 4 lessons in a topic as a new course. Finally I downloaded and unpacked AL for 1.8.1 to /moodle181_AL/moodle, went to notification and it installed flawlessly. I added it as a block to my course. I added a 2 question quiz to a topic. Notice I did not install Certificate (something I will do), nor did I use the Lesson contingency feature, because this test is about AL.

All my lessons have questions but I focused upon Lesson 2 that had 4 questions. I set Lesson 3 lock to need 2 correct questions from Lesson 2 and did not hide it. I set my Quiz to need 4 correct questions from Lesson 2 and hide it.

My student1 logged in and went straight to lesson 2 and missed every question. Quiz was hidden and student1 could see but not enter Lesson 3. My student1 went back and retook Lesson 2 and answered 2 questions correctly. Was able to enter Lesson 3 but not see the quiz.

I logged back in as admin and changed the lock on the quiz to 2 correct. When my student1 logged in the quiz was revealed.

These are the features I care about smile, so it seems to work for me ! I don't hide or make activities contingent upon viewing resources or participating in forums. I didn't notice the time delay feature before and that is of interest to us.

Next up in the order I will test:
  1. the time delay by adding a second quiz with student2
  2. add a resource and make Lesson 2 contingent upon viewing it with student3
  3. add Certificate and see what happens with student4.

Hope this helps, Thanks again for your work.





In reply to Bernard Boucher

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Chris Collman -
Picture of Documentation writers
Hi Benard,
I went a little out of sequence. Right under NewsForum I added textpage1 and textpage2. I then made textpage2 contingent upon viewing textpage1. I set the lock on Lesson1 to be hidden until textpage2 was viewed. Everything worked as I expected when I logged in as a new student.

I also played with the activity complete and prereq checkboxes. Which also seemed to work as I expected.

Then I went back to textpage2 and set the time delay to 5 minutes. Ooops. SQL error. I could only see news forum and textpage1, nothing elese in the course (possibly the activity complete box for textpage2).

I changed the site setting to see reasonable php error messages. Attached is an UTF-8 text file with them. I then went back and reset the site to developer's error message and this is what showed.

XML Parsing Error: not well-formed
Location: http://localhost/course/view.php?id=3
Line Number 207, Column 14: &string(67) "SELECT * FROM mdl_user_students WHERE userid = '2' AND course = '3'"
-------------^

All greek to me. It is a beautiful Sunday morning down here, so I may go outside and do some more yard work. Best.

In reply to Chris Collman

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Bernard Boucher -
Hi Chris,

Moodle seem to keep you younger day after day wink Maybe it is another bug in activity locking time delay big grin The timer is probably inverted!


What error did you get exactly? Some thing like:

This SQL relies on obsolete tables! Your code must be fixed by a developer

If so I will have to add another file to activity locking. ( lib/dmllib.php )

I hope it may help,

Bernard


In reply to Bernard Boucher

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Chris Collman -
Picture of Documentation writers
Hi Bernard,
Ahya, ever since I created a 1.8.1 Moodle with AL installed, I have been in this weird time warp. Figured it was a Northern New Hampshire thing, caused by the normal adjustment of the framstan with two sources of energy out of Quebec - Hydro & Boucher big grin However, being carded in the pubs is great for my ego !

Indeed that was the error when I had the low level debug turned on. I will keep on the path of a clean install. Will the lib/dmllib.php file solve the error on my current localhost, or should I do another install?

Read Lisa's posts. Wondering if my clean install has or will have a similar issue.

Just curious and my usual wordy self.


Best



In reply to Bernard Boucher

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Scott Hallenbeck -
I just installed the June22_07 version, after setting a second lock, I got the message:
This SQL relies on obsolete tables! Your code must be fixed by a developer
I an running a recent snapshot of moodle 1.8.1. I turned on debugging and moodle is now broken, cant even get back to turn debugging off as moodle stops with:
XML Parsing Error: junk after document element
Notice: Trying to get property of non-object in SERVER_ROOT/html/lib/locklib.php on line 89
when accessing server->debugging. This was a stock moodle install with just certificate 4.2 FAT.zip installed. Going to grab another snapshot and try again.
In reply to Scott Hallenbeck

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Bernard Boucher -
Hi Scott,
can you precise if you got that error when using time lock feature a Chris does?

I will post a new version probably next week with that error corrected.

In meantime if you check that post you will have a trick to correct it.

I hope it may help,

Bernard


In reply to Bernard Boucher

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Scott Hallenbeck -
It definitely is related to the time lock feature. I reinstalled the daily build then loaded the AL patch. It happened again as soon as I tried to time lock an activity. I commented out the error line in dmllib.php to get around it breaking the interface. (I did notice that $table was the empty string in that check.)

Been going thru the code and noticed an error in the block class, you might want to change line 30 to:

$courselocks += count_records_sql('SELECT COUNT(*) FROM '. $CFG->prefix . 'course_modules WHERE course = \''. $course->id .'\' AND delay NOT IN (\'0:0:0\',\'\')'); just looking for delay <> does not work for the empty case :p

oh and unlocking a time lock will not reset the delay to 0:0:0 nor empty
In reply to Scott Hallenbeck

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Bernard Boucher -
Hi Scott,
thanks for confirming the bug and for working in a patch.
I will check it probably next week, sorry for the delay still in vacation.


Thanks,

Bernard

In reply to Bernard Boucher

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by teresa pomposo -
Good afternoon!
I'm very interested in this module, I'm trying to download it but the link is off and I can't download the file. I had the same problem in a previous version and I couldn't resolve it.

Please, can anyone send the zip file to my email (pomposomt@unican.es)?

Thanks


In reply to teresa pomposo

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by teresa pomposo -
Thank you for the file, Bernand!

I install the module and it runs perfectly (except the time lock).

Thanks for all your work.
In reply to Scott Hallenbeck

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Carlos Peñas -
I'm triying to get rid of this issue and tested if the solution of Scott does the trick but the error still there again sad

I install a fresh 1.8.1 version of moodle, + AL patch, create a course and when active delay get the well know "This SQL relies on obsolete tables![...]" error.

this is my stack trace:

PHP Notice: Stack trace:
  • line 4788 of lib/weblib.php: call to debugging()
  • line 661 of lib/dmllib.php: call to error()
  • line 474 of lib/dmllib.php: call to get_recordset_sql()
  • line 414 of lib/dmllib.php: call to get_record_sql()
  • line 16 of lib/locklib.php: call to get_record()
  • line 1397 of course/lib.php: call to islocked()
  • line 221 of course/format/topics/format.php: call to print_section()
  • line 205 of course/view.php: call to require()
in /var/www/moodle/lib/weblib.php on line 5870, referer: http://localhost/moodle/

top weblib can be safely ignored. Looking at dmllib.php over line 661 there's an "if" block that fires the error if it finds "*prefix*user_students ".

looking locklib.php at line 16 theres the offending one, a call to get_record with table "user_students" ...

Here my research ends, because I don't now the moodle database enough to repair this.

may someone help me to fix this? Thanks



In reply to Carlos Peñas

Re: Activity Locking V 2.0 for 1.8.1 TimeLock caused error

by Carlos Peñas -
Hi again!

I'm here testing again... searching dmllib.php for the same if block in earlier versions I noticed It has been there from (at least) 1.7.1. So I thought, if there's an AL module for that versión It may behave different checking delay locks.

I downloaded version for 171 just to glance at, and found another way to test delay locks. I cut'n'pasted the whole if block in absence of better solution and just for testing on the locklib.php of 181 patch and it worked for me. (at least getting off that error of the missed table) it needs more testing
In reply to Carlos Peñas

Re: Activity Locking V 2.0 for 1.8.1

by jimmy kent -
Hi will activity locking V2.0 work for version 1.82?
In reply to jimmy kent

Re: Activity Locking V 2.0 for 1.8.1

by Alejandro Gil -
Only in 1.8.1, i tried it in 1.8 and 1.82 and it didn´t work.

It´s a problem because it turned imposible to get the moodle 1.8.1 version...

Anyone knows where can i find it?
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Lisa Stevens -
Thanks for your work on this, Bernard.

I tried it on our Moodle 1.8.1 this morning and received the following error on opening the home page of our Moodle installation:

Fatal error: Call to undefined function isunlocked() in [path removed]\course\lib.php on line 1334

I managed to correct it using a 'fix' suggested here.. http://moodle.org/mod/forum/discuss.php?d=60406 though that then caused a further error in course\lip.php. I'm afraid I had to undo the changes AL made for the time being as we only have the implementation on a production server but I'm hoping to replicate our Moodle install and try again to see if I can get it working. I'm afraid I'm no pro when it comes to php, though, but will see if I can get any further....

Lisa
In reply to Lisa Stevens

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Bernard Boucher -
Hi Lisa,

Few things to remember:

0 - Please don't test it on a production server.

1 - Login as feature don't works with Activity Locking, you must be the real student

2 - Conditions like "User must access this activity " works only one time, after that the access is done and the activity is granted.

3 - Activity Locking is not upgradable nor de-installable.

4 - You must respect the combinaisons of versions of that table.

The link you mention refer to a mismatch of versions of activity locking and Moodle. That is why it is very important to respect the matching versions of the table.

And again: Please don't test it on a production server.

Let me know how it works.

I hope it may help,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Lisa Stevens -
Hi Bernard
I have now tested it on a fresh install of Moodle 1.8.1 and it works well (same version of Moodle and AL as tested on our production server, but we do have other hacks on our production server which I suspect may be causing the issues).
Now I know that it definitely works I can try to get it working on our production server... Will try introducing our other hacks first to this fresh install of Moodle one by one and see whether I can get them all working harmoniously!
Thanks again,
Lisa
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Lisa Stevens -
Hi again Bernard
Just to let you know it is now working on our original Moodle installation...
I had to add
require_once($CFG->libdir .'/locklib.php');
to line 36 of index.php and that's got rid of the undefined function error I was receiving.
We are displaying a topic on the front page, so it was trying to use AL which wasn't being referenced at all in index.php...! I'm guessing this is something others may come across who are displaying topics on their Moodle home page..?
The AL is just what we've been looking for though - thank you!
Lisa
In reply to Lisa Stevens

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Bernard Boucher -
Hi Lisa,
sorry for the delay some vacation cool

I am happy that it works fine for you. I will try to reproduce your problem and maybe I will have to add the require_once($CFG->libdir .'/locklib.php'); at the appropriate place.

Salutations from Québec,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Roel Cantada -

Hi Bernard,

Great work.  I have tested AL v.2 for 1.8.1 on a version = 2007021505 release = '1.8 +' running on WinXP, and a Moodle 1.8 (2007021501) installed through Cpanel on a hosted server (RH linux).  In both I have topics section on, and experience the problem reported by Heather P in the discussion about AL for 1.5.  The front page gets wiped out.

It seems that the AL print_section() is breaking the front page sections.  So I did the following.

course/lib.php - created function print_frontpage_section() that is a copy of original print_section().  The original print_section() comes from 1.8+.  This is because AL's print_section() breaks the front page when it has a topic section.  Also added:
$str->lock      = get_string("lock","lock");
$str->unlock    = get_string("unlock","lock");
to function make_editing_buttons().

index.php - changed print_section() to print_frontpage_section().

topics/format.php & weeks/format.php - added:
$strlock = get_string('lock','lock');
$strunlock = get_string('unlock','lock');

I am attaching a zip file of the above modified files.  It also include an error log.  Can you tell me if I am on the right track?  It seems to work fine on my servers.

Roel

In reply to Roel Cantada

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Roel Cantada -

For my online server I cut & pasted activity locking code to my 1.8 moodlelib.php and lib.php file using phpeclipse.  I'm crossing my fingers, but it seems okay.

I have attached the modified files, please read the readme.  You can also look at the results here http://www.tagalog.ws/course/view.php?id=6.

In reply to Roel Cantada

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Chardelle Busch -
Picture of Core developers
Hi all,

I'm just putting the finishing touches on an updated certificate mod for 1.8. After reading this, would it be helpful if I added locking to the certificate itself based on a grade?
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Lisa Stevens -
Yes please, Chardelle, that would be brilliant! We are currently trying to add the certificate mod at the mo which doesn't seem to be working quite right (almost, but not quite!) so looking forward to seeing the new version smile
In reply to Lisa Stevens

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by John Brady -

Hi Chardelle

I’ve set up a fresh 1.8.1 test site. And can test the certificate mod whenever it’s ready.
Thanks for working on this

In reply to Roel Cantada

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Bernard Boucher -
Hi Roel,
sorry for the delay still in vacationcool.
I just tested your patches and I found them very usefull as correcting bugs that I didn't know!

Your code is integrated in the new version of activity locking for 1.8.2.

Thanks for your contribution,

Bernard

In reply to Roel Cantada

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Bernard Boucher -
Hi Roel,
sorry for the delay some vacation cool

I just checked your site and I don't understand nor see what you mean by AL print_section() is breaking the front page sections.

Do you have a screenshot of that breaking.

I will be pleased to include your changes when I will understand themwink

Thanks for your work,

Bernard


In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Roel Cantada -

Hi Bernard,

You will not be able to see the problem in my site because I patched it already with my modifications.

Here are screenshots of the problem:

Below is the screenshot of the original moodle 1.8+ while it was not patched with AL yet. It has topics sections and topics is enabled from frontpage settings.

Image88.gif

 

Next below is the screenshot of frontpage when moodle was patched with the AL version from the modules & plugins page. I have not modified course/lib.php and index.php here. This is when I am not logged in yet, settings are the same as above.

Image84.gif

Here is a screenshot when I am logged in. Notice that the sections and everything else were wiped out.

Image85.gif

 

The next screenshot below is when I disabled the topics sections. The course list appeared normally now.

Image86.gif

The next screenshots are after I modified the course/lib.php and index.php as I have mentioned above. The screenshots appeared normal again when logged in and when not logged in. The topics sections had been enabled in the front page settings and AL is working.

Image87.gif

 

 

Image83.gif

The only visual difference that I saw between the course sections and the frontpage sections is that the frontpage sections do not have a column of editing icons for a section. This is true even when editing is enabled as can be seen in the figure below:

Image89.gif

In reply to Roel Cantada

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Roel Cantada -

P.S. I use the topic section for the frontpage in my site to replicate the moodle.org frontpage layout.

In reply to Roel Cantada

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Roel Cantada -

Oh, the last screenshot of the difference between frontpage sections and course sections is not a result of my modification.  It is a charactersitic of the original moodle that was unpatched with AL.

I pointed it out so as to narrow down the problem with the AL modified print_section() because I don't have the capability to step through this function.

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Michael Penney -
Does it backup and restore?

We made a version for 1.7 that does backup and restore, but it requires this patch for backing up and restoring blocks (gives full backup and restore functionality to blocks, which means you can backup and restore your AL settings from one course to another):

http://tracker.moodle.org/browse/MDL-8270

We can't release our version until the patch makes it into core, so please vote for itsmile.
In reply to Michael Penney

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Bernard Boucher -
Hi Michael,
sorry for the delay some vacation cool

Activity locking is not "backupable". When your patch will be released it will be interesting to see if it will make activity locking backup/restore able and what conditions ( names of tables and/or fields ... ) will be required.

Thanks for working on that,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Marios Katsis -

Is there a way to download the zip file Activity Locking V 2.0 for 1.8.1 only?

I try for days to download it from table, but nothing. Maybe the server is down.

if anyone could upload it.

Thanks

Katsis Marios

In reply to Marios Katsis

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Bernard Boucher -
Hi Katsis,
first welcome to Moodle. ( I hope Katsis is your first name! )

I just changed the link because I used the intranet ( 192.168. ... ) address instead of the internet address. Both address works fine for me but only one works for you and the others. I apologize for my errorblush

Thanks for asking,

Bernard



In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Chris Collman -
Picture of Documentation writers
Hi Bernard. Been away on another project for a month. I am having trouble with the http://206.167.134.155/bb/authoring1/Activity_Locking_V2_0_for_181_June22_07.zip
link. ..134.155 is not responding.

Could be dust in my network connection smile Thought I would give it a test on a 1.8.2 Moodle.

Best Chris
In reply to Chris Collman

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Chris Collman -
Picture of Documentation writers
Hi Benard,
Found the June 22 file I downloaded at home and brought it to work. Created a clean Moodle 1.8.2 and brought in a simple course. Lesson1, Lesson2, quiz and an evaluation. There were 2 questions in each lesson and the quiz. Installed AL and nothing crashed or screamed at me. Great !

I set the locks so student had to access Lesson 1, then Lesson 2 and then they could take the quiz. They had to get a score of 1 on the quiz to fill out the evaluation.

When my student Fill Hill took the course, it would not recognize that Lesson 1 had been completed. I had to play with lesson 1 settings. When I set max grade to 1 from 0, that solved the problem. Noticed I had custom scoring set to on. Made that change in Lesson 2 as well. With those changes, AL worked and locked and hide the way I told it.

So there might be an issue determining if an activity or resource is accessed (completed?). Merely accessing an activity is not something we would select as part of a conditional activity, thus it is not a big issue for us.

Now I will install Certificate and see what happens when student Dim Witt takes the course. Mr. Witt is not the brightest light bulb in the pack smile He has a hard time passing anything the first time. Thus he is a great tester !

Best Chris


In reply to Bernard Boucher

Re: Activity Locking V 2.0 for 1.8.x only with Certificate

by Chris Collman -
Picture of Documentation writers
Hi Bernard,
A continuation of my previous post. I duplicated the simple lesson. Added Certificate Pro to the Moodle 1.8.2. Put Mr. DimWitt into a student role. Made sure the locks were set the same and added one for Certificate.

Amazing, it took Mr. Witt at least two attempts at everything to move on! But you will be please to know eventually he received his certificate. The teacher had to reset lesson settings to score the max on any retake.

I only used AL for the conditional settings. I DID NOT use any in Lesson nor any in Certificate. Everything worked the way it should for me.

Note: I will now attempt to have the teacher break it. I am not sure if Lesson and Certificate might "fight" with AL, but as long as I know the path of few problems, I am happy.

Thanks for your continued effort. Chris
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.1 only

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Bernard, could you please remove some of the extra entries in the moodle modules database?

Instead of an entry for each version of this patch there should be one entry in there with links to all the different entries (perhaps just a link to that table in the docs, even).

Thanks for all your work on this, I know a lot of people find it useful.