Conditional activities: Activity Locking V 2.0 for 1.7.1 only

Conditional activities: Activity Locking V 2.0 for 1.7.1 only

by Bernard Boucher -
Number of replies: 44
Hi all,
as promised but 1 month delay check it 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.

Please don't test it on a production server.

Let me know if it works fine ( I don't use 1.7.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.7.1 only

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers
Hi Bernard -

I needed this and was just going to start working on it, so thanks!

Have you checked this into CVS at all, with a 1.7 branch tag?

mike
In reply to Bernard Boucher

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

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers
Hi Bernard -

I have a couple of 'specific' questions...

In the 'locklib.php' file, the function 'activity_complete':

1. It calls a 'get_record' function to get the actual activity, but it doesn't appear to use the record it gets anywhere. I'm guessing that can be removed then?

2. When checking the logs to see if the activity has been accessed, it searches the 'userid', 'module' and 'info' fields. The 'module' and 'info' fields are character fields which don't have any indeces that can be used in this particular search and can slow down the search (I've seen this on large sites). Is there a reason why we can't simplify that and search for the 'userid' and the 'cmid' fields only? Do you know if there's a known issue weherby some activities might not set the 'cmid' field? If not, it would speed things up a lot to use the two integer fields, and the create a new index on both of these fields.

mike

In reply to Mike Churchward

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

by Bernard Boucher -
Hi Mike,
I am very happy that a your are interested by Activity Locking.

0. - It is not in CVS. I did'nt took time to learn it. Maybe I should have save time if I did it! But If you want to put it in CVS , go ahead, that will encourage me to learn it and to use it.

1. activity_complete ( from Stuart Mayor ) use get_records to feed the variable $requiredgrade to check if there are some restrictions in the table course_module_locks that have to be satisfied before granting access to the particular activity. Arrays are used because many restriction can be considered in same time before granting access to a particular activity.

The names used are a little confusing:

- activity_complete let suppose that it check only for a completion, an access to an activity.
- $requiredgrade let suppose that it check only graded activities.

But in both cases the checks for access and grading activities are performed.


2. Sure that optimisation was not too much considered wink.
A major rework from John Gschnaidner named Score Lock use a new table, not the log table, to keep account of the access. Unfortunatly John is sick and he did'nt get the chance to finish his new version. John added also David Delgado drill down capability to the question level for the locking mecanish! That table show you the differents versions and their features.

Depending how much time you have to invest in that and also, if you want to integrate it in moodle main version here are some comments:

- 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 longer to do.

- Maybe if Martin explain briefly how he envisage to do it in moodle 2.0 should save time to you to do it in a 'martinized" way the first time ;-)

- Socre Lock is probably a better start point than activity locking if you want more features and better code to start.

- If you want more features then maybe regulate rights is part of the solution. It permit to have differents activities for differents groups at differents times. ( 3 functions and 200 lines of code to add to activity locking )

I hope it may help,

Bernard












In reply to Bernard Boucher

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

by Chris Collman -
Picture of Documentation writers
Hi Bernard and Mike,
I tried downloading from two places and could not, plus the Module and addin download tab which linked to the 134.155/bb below.

The links via MoodleDocs timed out for me. I used this. http://206.167.134.155/bb/authoring1/Activity_Locking_V2_0_for_171_Feb1907.zip

http://download.moodle.org/download.php/patches17/activity_locking.zip
also did not seem to exist.

I have a localhost ready to test this feature with my simple stuff as my contribution smile Thanks for all your efforts. Chris
In reply to Chris Collman

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

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers
Chris -

I just put the code into CVS today. It can take up to 24 hours before its available at the download link. Try again tomorrow.

mike
In reply to Mike Churchward

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

by Sreeprakash N -
Hi,

I have installed Activity Locking V 2.0 for Moodle 1.7.1 on my Moodle 1.7.1 (latest stable)

