Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Number of replies: 43
Hi all,

you will find a new version of activity locking for Moodle 1.8.2 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.

The bug of 1.8.1 time delay ( relative to course first enrollement ) is corrected using moodle log table.

Please don't test it on a production server.

Let me know if it works fine ( I don't use 1.8.2 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.2 Only

by Bernard Boucher -
Hi All,
just updated to include Roel code to fix bug in main page when topics are used.

Thanks Roel,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Stuart Hiles -

Hi Bernard.

I've installed the 1.8.2 version and am having problems. Most of my courses are in topics format, and when debugging I'm getting the following issues:

"Notice: Undefined variable: locks in /home/elcelea/public_html/course/lib.php on line 1585
  
Notice: Undefined property: lock in /home/elcelea/public_html/course/lib.php on line 2550

Notice: Undefined property: lock in /home/elcelea/public_html/course/lib.php on line 2553"

Error messages appear in labels, resources, forums etc.

I'd like to get this working as I want users to complete a pre-course questionnaire using the Feedback block before undertaking a SCORM activity. We have over 100 courses where I would like to apply this, and think it is a really useful concept.

Many thanks,

Stuart 

In reply to Stuart Hiles

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Stuart Hiles -
The problem is with Ajax. If I disable Ajax support then it all works correctly!
In reply to Stuart Hiles

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Stuart,
ajax is still experimental and I did'nt try to use it with activity locking.

Thanks for "auto answer" yourself wink

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Sacha Brostoff -

Hi Bernard!

Thanks for all your work on this - I'm very excited at the prospect of using it!  I've run into a problem, and don't know if it's just me being stupid or what?

I've 'installed' what I think is the latest version (14th Aug 2007) into 1.8.2.  How I did this was unzipping your zipfile, then moving the contents of the folder Activity_Locking_V2_0_for_182_August14_07 (the 5 folders and index.php) into the root moodle directory.

When I go to the course main windows (e.g. http://localhost/moodle/course/view.php?id=4) I get a completely blank screen. 

I had a window still open on the lesson page (e.g. http://localhost/moodle/mod/lesson/index.php?id=4) from a previous session - and that still works fine - I can still view lessons as normal.  It seems it's the course main page that's problematic.

My course uses topics.   Is this the infamous topics-main-page bug?  Ajax is switched off.

Best regards,

Sacha

In reply to Sacha Brostoff

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Sacha,
you got the same problem than Dmitriy: a new function editcourseallowed was instroduced since 1.8.2 in 1.8.2+ and it created a fatal error wink when called in weblib.php!

It is not too hard to fix it, I will try it later this week.

I hope it may help,

Bernard

In reply to Sacha Brostoff

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by teresa pomposo -
Where is the file "Activity_Locking_V2_0_for_182_August14_07.zip" that Sacha was talking about?

When I download the file for moodle 1.8.2 from the table http://docs.moodle.org/en/Activity_Locking#Table_of_Versions

the file has the name "Activity_Locking_V2_0_for_182_August13_07.zip"

Is the same file??
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Chuck Kimball -

When setting up the activity locks, under Settings there are boxes for "Style to use when the activity is complete" and "Style to use when the activity is locked".  I am not sure what needs to be in the boxes.  What is the purpose of these settings?

Also, can the settings be accessed directly?  On the main page of the course it states how many locks are within the course and the lock settings (mine shows:  "Locks are not displayed for this course").  The locks seems to be working but I can't tell if I am missing something.

Thanks!

In reply to Chuck Kimball

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Roel Cantada -

Hi Chuck,

For the settings "style to use...", Stuart Mayor told me a long time ago that:

"These settings allow you to specify a CSS style to use.
e.g. Create a CSS style "completed" in your stylesheet then enter "completed" in the field.
This allows you to, for example, display completed items with strikethrough"

You can find the original discussion thread here: http://moodle.org/mod/forum/discuss.php?d=33184

Roel

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Michael DePalma -
Hi Bernard.

Thank for for such an awesome Moodle addition! Is there a way to make it work in reverse? i.e. if a student receives a lower score it unlocks additional content? Thanks!

Mike DePalma


In reply to Michael DePalma

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Michael,
to have it working in reverse you will have to modify at least 2 lines of the file lib/locklib.php:

Lines 41 and 76 : Look for >= and change it for <, that may be a good start!

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.8.2 Only

by Michael DePalma -
Success! (That was a little too easy)...

I just swapped >= for < everywhere. I'll try with some more users,courses, etc. Thanks again!
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Stefan Gössler -
Hi just to add my two cents:

this looks just GREAT - and it would help with an issue I see quite a lot:

cluttered screens which keep first-time-users from using moodle at all.

Background: I'm using moodle in training settings. My participants are of the age of about 22 upwards - sometimes in their 40's with little computer skills. When these folks see a screen full of articles, lessons, slideshows, questionnaires and so on they feel lost pretty often. I had one case who opened moodle, looked at it and closed it again for good.

Now, I'm using a Theme based format and hide quite some stuff but for the start people still see about 10-15 different activities.

What I'm hoping of this addition is, to be able not only to make things dependent on scores but also e.g. hide things until the first 3 articles have been read or the self-assessment questionnaire has been completed. Also it would be great if then there could be a one-time news-message telling users "congrat, you've just unlocked additional content, be happy!"

stef
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Simon Burnell -
Hi Bernard,
thanks for a great module, however, although it locks a certificate until a student has achieved a certain score in a quiz, if I make the certificate dependent on an assignment, it doesn't unlock when the assignment is satisfactorily completed.

Any guidance would be much appreciated,
Simon
In reply to Simon Burnell

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Simon,
first it is not clear wich versions of activity locking and certificate you are using.

The lastest certificate from download modules don't need activity locking for locking a certificate:

.


The locking mecanism of activity locking works fine also :

.
.

I hope it may help,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Simon Burnell -

Hi Bernard,

thanks for the reply. I'm using Moodle 1.8.2 and the appropriate activity lock, however I'm using an old certificate module which, since it was working, I haven't looked at since installing it a while ago!

I'll install the new version and see how I get on with it, however I wonder if it's worth you looking at the activity locking which wouldn't unlock when an assignment was completed (but workied fine with the quiz module).

Thanks again,

Simon

In reply to Simon Burnell

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Simon,
if you check carefully the 3 images of my previous post you will see that:

the first if the new certificate interface,
the second the certificate locked waiting for the assignment
and the last is the certificate unlocked after the assignment was completed.

Yours should do the same.

I hope it may help,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Simon Burnell -
Hi Bernard,
I've had a chance to install the new certificate mod (1.7.2.2). I'm still having problems thoughsad
The certificate will lock and unlock based upon the results of an MCQ quiz, but will not lock based upon an assignment. The lack of locking also occurs if the assignment is the only "dependency".

If I use Activity Lock to lock access to the quiz based upon the student passing the assignment, then the lock doesn't unlock when the student passes the assignment. This is the same problem I was having when using the previous version of the certificate mod with Activity Lock!

My setup is
Certificate which depends on:
Offline Assignment pass grade 100/100
Quiz MCQ pass grade 75/100

MySQL tables

certificate_linked_modules
Full Texts id
certificate_id
linkid
linkgrade
timemodified

Edit Delete 1 1 35 75 1192081548

Edit Delete 2 1 35 100 1192084387

Edit Delete 3 1 -1 0 1192084387

Edit Delete 5 1 30 75 1192084387

I've also tried using Activity lock to make the Quiz dependent on the Assignment, but, as I mentioned earlier the lock doesn't unlock

course_module_locks
Full Texts id courseid moduleid lockid requirement

Edit Delete 43 8 30 35 100

Although I've had no other issues with it, the only other thing I can think of is whether php version (5.0.5) is causing problems.

Simon

Moodle 1.8.2
Activity locking v2.0 for 1.8.2
Certificate 1.7.2.2
In reply to Simon Burnell

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Simon Burnell -

Hi Bernard,

I've sorted it out!!

The MySQL table references had somehow got the incorrect module references and when I backed up and restored the minimum info from the course, they sorted themselves out.

Thanks for your help by putting me on the right track with the new cert module,

Cheers,

Simon

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Rich Schumaker -
I guess I'm a little slow but I am having some trouble with the install. I downloaded the zip file and uncompressed it leaving me with a folder entitled:

Activity_Locking_V2_0_for_182_Sept25_07 Folder

I put the uncompressed folder in the root of my Moodle install but I did not see any installation of the activity when I opened Moodle. Could I get some idiot proof install instructions? Thanks in advance.
In reply to Rich Schumaker

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Roel Cantada -

Hi Rich,

Inside the Activity_Locking_V2_0_for_182_Sept25_07 Folder you will find files like index.php and folders like mod, lang etc.  These contents are what you should copy to the root of your Moodle install not the parent folder Activity_Locking....  It will overwrite some files like the index.php, course/lib.php, etc.  Make sure to  back up your installation.

Hope that helps.

Roel

In reply to Roel Cantada

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Rich Schumaker -
That's kinda what I thought but I wanted to make sure. Thanks Roel.
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Walter Matheos Jr -
Any news about Activity Locking V 2.0 for 1.8.3+ ?


In reply to Walter Matheos Jr

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Manel Lopez -

I've installed Activity locking in Moodle 1.8.3+

Whem I'm going to edit the course, I only can see the forum activity.

Any sugestion?

Thanks in advance

In reply to Manel Lopez

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Manel,
you will find all the versions of activity locking in that table. 2 versions exist for 1.8.2 and 1.8.2+.

Unfortunately there is no version for 1.8.3+

The only thing that I am sure is that version for 1.8.2 will not works for 1.8.3+ because it use a modified version of moodlelib.php the most modified file of Moodle.

Two simple options:
to use the appropriate version of Moodle 1.8.2
or to wait for Moodle 2.0 wich according to roadmap will include a real
conditional activities code.

A more complicated option is to apply 1.8.2 modifications to 1.8.3+ code.

I hope it may help,

Bernard
In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Manel Lopez -

Hi Bernard

My kmowledge of PHP says me I migth wait for 2.0

Thanks a lot

In reply to Walter Matheos Jr

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Walter,
unfortunately the short answer is no.

Sure it is possible to apply old changes to new 1.8.3+ or to 1.9 code but more Moodle evolve more you will loose functionnalities. For example activities locking don't support new roles, you will have to use depreciated functions to make works or to insert new roles functions to make it compatible with recent Moodle. Samething with new gradebook.

If you wait a little then the new Moodle 2.0, according to the roadmap, should integrate conditionnals activities not as a hack but as a new core feature.


I hope it may help,

Bernard


In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Steve Lon -
I installed the most recent version of AL (Activity_Locking_V2_0_for_182_Sept25_07.zip) on 1.8.3 and get "prerequisite not complete" on a locked quiz.

I had checked "User must access this activity" on a previous forum.

After the user accessed and created a posting on the forum, the quiz is still locked.

Any ideas?
In reply to Steve Lon

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Steve,
the word Only is added to each version of activity locking because it use moodlelib.php, the most modified file of the moodle system. I didn't have tested Activity_Locking_V2_0_for_182_Sept25_07.zip with moodle 1.8.3, only with the version of that table.

Maybe a question that I will test here :.: what kind of grading you put on your forum?

I hope it may help,

Bernard


In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Steve Lon -
Hi Bernard,

I guess folks like me like to push the limits, and try to figure things like this out but on this one, I just have no idea where to begin !

If all else fails, I'll just install a copy of 1.8.2 for production.

...So, I am using a scale of 1 to 4 for each forum. But I would prefer that the locking did not look for a score, or access, but rather that a student had actually created a posting.

What do you think?

Steve

In reply to Steve Lon

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Steve,
I just test your situation with 1.8.2 and in the activity locking screen the system only offer you : "user must access this activity" and not the gradesad It is normal that it don't work because the code don't permit it ( but I don't remember whyblush the code don't permit it ).

If you whant to test it try that:

In the file course/lock.php at line 108 you should have:

if (function_exists($gradefunction) and $mod->modname != "forum") { // Modules with grade function (excluding forums)

Remove the and $mod->modname != "forum" and try it. It works here and it may works also with your 1.8.3.

Let me know if it work with 1.8.3.

I hope it may help,

Bernard


In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Steve Lon -
Hello again, Bernard,

That works great!
I also changed the comment...
// Modules with grade function (including forums)

Now, perhaps you can help with another possibility...

I will give 1 point in each forum, just for a posting. Is there a simple way to default the grade for posting in the forum to "1" point, instead of "0" ? I am looking in mod/forum/post.php but am a little skeptical of myself. Can I set rating = 1 in here somewhere?

With AL, that will allow folks to post, and move on to the next activity, if set for 1. Then, I can reassign a grade.

Thanks,

Steve

In reply to Steve Lon

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Steve,
I am happy that it works for 1.8.3 too.

For your "auto-grading" of forums it is always possible to do it but you must always evaluate the cost or the time required to do it and the gain !

Generally speaking, when you hack a system like Moodle, less you touch modules better it is. Take me as a bad example: too many hacks too few time to adapt them : I am stuck ( but happy ) with my old 1.6.1 Moodle!

I don't have time for your hack but let me suggest a simpler hack of Moodle.

If you check attentively the log of a "posting" student then you will see that a event is added for that only:

.

It is possible to modify activity locking to check that event only when the predecessor is a forum.

If you revert the change to course/lock.php to it original ( no grading for the forum ) and if you modify lib/locklib.php to search precisely for that event in the log only when a forum is a predecessor activity you will be ok.

Around line 33 in lib/locklib.php you have :

if (record_exists("log", "userid", $USER->id, "module", $mods[$lockid]->modname , "info" , $mods[$lockid]->instance)) { //5
$locks[$modlock->lockid] = "open";

Not very clean but before $locks[$modlock->lockid] = "open";

If you make a test to see if the module is a forum and then if you check if a record_exist with the action = "add post" then that even will unlock your locked activity.

Doing it that way you will not have to modify the forum module and you will not introduce a "false grade" in the system and the students will have access to the locked activity without your immediate intervention only after posting.

Even if it is not very clear and not tested, I hope it may help!

Have a good hack,

Bernard






In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Steve Lon -
Hello Bernard,

Thank you so much - I did revert the change of course/lock.php to it original. Now I will begin work on the code like you have said. It will have to be a work in progress, this week, because I have so much to do.

I will update you when I have a workable solution. Also, I'll ask some friends to review the code before I post.

Hacking to my heart's content,

Steve
In reply to Steve Lon

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Chris Collman -
Picture of Documentation writers
Go Steve and Thanks Benard. Nice thread development here.

Been doing other things and saw the "hacking to my heart's content" in an email from this forum. I have been dumbing down from 1.9.3, learning about how assignment works in our 1.5.2 Moodle site, plus dabbling in MoodleDocs and Lesson Forum. Staying right away from hacking.

I think we will upgrade to 1.8.x . AL is on our list of must have installed. Thank you for all your efforts. Chris
In reply to Chris Collman

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Chardelle Busch -
Picture of Core developers
Hey Chris (et Bernard aussi),

Just to let you know, since I had to figure out the new gradebook API for the certificate (not recommended unless you have a case of wine handy) I have also updated the AL hack for 1.9. It seems to be working okay, but I haven't posted it yet. I might go ahead and add the forum posting log lock too.
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Chris Collman -
Picture of Documentation writers
What a great idea, "hacking with hock" or is it "plunk". Anyway, you all deserve a case each. I am doing my penitence with a redo of Section 7 in demo.moodle for 1.9 .

Looking forward to any draft of AL for 1.9 . I gotta run and find a grape graphic for the pages in the Lesson cluster. Best from snowy, and cold NH.

Chris
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Bonjour Chardelle,
I am happy that you continue to update Certificate and Activity Locking code to reflect recent Moodle Gradebook and maybe Roles changes. I will be pleased, when you will be ready, to update the link and the maintainers names in Moodle Modules and Plugins database.

Thanks for your relentless work,

Bernard

p.s. That may interest you : next semester my organisation will let me work nearly fulltime on the developpement of Socrate, a generator of scorm modules based on Bloom's taxonomy. I estimate that the authoring time will be cut by a factor of 10 and the students will get a Socratic Dialogue as feedback! The scorm module is nearly equivalent to these moodle modules : book, resource, quiz and maybe certificate! The scorm give full control on the navigation at the answer level, exactly what we try to obtain with Activity Locking!



More on that next April.


In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Chardelle Busch -
Picture of Core developers
Oooh, I can't wait Bernard! Sounds cool.

Yes, I got the timing code to work, updated roles (fixed it so guests don't get any tracking, etc.), print navigation, and whatever else I happened to see that needed work. It really should be updated to formslib--but that would take a LOT of work. I'll send you a link to the download.
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Derek Wahila -
Do you think you are ready to post/share the AL updates for 1.9?

We're working against the 1.9 release as we _need_ the groupings functionality for our content. The requirement is also to have pre-requisites for content. So from what I understand, AL is our best (only) option.
In reply to Derek Wahila

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Bernard Boucher -
Hi Derek,
sorry for the delay I missed that post.

Chardelle has posted a new enhanced version of Activity Locking here.

I hope it may help,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking V 2.0 for 1.8.2 Only

by Felipe Gomes -

Does anyone still have this module? I need for to version 1.8+


Thanks