Conditional activities: Activity Locking for Moodle 1.5+

Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Number of replies: 68
I've update my Activity Locking hack to work with the latest stable release of Moodle 1.5

  • A number of bugs and warnings have been fixed
  • There is now the ability to lock/unlock entire topics at once
  • Activities can now be locked by time. You can set a number of days/hours/mins a student has to be enrolled for for an activity to become unlocked. (This is still very rough though)
  • Probably other stuff I can't think of
Installation (on a new system) should be simple a matter of placing the files within the zip in their relevant folders in your Moodle installation. You must then visit the admin page of Moodle to upgrade your database.

People who already have part installations of Activity Locking... good luck.

Remember
THIS IS STILL IN DEVELOPMENT. USE AT YOUR OWN RISK.
Average of ratings: -
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
Hi Stuart,

Welcome back. This is really cool! One thing that is really great about this is that even without locking activities, you can still use this code for "progress tracking" by getting the green checks.

I haven't tested the time thing, but everything else was great. No errors installing the data tables; however, I still get the previously mentioned debug errors.

Also, I had a locked activity and clicked on it to get the "can't access... message", then when I went back to the homepage I got the green check (even though the activity was still greyed out and locked.  Any ideas on this?


In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
Hi again,

I have been trying to lock an activity based on a graded assignment and can't get it to work.  I tried adding the lock code to the submissions.php page, but that didn't help.  Any ideas?

As for the green check on locked activities above, I'm not seeing that behavior now, I think maybe the test user I was using before had been made a teacher so that was why I was seeing the checks.....never mind.
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Teachers, as you have seen, have a different view of locks.

Teachers should see locked activities as locked, all the time, even if they have completed the prerequisites. This allows teachers to keep track of which activities have been locked. Teachers should be able to access all activities in that course, regardless of an activity's lock state.
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Hi Chardelle,

Thanks for your reply.
Is there any chance you could refresh my memory on the debug erros you are getting? I've removed several of them in this release, but there's obviously still some I've missed.

Your second problem - I assume (or hope!) the locked activity you were trying to access was an activity that just needed to be viewed to mark it as completed. I've seen similar behaviour before. I think it happens when the lock-checking code is placed after the add_to_log function in view.php for that particular activity. The lock checking code looks for an entry in the log for that user on that module. If there is a record, it marks the activity as complete.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Bernard Boucher -

Hi Stuart,

              thanks for returning from the honeymoonwink

I have some problem with a fresh new 1.5+ Moodle install and activity locking .4.

The automatic installation is perfect .

The delay is ok.

But nothing is writen in course_modules_lock when I try to add some grade or access dependance.

If I add a record manually the lock is displayed correctly but as soon as edit it it is flushed and replaced with nothing.

I have checked a little bit the code and only the 3 delay parameters seem to be passed in that line

$passmarks = data_submitted();

I commented the tree delay parameters and nothing is passed then.

Thanks for your work and I hope it may help,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
That's slightly worrying Bernard.

A couple of things to try/check.
Firstly, the lock table should be called "course_module_locks", not "course_modules_lock". Did I make a mistake in the sql file or is it just your typo?
Secondly, could you try the following for me.
  • Open course/lock.php
  • Comment out line 62. It begins with redirect(
  • Insert a line after line 51 that says echo "$passmark ";
If you try and add locks now, your should get some feedback when you submit the locks. You should get a list of numbers and/or A's at the top of your screen.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Bernard Boucher -
Hi Stuart,
for the name of the table you are wright, I write my post not on my pc and only using my old memory!

With the redirect diasbled nothing is displayed if the echo is after line 51. The 2 conditions of the 2 if are false.

If I comment the 2 if and their corresponding braces to "force" the writing then only the 3 delays, no other passmark stuff ( predecessor, id, ... ) are present.

That give these 3 "false errors" :
.

I hope it may help,

Bernard

p.s. I will try to reinstall a new Moodle and activity locking tomorrow to be sure it is not only my fault.

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
This is very odd Bernard.

Initially, I thought that perhaps the <form> wasn't being created properly, so nothing was being sent by post data. It would appear from your post that post data is being sent, but not including all the module data.
I assume then, that the initial lock html page is not being created correctly. I have no idea why. Could you post a copy of the (html) page source made from lock.php?
Aside from that, I hope a reinstall fixes it wink
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Ralph Blakeslee -
Hello Stuart,

Thank you for working on this important feature. I hope it becomes standard in the next Moodle cycle.

I have installed the code in my test site that is running the latest version of Moodle 1.5. I believe that I have all of the files in their correct place. Updating the database went smoothly and no errors were reported. The interface looks great! However I am having a problem with getting somethings to work. Perhaps I am not doing something right. Let me explain.

I have a resource that is a web page framed in Moodle. The page is named "Certificate of Participation" The page should be locked and contingent on passing a quiz with a grade of at least 70%. After locking the this resource the white box and the words "locked" appear after its name. However, participants can access the resource without taking the quiz.

Conversely I have another problem with a forum board contingent to reading the course lecture. The course lecture is in a resource web page. The resource is configured to "pop up" over the Moodle classroom. A forum board is locked contingent on participants access the course lecture. Again the white box and words "locked" are located after the forum board's title. Despite participants access the course lecture the forum board remains locked.

This is leading me to think that I have not set up the activity locking correctly, however I have played around with for a few days and can not get it to work. Could the problems be based on the fact that some of these contingent resources are web pages links rather then activities and resources which a part of Moodle?

Thanks again

Ralph

In reply to Ralph Blakeslee

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
Hey Ralph,

I think if you have added the new resource view page (with the locking code) and then add your stuff to the page as a resource it should work--I've tried it and it does work with resources.

Also, here is a little trick with this stuff, if you want to really test it correctly, you cannot do the loginas for a test student. You need to log out as a teacher or admin, and then log in directly as the student--try that.  Also, just for the heck of it, try changing your course settings to add locking "before" each activity and see if that works. (I haven't tried the after).  
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
And here are the debug errors that appear right above each locked activity (and they go on and on):

Error: Turn off debugging to hide this error.

SELECT * FROM mdl_log WHERE userid = '1' AND module = 'forum' AND info = '6'

Found more than one record in get_record_sql !

Array
(
[892] => Array
(
[id] => 892
[0] => 1110859853
[time] => 1110859853
[1] => 1
[userid] => 1
[2] => 70.58.10.63
[ip] => 70.58.10.63
[3] => 4
[course] => 4
[4] => forum
[module] => forum
[5] => 33
[cmid] => 33
[6] => view forum
[action] => view forum
[7] => view.php?id=33
[url] => view.php?id=33
[8] => 6
[info] => 6
)

In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Ralph Blakeslee -

Thanks Chardelle for the suggestions. Interestingly enough, moving the check boxes from the rear of the item title to the front made some difference. Also, the check boxes appeared in front of all of the items. When I had the function set for the check boxes to be at the end of the titles they only appear on those items that needed to be view. Actually, having them in front of all of the resources and activities is a nice feature - it helps the student visually keep track of their work.

You were right about the "loginas" problem. I also created several new student accounts to test this out. The forum board that was locked, contingent on accessing the course lecture, works very well. My only observation is that when you set the lecture to be a resource that "pops up" over the classroom, the classroom page does not reload. This means the green check mark does not automatically appear next to course lecture check box. Although this might be somewhat confusing to some students I don't think it is critical. Once they attempt to access the forum board and return to the classroom page the green checks appear.

Unfortunately I still can not seem to get the other resource to be locked contingent on passing the quiz. The Certificate of Participation can still be accessed without taking the quiz:

moodle1.gif

I am not sure what I am doing wrong....

In reply to Ralph Blakeslee

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
Hi Ralph,

Glad you got things figured out, but you're right, I tested an html page and it doesn't lock. It also wasn't working for a composed html page either (although I thought I tried this before and it did?). Maybe Stuart can take a look at the resource mod to see if something is missing.
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Ralph Blakeslee -

Chardelle,

Thanks for the information.  This is an important feature and I glad to contribute is some small way to its testing and development. 

BTW - Happy 4th of July!big grin

Ralph

In reply to Ralph Blakeslee

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
The problems you are having with resources arise from an error I made when editing view.php for the resource module. I did a quick "whistlestop" tour of all modules, adding a few lines of code to make them lockable. Having reviewed the resource module, it appears it works slightly differently to other modules. I've changed the relevant code and it now appears to work on my machine.

I've attached the new mod/resource/view.php file for you (all) to try. I'll put it in as standard in the next release.

Oh, and happy 4th July to everyone "over the pond".
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Ralph Blakeslee -

Stuart,

It looks good.  I installed the two new files and everything works.  Great job and thanks.  If I wanted to remove the "continue" button when an activity is blocked which file would I look to change.  The view.php file?

The reason I ask is that my resources are set to pop up over the classroom page.  If a student hits the continue button they will have two instances of the classroom page open, which may be consfusing.

Again, thanks - off to the fireworks latter.

Ralph

In reply to Ralph Blakeslee

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Ralph. I think you're going to like this...

Firstly, download the attached locklib.php file to the appropriate folder.
Now, all you need to do it edit the view.php within whichever activity you want to alter the behaviour of.
Look for the line
    check_locks($cm);
and change it to
    check_locks($cm, 0);
        or
    check_locks($cm, 2);

Changing it to "0" will not display any button after the lock notice.
Changing it to "2" will display a "Close this window" button after the notice.
Use whichever fits your purposes.

It's worth downloading this file if you are not interested in the above behaviour as it also fixes another bug. It will be included as standard in the next release (the file, not the bug!).
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Ralph Blakeslee -

Rule Britannia!!!

Thanks Stuart!  This is great!  I will test it out today.

Ralph

In reply to Ralph Blakeslee

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Ralph Blakeslee -

Stuart,

I have been testing the hack for a few days and it works very well.  Thank you for adding that bit of code that allows for the close window/continue option.  It is great.

Ralph

In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by David T. Cannon -

Hello,

Well, I installed a new Linux box with the latest MySQL, Apache2, PHP5 (this is not forum to discuss the latter two combo). I then installed moodle 1.5.1_stable, which works as expected.

Next, I installed the Activity Locking patch, and the latest two files that were posted to this thread.

I dont get any locking at all. The course_modules_locks table is never modified.

Is there another update that I am missing or others have hacked, before I delve into modifying the libraries.

Dave.

In reply to David T. Cannon

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
When you say the course_modules_locks table is never modified? This is a new table that is created when you upload the block and then click on admin--you should get the tables creates successfully.... message. If you did that, then, you won't get any locking until you change your course settings to include locking--try setting it to add locking before an activity as the after might have problems.
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by David T. Cannon -

Chardelle,

The table creation gave all successful messages when I went to the admin panel.

Now, I have tried all lock settinings(before/after/none) the in course settings panel. When I click on a lock of the section, or a section step, the lock panel comes up. I then check other sections to complete before the selected one and click save activity locks.

The table does not get updated, and when I return to that lock panel, there are no check marks. There are no messages with debug=on, and nothing in my error logs.

Now, I am doing this as admin, I assume I have the permissions for that.

Thanks....Dave.

In reply to David T. Cannon

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
Hi David,

Yes you should be able to do it with admin. I had never tried locking a section before, but I just tried it and it worked fine, when I save changes, then the activities in that section turn grey and say (locked)--I'm assuming you aren't getting this.

I'm not sure I can help you, except to make sure you have all of the files uploaded under the course folder, the lib/locklib and all of the activity view files...

The only other thing I can think of is that I haven't upgraded my Moodle for awhile, I'm using $version = 2005060201; so maybe the latest version of Moodle creates a problem? (Also, I'm using Linux with PHP 4.3.11, Apache 1.3.33 but I can't imagine that that would be it).

What version are you using, and has anyone else had problems with later versions?
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by David T. Cannon -

My moodle admin page says, Moodle 1.5.1 (2005060210), so im a few verions ahead of you. Believe it was build last week.

I will also add that the label resource breaks with the lock mod in my version.

Dave.

In reply to David T. Cannon

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
I'll probably upgrade again soon, then I'll let you know what happens.  I also found that the label reproduces itself as a link--and taking the lock code out of it doesn't help???  
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by David T. Cannon -

Well, I downloaded same version you have, and still same problem. And label resource are still broken. very strange. I am taking a break until tomorrow smile

Dave.

In reply to David T. Cannon

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
It would appear you are having similar problems to Bernard above.
Unfortunately, at the moment I've no idea what's causing it.
It would seem that the lock.php page isn't being created properly and hence not sending a complete form.
All I can guess is that it is a difference in platform (linux, php, apache) rather than Moodle version.
I am developing the hack on Win2000, IIS, php 4.3.10, MySQL 4.0.21

One thing you could do for me is try to lock an activity, then get a copy of the page source that is created by lock.php. Either post it on here or email me with it.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Bernard Boucher -
Hi Stuart,
              sorry for the delayshy ( Greece Island cruisecool ).

I just reinstall all with 1.5.1+ ( 2005060210 ) and the same problemsad.

But I tested it with an old Easyphp instead of an new Xampp and it works fine first timebig grin.
Both Win2k

EasyPhpbig grin:
php 4.2.0
mysql 3.23.39
apache 1.3.24


Xamppangry
php 5.0.2
mysql 3.23.57
apache 2.0.52

I hope it may help.

Thanks,

Bernard

In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by David T. Cannon -

Hi Stuart!

Well, this function is pretty essential for my use, so I am persuing it. Attached is a copy of the lock.php file you requested. From Bernards post, looks like its the php5.

$passmarks = object(stdClass)#165 (5) { [1]=> string(1) "A" [7]=> string(1) "0" ["delayday"]=> string(1) "0" ["delayhour"]=> string(1) "0" ["delaymin"]=> string(1) "0" } ....with first item checked.

My first guess is the staement "if (is_numeric($predecessor)) {" is always failing.

Also, did you notice trouble when you create a Label resource from your mod?

Dave.

In reply to David T. Cannon

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
David,

Thanks for your help on this.
Looking at the source code you posted, I can't see anything wrong. That html should be posting all the activity locks fine.
As you say, php5 could be one reason it's not worknig properly. It may also be apache2. I suppose it's equally likely to be either. Apache will be handling the POST data and php does all the jiggery-pokery once it's got the POST data.
I'd probably put my money on php too. I think I'll have to install combinations of both of them to see what I can find out. Unfortunately that's going to be a reasonably slow process. I'll install VMWare with various apache/php combinations tomorrow and see what I can figure out.

As too the label problem...
Not I hadn't had a problem, but then I hadn't looked. tongueout It would appear that there is, indeed a problem with labels once locks have been applied. Label is a special case of activity that I simply hadn't looked at. I'll take a look at that too.
In reply to David T. Cannon

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Aha!

I've just noticed your edited post.

My first guess is the staement "if (is_numeric($predecessor)) {" is always failing.

I'd say that's a very good guess. It would also point to php being the culprit.
I'm looking into it now.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Bernard Boucher -
Hi Stuart,
               like I notice before  for php5 only the 3 delay parameters seem to be passed in that line $passmarks = data_submitted(); that is why is_numeric fail. With php4 it is ok.
data_submitted wich use $_POST seem to create the problem with php5.

I have checked some php forums about differences beetwen php4 et php5 but nothing found yet!

Maybe later,

Bye,

Bernard



In reply to Bernard Boucher

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Bernard/David (and anyone else),

Could you please try using the attached course/lock.php file. Hopefully this will fix the problem.

This also should fix a problem with modules that don't have grading set.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Bernard Boucher -
Hi Stuart,
new lock.php don't fix itsad.

But, if you replace in line 53 of lock.php $passmarks with $_POST then that workssmile with php5 but it bypass data_submitted validation.

        foreach ($_POST as $predecessor => $passmark ) {


I don't know why but the return of data_submitted strip some values when used with php5. Maybe a php Kingmixed will know the difference beetwen php4 and php5 in returning objets and the appropriate "type casting" to add to make it more general.

I hope it may help.

Thanks,

Bernard


In reply to Bernard Boucher

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
That's very odd Bernard. As far as I can see, I'm using the data_submitted function in exactly the same way as it appears in (lots of) other places throughout Moodle.

It must have something to do with the way the php "foreach" construct works in the different versions. You see, $_POST is an array, whereas the return for data_submitted() is an object. PHP5 must handle objects differently in foreach constructs. Or at least that's my guess.

For the moment, though, I'll replace data_submitted with $_POST just to get it working. Hopefully some explanation will come up.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Bernard Boucher -
Hi Stuart,
              your usage of data_submitted is not the problem I think.
with

if(isset($_POST)) {

foreach($_POST as $key=>$val) {
 echo $key.'=>'.$val.'<p>';
 }
}

in  data_submitted and in lock.php I get all the values anticipated.

But if I use $passmarks instead of $_POST in lock.php then only the 3 delays parameters are presents. The return of data_submitted seem to strip the others values.

Probably others problems will be detected in others area of Moodle when more people will use php5 due to that problem with data_submitted. If we don't find a solution in few days then I will fill an official bug!

Bye,

Bernard

In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by David T. Cannon -

Gosh, The one morning I sleep in, there's alot of action going on smile

It appears to me, that the difference in the way you are using this call is:

You have an associative array, with both numbers and text as keys. Only the

text keys are being passed through the foreach loop. Now, Why this is.....is beyond me.
Dave.

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Bernard,

I wonder if you could do a quick experiment for me.

On around line 39 of lock.php, replace
$passmarks = data_submitted();
with
$passmarks = get_object_vars(data_submitted());

and see if that makes any difference at all...
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Bernard Boucher -
Hi Stuart,
              sorry that generate 3 new notices:
Notice: Trying to get property of non-object in H:\xampplite\htdocs\moodle\course\lock.php on line 41

Bye,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Grrr.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by David T. Cannon -

After much researching, I think this is the solution. Although, Stuart please test it out. I have so many hacks in now, I'm not sure how many changes I've made.

Use: while(list($predecessor, $passmark) = each($passmarks)){

in place of: foreach ($passmarks as $predecessor => $passmark ) {

Also, make sure the line: if (is_numeric($predecessor)) {

is still in there. Now did we fix the label problem?

Dave. (gosh its hard when you all are sleeping when Im awake smile )

PS. my lock file attached.

In reply to David T. Cannon

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Bernard Boucher -
Hi David,
that works fine herebig grin

The one morning you sleep in, help to clarify the ideaswide eyes

You are the php King that I waited forwink

For the label in moodle/course/lib.php around line 1820 you have all the editing buttons. An if based on mod->modname == 'label' before the return assigning the html code to a variable if the condition is false should do the job of not showing the lock icons for labels.

if ($mod->modname == "label") { //bb
$lockhtml='';
}else{
$lockhtml='<a title="'.$str->lock.'" href="'.$path.'/lock.php?id='.$mod->id.
'&amp;sesskey='.$sesskey.$section.'"><img'.
' src="'.$CFG->pixpath.'/t/lock.gif" hspace="2" height="11" width="11" border="0" '.
' alt="'.$str->lock.'" /></a>';
}


return '<span class="commands">'.$leftright.$move.
'<a title="'.$str->update.'" href="'.$path.'/mod.php?update='.$mod->id.
'&amp;sesskey='.$sesskey.$section.'"><img'.
' src="'.$CFG->pixpath.'/t/edit.gif" hspace="2" height="11" width="11" border="0" '.
' alt="'.$str->update.'" /></a>'.

$lockhtml.

'<a title="'.$str->delete.'" href="'.$path.'/mod.php?delete='.$mod->id.
'&amp;sesskey='.$sesskey.$section.'"><img'.
' src="'.$CFG->pixpath.'/t/delete.gif" hspace="2" height="11" width="11" border="0" '.
' alt="'.$str->delete.'" /></a>'.$hideshow.$groupmode.'</span>';
}

As a php kingwink you will probably find something cleaner or shorter.

Thanks,

Bernard

In reply to Bernard Boucher

Re: Conditional activities: Activity Locking for Moodle 1.5+

by David T. Cannon -

Well, php King may be a bit much. I am just getting into php again after having taking a few years off.

For the label; My lines look nothing like what you have above. I am pretty sure the problem is around line 1064 of coure/lib.php. There it is echo-ing a string, but I think one of the variables is causing an error. I am sure its the $extra string. I think it needs to have html stipped or something.

Dave.

Is Stuart awake yet?

In reply to David T. Cannon

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Thanks for the help guys.

I've implement the changes to the locking code that you suggested, and it still works on my system. Hopefully, then, we've got it nailled.

I've also made a couple of other changes. That locking code has been moved into the locklib.php library, as it is used in the sectionlock.php page too.

I've also fixed the label problem.

I think I'll zip it all up and post it as a new release. I've also got CVS access now, so I'l put it there too.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Alvin Shaffer -

Stuart,

First off let me thank you for your hack. I have used Bernards hack for ~ 1 yr now and I am ready to upgrade to 1.5 and I am excited about this feature. Can you release a fully package hack for 1.5.1 (or 1.5.2 soon to be released) with all the latest code. (just for easier deployment)

Thanks

Alvin

In reply to Alvin Shaffer

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Stuart Mayor -
Yes, I'll be releasing a new version soon.

There are a couple of issues that have arisen that I want to take care of before the next release.
In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Jens Gammelgaard -
Picture of Translators

Hi Stuart!

Great work, I see that the Moodle 1.52 is on the way within a few days, I will test AL then and return with my experience.

Have a nice weekend!

KR
Jens

In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Dale Chappell -

It appears as though the only time that the activity locking works is when I am logged in as an administrator. Regular students have full access to the sequential topics without any regard to the completion of the prerequisites.

Any idea why this occurs?

Thanks for any input,

Dale

In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by James Robertson -

Hi Stuart,

I've been following this thread for some time, but only downloaded & set it up today.  From a couple hours of testing I have to say that this is really wonderful big grin!  I hope it makes it into standard Moodle.  I really like the checkboxes in front of each activity, it's very intuitive and helps the students track their progress (this has been something of a problem).  From what I've seen, I presume the problems with checkboxes in front have been solved.

I added the standard 2 lines of code (and the start/end comments) to view.php in Questionnaire.  Anything else I need to do? It seems to work both as a locked activity and a prerequisite for another activity.  I am not required to complete the Questionnaire, just view it, but I believe that is the case for all non-graded activities.

A few questions/comments:

1. When a resourse is opened in a new window, there is still nothing to refresh the course menu, so the student doesn't see any change (already noted above, I agree it's not a biggie).

2. What does locking a label do?  I had expected it to render the label invisible (or at least grey), but it seems to have no effect at all.

3. There are three locking display choices, but is there a way to turn off locking course-wide -- ideally it would retain the locking data for use again when locking is turned back on for the course.

4. I had expected the Locking block to turn locking on & off (enable/disable) for the course, but apparently not.  I can't tell what it does other than give a count of activities with locking capability.  Does it have other functionality?

5. Setup was somewhat awkward, since I had to check each file to ensure it was more recent than my Aug 10 release files.  I ended up merging 3 files (view.php for forum and lesson, and attempt.php for quiz).  Any plans for another release soon?

6. This looks awfully good -- what is the consensus about stability at this point: is the July 19 (?) version good enough for a production site?  Not asking for guarantees here (there's always a risk), just wonder what the general feeling is.

For the record, I am using 1.5.2+ v2005060222, with add-ons including Questionnaire, Quiz Detailed Responses & Essay Question, Marking block, Course Menu block, Course Section block, Date Manager block, and the LinuxBox Gradbook enhancement (these are on a localhost test, a subset is on our production site).

Thanks,

Jim.

In reply to James Robertson

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Ger Tielemans -

What is the latest version? Acivity locking works for me in 1.5.2+

But how can I unlock again? sad  (Am I missing some buttons?)

I used an activity with a score and tried to overrule it with another lock - but then with a checkmark, to uncheck it later - ending up with two locks: it now looks like a Dutch bike (nice, but..)

Attachment vb2.png
In reply to Ger Tielemans

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Ger Tielemans -

Using a box and a checkmarked box for lock and unlock is disturbing: why not  just use an open and a closed lock to echo an open and close lock?  

In reply to Ger Tielemans

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
Because you can also use this code for "progress checking".  Which I think is really nice--for activities that aren't locked you still get a check showing they've been viewed.  Ger, just change your icons to the locks if you want.

Did you figure out how to get rid of the bicycle?
In reply to Chardelle Busch

Re: Activity Locking for Moodle 1.5+ Unlocking?

by Jens Gammelgaard -
Picture of Translators
In Denmark we bicycle about as often as in the Netherlands, but I have not found the unlock either.

So is the unlock button /feature there or we have to delete the locked activity and establish it again?
In reply to Jens Gammelgaard

Re: Activity Locking for Moodle 1.5+ Unlocking?

by James Robertson -
I bicycle a lot too, but I still get only one box with my activity locking.  How are you getting the second box?
In reply to James Robertson

Re: Activity Locking for Moodle 1.5+ Unlocking?

by Audun Hauge -
If you choose  Show activity locking: After each locked activity
and  set up two dependencies (one activity locked by two others),
then you'll get two boxes.
Each box will have a mouseover showing the name of the required activity.
With checkmarks in front, you only get the one checkmark.
In reply to Audun Hauge

Re: Activity Locking for Moodle 1.5+ Unlocking?

by James Robertson -

I see -- I have been using the "Before" option. 

A few minutes later after a quick try with the "After" option:  when I added two more conditions to an activity (3 total), I got 3 boxes as you described.  But when I removed the two added conditions, it reverted to one box again.  Removing the original condition brought it back to no boxes.

So what is different?  I don't know -- I am using an Aug 9 version of 1.5.2 v2005060222, so I wonder if there is a problem with later versions?  Or did I leave out something?

Jim.

In reply to Ger Tielemans

Re: Conditional activities: Activity Locking for Moodle 1.5+

by James Robertson -

I'm not sure how you got the two boxes.  I don't think I can get two boxes even if I try.  When I edit the lock, it just brings up the locking page for the activity and I change it and exit.  The change is reflected in the student view as expected.  I was trying to test a scenario similar to what you showed and it seems to work.  So we are apparently doing something different, but I don't know what.

Incidentally, anyone know what the activity locking block is for? Just a report on number and format of locks?

Jim.

In reply to James Robertson

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Chardelle Busch -
Picture of Core developers
Ger et Ari,

Just a thought--could having the locking come AFTER the activity instead of BEFORE possibly be the culprit? I have never tested it after, only before--which seems to work just fine. Maybe try changing it to before and see what happens?

James,

Stuart created a block as an easy way to create the data tables--so you can just ignore it after you have it installed--as a matter of fact, I just looked at it and it seems to add 6 locks to the number of activities in a course--so I don't think the info is meant to be helpful.
In reply to Chardelle Busch

Vast: Re: Activity Locking for Moodle 1.5+

by Ari Ranta -
Hi Chardelle
Good thought! Before activity is the right place. I had it after.
Thanks again for your help.
Ari
In reply to Ari Ranta

Re: Vast: Re: Activity Locking for Moodle 1.5+

by Alison Wright -

Sorry to butt in on the discussion.

I'm really interested in obtaining this module.  Where can I download the latest documents?

TIA

Ali

In reply to Alison Wright

Re: Vast: Re: Activity Locking for Moodle 1.5+

by James Robertson -

Here:

http://download.moodle.org/download.php/modules/activity_locking.zip

Anyone: Did the extra line of code:

require_once($CFG->libdir.'/locklib.php');

ever get added to CVS?

In reply to James Robertson

Re: Vast: Re: Activity Locking for Moodle 1.5+

by Rashan Anushka -
Hey,
This is greate. So far all works except the Icon for 'Lock' is not displayed, although i extract it in the right place (../moodle/pix/t). So what can be the problem?
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking for Moodle 1.5+

by James Robertson -

Thanks, I'd wondered if the block might just be an initial setup device -- apparently so.

I have one course with check boxes after, for testing.  I haven't seen the problem described, though box-after is a little counter-intuitive: the student sees the green check meaning it's OK to do the activity, but it intuitively looks like the activity has been "checked off."  Ideally, I suppose, a check box would come before (all activities) and a lock/unlock symbol after (activities with locks defined).  But the greyed-out display accomplishes the latter well enough, without adding another symbol.

I am considering putting this on our production site, I really like the check boxes for activity tracking (locking is also appreciated).  Any feeling on how risky that is?  I haven't seen any problem on localhost. 

In reply to Ger Tielemans

Vast: Re: Activity Locking for Moodle 1.5+

by Ari Ranta -
Hi Ger,
did you get this fixed? I have same problem. I have not found a way to unlock. I'm testing 1.5.2+ for upgrading.
Ari

In reply to James Robertson

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Sinead Gibney -

Hi Stuart,

I just wanted to give some feedback on this module. The college I work in runs self-paced home study course. It has been a traditional correspondence college for seventy years now and is just breaking into online education.

Besides developing courses specifically for the online medium, we were hoping to offer an online system to our existing students that replicates the traditional one. This depended hugely on the conditional release of material. Which your module, Stuart, allows us to do. approve

The installation went very smoothly, and it has worked beautifully in a mock-up course that I have. As I play around with it, Ill come back with any ideas but for now just had one recommendation:

The criteria for release of a resource based on an assignment activity is a grade. Would you consider also making it a criteria that the students simply has to submit the assignment? This means that they can continue working and not have to wait for the tutor to grade them.

And other than that, I was just wondering, like James, when it will be stable enough for production sites? Im also running 1.5.2.

Thanks for all the hard work,
Sinéad

In reply to Stuart Mayor

Re: Conditional activities: Activity Locking for Moodle 1.5+

by Jamie Smith -

I'm just starting to test and develop my own Moodle site. We build our content in SCORM packages. So, I use almost exclusively SCORM activities.

I noticed one slight flaw. If the SCORM is clicked on, you are taken to the "view.php" page where access and status regarding that SCO is given. If you have not yet established a status (niether complete or incomplete) and exit back to course view without viewing the SCO, the box is checked. However, since the prerequisite for the next activity has not been met, it is still locked. Once the SCO is viewed and establishes an incomplete status, the box will be empty again reflecting the activity is not yet complete.

This is not a problem in functionality, but presentation and can be a bit confusing to the student.

Other than that, I've tested it quite a bit with SCO completion and SCO quiz scores as prerequists. I also use it to require the students visit the course news forum prior to beginning the course.

Thanks for the good work.