The new table has been created with the right prefix, new fields are added correctely to the table and the files copied with the same structure/locations. Closed and started the browser and logged in.

But I do not see any change, no new tabs for the lock settings!

I am using Courses in the Topic mode.

I am missing something, can you please help, I know PHP but I am new to moodle!

Thanks,
Sree
In reply to Sreeprakash N

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

by Bernard Boucher -

Hi Sreeprakash,

if you check carefully from that table in the teacher interface column, that version of activity locking use padlocks icons not tabs for setting locking only when you are in course edit mode.

I hope it may help,


Bernard


In reply to Bernard Boucher

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

by Sreeprakash N -
Hi Bernard,

No cant see that lock, I am missing something, here is the screen I am in, may be I am looking at a wrong page.

Thanks,
Sree
Attachment Image1.gif
In reply to Sreeprakash N

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

by Bernard Boucher -

Hi Sreeprakash,

sorry for the delay, the internet at the hotel at Varadero was so slow, nearly impossible to check emails!

I just reinstalled it with new lastest 1.7.1 version and I got the padlocks immediately in topic and in week modes as the attached image!


Maybe you reinstalled a new moodle release over the old one with activity locking already installed. In that case you will loose padlocks. Try reinstalling activity locking or maybe better moodle and activity locking.

Let me know if it works.

I hope it may help,


Bernard


Attachment lock3.png
In reply to Bernard Boucher

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

by Sreeprakash N -
Thanks Bernad.. will do a backup fresh install and try this this week..
Regards,
Sree
In reply to Bernard Boucher

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

by Genie Wu -

Hi Bernard,

Thanks for the activity locking 2.0 for moodle 1.7. :>

I have been testing it for the last few days. So far I am successful with locking a certificate, quiz (kind of, before its prerepuisite scorm is accessed), web page, and scorm. I have problems with a quiz that is locked and its prerequisite is a scorm (report method: 0 or 1, require grade=1). After viewing all the slides, the scorm grade becomes 1 in the grade book and the quiz prerequisite box is checked. There is a message when the debug mode is on in the quiz page:

Fatal error: Call to undefined function: scorm_grade_user() in /home/columbia/public_html/moodle/mod/scorm/lib.php on line 377

Any idea where I should look into?

Thanks,

Genie

 

In reply to Genie Wu

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

by Bernard Boucher -
Hi Genie,
the function scorm_grade_user is not part of activity locking but of the scorm module. It is defined and included in the file mod/scorm/locallib.php.

Can you check if the file is present and if it contain that function?

Let me know your results.

I hope it may help,

Bernard

In reply to Bernard Boucher

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

by Genie Wu -

Yes. The function is in mod/scorm/locallib.php and is present.

One thing I didn't mentioned is that i replaced the test with a web page (scorm ->webpage(locked) and I was able to access it after the scorm grade=1. So I am not so sure if the problem is with scorm.

Thanks,

Genie

In reply to Genie Wu

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

by Bernard Boucher -
Hi Genie,
thanks for the details.

First I never use scorm module.

Can you make a simple test on you site: try to lock the quiz with another quiz to see if it work.

Also watch the gradebook to see if the scorm and the quiz grades appears the same way.

Let me know your results.

I hope it may help,

Bernard

In reply to Bernard Boucher

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

by Genie Wu -

Hi Bernard,

Thanks for your suggestion and I tried what you suggested and other couple combinations: 

1. quiz+quiz(locked) --->worked

2. scorm+scorm(locked)--->worked

3. scorm+resources(locked)+quiz(locked)--->worked

They all worked but not scorm+quiz(locked). Fatal error: Call to undefined function: scorm_grade_user() in /home/columbia/public_html/moodle/mod/scorm/lib.php on line 377

And i went back to my previous 1.6 Moodle installation with ScoreLock and scorm+quiz didn't work.

This is a gradebook view:

activity_lock3.jpg

Pre-test and post-test are the same. But post-test page is blank. Can't take the test. Scorm is recorded as 1(finish viewing all slides) and 0.

Any suggestion welcome. Thanks.

Genie

In reply to Genie Wu

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

by Bernard Boucher -
Hi Genie,
thanks for your testing.

Maybe another test before a modification:
scorm+resources(locked)


Now a suggestion to try on a test system only:

There are some occurences of require_once('locallib.php') in the file mod/scorm/lib.php that specify the path to the locallib. That relative path is good if the call to the function is done by the scorm module. But if the quiz or another module call it then the relative path is bad and the function scorm_grade_user() will not be found!


Can you replace all occurences of

require_once('locallib.php'); with

require_once($CFG->dirroot.'/mod/scorm/locallib.php');

only in the file mod/scorm/lib.php.

Let me know if it works.

I hope it may help,

Bernard


In reply to Bernard Boucher

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

by Genie Wu -

hi Bernard,

Right on! It's solved! I played with that require_once parameter before but I didn't add the dirroot part and of course it didn't work. Thanks so much for being so specific! I knew it would probably work just by reading your explanation. The functionalities I need for activity lock seem to work fine.

Genie 

  

In reply to Bernard Boucher

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

by michael jones -
Hi, I have two courses that are SCORM format. Each course only contains the SCORM, which is a flash file. Let's call them:

Course A
Scorm 1
Course B
Scorm 2

Can I use activity locking to make Course B not appear at all to users who have not completed Course A? So basically they won't see Course B in their customized course list.
In reply to Bernard Boucher

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

by Jose Antonio CM -

Hallo. I tried it in Moodle 1.7.1. Appears the next error:

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

Can you help me?

In reply to Bernard Boucher

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

by Chris Throup -
This is a very quick and dirty hack, but I have made this work with Moodle Moodle 1.7+ (2006101009) -- might be useful to people running another install of 1.7.

Chris
In reply to Chris Throup

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

by Rick Knowles -
Has anyone found a problem with activity locking slowing down the course.  I have found that if there are several locks such as the studetn must complete 10 activities before they can take a quiz this can really slow down the course.  Any ideas?
In reply to Rick Knowles

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

by Bernard Boucher -
Hi Rick,
sorry for the delay a small overload here.

Activity locking is not optimised at all, it contain only minimal code to work. Maybe if someone with some time and some experience with Mysql indexes can speed it up!

A simple test if you use standard theme with perfdebug activated: you will see # of db access and the time required to display the page: check the difference in time and db access to display the problematic page as a student and as a teacher. The locks are not evaluated when you are a teacher.

Let me know the numbers you get.

I hope it may help,

Bernard



In reply to Rick Knowles

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

by Chris Collman -
Picture of Documentation writers

Rick,

Just curious. Do you care in what order the students complete the activities?   Just wondering on the quiz conditions if you have checked off all 10 activities.  Or if you have ordered the activities, so the student must completing Activity1 before Activity 2, then complete Activity 2 before Activity 3 and so forth until the student must only complete Activity 10 before taking the quiz.  

My question to everyone, would one method take longer to process than the other?   

Chris

In reply to Chris Collman

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

by Rick Knowles -

Yes.  Student would complete activity 1 then Activity 2 would unlock then on to activity 3 etc.

Rick

In reply to Chris Throup

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

by Chris Throup -
It seems the directory structure has gone a little strange in the ZIP file I uploaded. I'd love to blame it on some technical problem, but I think it is most likely that I have forgotten how to use WinZIP.

Anyway, attached is a ZIP with the file structure intact. Created and tested in WinRAR; I know this one works (crossedfingers).

BTW, in case it wasn't clear from my first post, this is Bernard's code backported to Moodle 1.7+ (2006101009). The fact that Bernard's code wouldn't work on our Moodle install without modification would suggest that my version is unlikely to work on any newer versions of Moodle.
In reply to Chris Throup

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

by Bernard Boucher -
Hi Chris,
Thanks for your work.

I just updated the table to reflect your version.

If you put your code in the module database then it will be easier to make corrections to your link.

I hope it may help,

Bernard



In reply to Chris Throup

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

by Fido Aragon -
Hi, Chris.

Thanks for you work on AL for 1.7.1, It's great modul...mrknout

I downloaded your lasted version AL (from 20.3.07)and tested it on moodle 1.7.1 , 1.7.1+ and 1.9.
But I have a problem whit prerequisites activity on locked activity smutek. For example, I set that the student must completed test1 and than he can do test2, but If student completed test1, test2 is not unlocked...

I try to find what is wrong, but I'm novice in moodle smíšený pocit

Can you help me? Or have you any idea where I should look into?

Thanks,

Fido

PS:I'm sorry for my english, it is not my eminency smile
In reply to Fido Aragon

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

by Chris Throup -
Hi, Fido.

I'm not sure if you intended that message for me. You will need Bernard's module (link at top of this thread) for Moodle 1.7.1. I would guess (although I haven't tested) that it will not be suitable for 1.9.

The version I have posted is simply Bernard's module edited to be compatible with earlier Moodle 1.7 releases. I have not contributed any effort to activity locking itself, just had the patience to work out the differences between the affected parts of Moodle 1.7+ and 1.7.1.

My only tip, assuming you have the correct version for your Moodle install, is to make sure you visit the admin page to update the Moodle database.
In reply to Chris Throup

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

by Fido Aragon -
Hi Chris,

Thaks for your answer.

I'm sorry, I forgot write here that I tested Bernard's module on Moodle 1.7.1, 1.7.1+ of course too. But my problem was same.

Ok, I try write to Bernard for help úsměv



bye Fido
In reply to Fido Aragon

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

by Bernard Boucher -
Hi Fido,
if you respect the matchs of Moodle and activity locking of that table then it should work.

Activity locking is not "reinstallable" over and old version, nor after and upgrade or a downgrade of Moodle.

It works only with fresh new install of Moodle and activy locking.

Also you may experience problem if you test it with Moodle "logging as" feature. Log really as a real student to test it correctly.

Can you precise yourphp and mysql versions?

Let me know if it work.

I hope it may help,

Bernard

In reply to Bernard Boucher

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

by Fido Aragon -
Hi Bernard,

Thanks for your help...

My problem was, that I tested with Moodle "logging as" feature. If I logout and than loggin like other user (student), the AL work correctly. mrknout

Thank you very much,

Fido

PS: Of course I tested AL on regular version Moodle and I installed AL to a new installation Moodle every time. But when it didn't word, Than I experienced whit other version Moodle and AL.

PS2: Maybe this information can be write in the documentation of AL mrknout (I don't know when can I write it there - my english isn't excellent).
In reply to Fido Aragon

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

by Chris Collman -
Picture of Documentation writers
Hi Fido,
I added your excellent suggestion to Moodle Docs under Tips & FAQs.

I have run into this issue before with other modules. I never trust the change view or change roles when I am testingsmile. That is why I have my faithful users Dim Witt, test user1, and test user2 always available in every Moodle.

Thanks for sugestion. Chris
In reply to Bernard Boucher

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

by Tom Pendley -
Hi Bernard,

I am wondering if you have any plans to do an activity locking version for moodle 1.8.

I had it working great on 1.7.1 but unfortunatly my primary activities are SCORM packages so that I can deliver flash video and the like and then track.

it seems that 1.7.1 has a fatal bug for SCORM and I doubt that it will get much attention as they work toward 1.9 amd 2.0

I will probably be running 1.8 untill 2.0 comes around and AL would be really great.

Just a wish

Tom
In reply to Tom Pendley

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

by Bernard Boucher -
Hi Tom,
sorry for the delay, a small overload here.

I am using only moodle 1.6.1 at work. 1.7.1 and 1.8 will require that depreciated functions that activity locking use, will have to be replaced with appropriate new roles functions. Check that post to see the problems. Time always time!


I hope it may help,

Bernard

In reply to Bernard Boucher

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

by Michael C -
Activity Locks

There are 19 locks within this course

Lock Settings

Locks are not displayed for this course

How do I go about changing the settings?  In the block there is no way to edit.  Is something out of whack someplace.  I did a fresh install and the database was setup correctly.

Could this be the reason that most of the front page doesn't show up? 

In reply to Michael C

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

by Bernard Boucher -
Hi Michael,
sorry for the delay, a little overload here.

If you respect the combinasions of moodle version and activity locking from that table then it should work fine.

Can you precise you moodle version and activity locking version?

Also can you precise what you mean by "Locks are not displayed for this course" setting wich is not part of activity locking 2.0 for 1.7.1


I hope it may help,

Bernard

In reply to Bernard Boucher

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

by Michael C -

No problem at all.  I totally understand how busy you are.  I figured it out.  I deleted an older version of activity locking, reverted back the database before the install and tried all over again.  It worked except for one minor problem.

Moodle 1.7.2 + (2006101020)
Activity_Locking_V2_0_for_171_Feb1907

When TOPIC is checked for the look on the front page, all courses disappear, when I uncheck TOPIC then everything is fine and the courses show up.

I just figured this out late last night.  Any ideas as to why display Topic would do this?

TY for your help,

Michael

In reply to Michael C

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

by Bernard Boucher -
Hi Michael,
I am happy that your system works fine!
For the "topic checked " problem maybe it is related with the differences with some files of moodle 1.7.1 and 1.7.2+

Activity locking is only a hack and it use some of original moodle files slightly modified. That is whyit name specify explicitly the moodle version implied 1.7.1 in that case.

A fast check to moodle cvs give these 2 files changed. Maybe if you check the differences with 1.7.1 version and 1.7.2+ version you will be pointed in the right direction to fix the bug:


lib/moodlelib.php

course/lib.php

I hope it may help,

Bernard


In reply to Bernard Boucher

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

by Ryan Closs -
I'm new to Moodle so it's entirely possible I'm missing something completely obvious but I followed the steps, copying over all the files and running the mysql command and while I'm seeing it in the blocks list and I can add the block to a page I can't find anywhere that I can actually set the activity locking rules.

I'm running 1.7 and installed the version for 1.7.

Any help of guidance would be fantastic.

Ryan
In reply to Ryan Closs

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

by Bernard Boucher -
Hi Ryan,
if you check carefully that table you will see that the version of activities locking for 1.7 done by Chris is supposed to install mysql tables automatically, so you don't have to do it manually.

To lock an activity you have to go to the edit mode of moodle and a padlock icon should appear near each activity. Clicking on that icon bring you to the lock screen.

If by mistake you have installed an other version then the lock screen is accessible when you try to edit an activity with the precil icon.

Can you double check your moodle and activities locking version and report it here please.


I hope it may help,

Bernard
In reply to Bernard Boucher

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

by Ralph Blakeslee -

Bernard & Company:

Is there a significant difference between Moodle versions 1.7.1 and 1.7.2?  I have installed AL 2.0 for 1.7.1 on a site running 1.7.2 and seem to be having some issues.  Example:

Fatal error: Call to undefined function: isunlocked() in /home/gover4/public_html/campus/course/lib.php on line 1123

On the front of my page.

Thanks

Ralph

In reply to Ralph Blakeslee

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

by allen tseng -
Hi Ralph,

We encountered the some problem. add following line to ./course/lib.php in line 1123 seems to solve it temporarily.

//bb if ($mod->visible or has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
require_once($CFG->libdir.'/locklib.php');
if (($mod->visible and (isunlocked($mod) or $mod->visiblewhenlocked)) or has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
echo '<li class="activity '.$mod->modname.'" id="module-'.$modnumber.'">'; // Unique ID