Conditional activities: Activity Locking course format update

Conditional activities: Activity Locking course format update

by Chardelle Busch -
Number of replies: 41
Picture of Core developers
I thought I would start a new discussion since the old one is getting to be too long.

Here is an updated zip of the locking course format that should work with 1.9.9. I have also updated the db files so that uploading the mysql file is no longer necessary, and it will work with all databases. Please READ the instructions first before doing anything.

Thanks to you Chris for helping keep this up to date and prompting me to get it updated!
Average of ratings: Useful (2)
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Art Lader -

Hi,

Just FYI: I have tried this on several fresh installs of 1.9.9tonight, and I am having this problem again -- http://moodle.org/mod/forum/discuss.php?d=128318#p562816. Moodle cannot seem to find the style sheet and locks me out of the site.

The problem comes when I patch moodlelib.php. When I go back to the original moodlelib.php, all is well again.

Maybe that will help someone.

Regards,
Art

 

In reply to Art Lader

Re: Conditional activities: Activity Locking course format update

by Chardelle Busch -
Picture of Core developers

Just make sure you don't add any extra spaces or line breaks when you paste in the code in moodlelib.php.  Also, pasting from certain word programs can sometimes add funny things to code.  If all else fails, type the added lines into moodlelib.php in an html editor rather than cut and paste.

Also, keep in mind that if you do not need to show any icons to your users (e.g. you don't show progress tracking and you hide your activities until available) you do NOT need the code that is added to moodlelib.php.

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Art Lader -

HI, Chardelle.

I checked for extra spaces and used a decent text editor, but I did copy/paste each time. I will type the code in by hand and get back to you tonight.

Thank you for all of your work on this. You're the best.

- Art

In reply to Art Lader

Re: Conditional activities: Activity Locking course format update

by yuki yuki -

did u get it to work with moodle 1.9.9?

In reply to yuki yuki

Re: Conditional activities: Activity Locking course format update

by Art Lader -

Hi,

I decided not to fiddle with the lib file and it's working. smile

Something keeps logging me out of the site, but it is probably unrelated.

- Art

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Larry Lippke -

What data does the Time Delay Lock use in calculating whether sufficient time has passed?  Is it simply the current time compared to the log file entry time for when the user enrolled in the course? How, if at all, does this relate to the time requirement available in the certificate module?

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

My host installed AL_format_1.9.9 per the instructions contained within the zip file, but I cannot get it to work. I am using Moodle 1.9.9+, but the padlock shows up only transiently or when I hit reload, so I have to be quick to click on the correct padlock. I then get a list of all my many course elements with checkboxes, and mark the element in question to show that the user is required to access it, mark display as Yes, and Yes for show activity prereqs, and Save Activity Locks, and nothing changes. In the course it says there are 0 locks for this course!

If I disable AJAX, the padlock shows up permanently when in edit mode, but locking still does not work.

Nothing is like the video in Moodle Blog http://www.moodleblog.org/?p=110, so what am I doing wrong?  Are there better instructions for the version I am using?

In reply to Deb Smith

Re: Conditional activities: Activity Locking course format update

by Chardelle Busch -
Picture of Core developers

Most likely the extra fields did not get added to the course_modules table.  Since moodle will not install a plugin AND add fields to another table at the same time, you must basically install the block first, then upgrade the block (which will install the extra db fields) by increasing the version number.

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

When I click notifications, I get the error message:

Version mismatch: block activity_locking can't downgrade 20010090400 -> 2001009041!

This is the first time I had installed AL, so I edited the line in the block_activity_locking.php file as stated in the readme.txt file, but I still can't get it to work.  I assume this is the step that you mean by upgrading the block?

In reply to Deb Smith

Re: Conditional activities: Activity Locking course format update

by Chardelle Busch -
Picture of Core developers

Yes, that is corect, however, if you notice, you are missing a number in your new version.  There needs to be 11 numbers, try changing 2001009041 to 20010090401

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Bernard Boucher -

Bonjour Chardelle,

I am not totally sure because I did'nt installed it, but I think that there is a small typo error in the lastest version of :

AL format 1.9.9\blocks\activity_locking\block_activity_locking.php

there is :    $this->version = 20010090400;

should be;  $this->version = 2010090400;

last year version was :

$this->version = 2009070400;

 

I hope it may help,

Salutations from Québec,

 

Bernard

 

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

I corrected the typo, and pasted the info into moodlelib.php which it appears my host failed to do, but I am still getting an error message when I hit notifications that says:  Version mismatch: block course_summary can't downgrade 2007101510 -> 2007101509!

I am using 1.9.9 and still get 0 locks in the course when I try to lock certain items.  What am I doing wrong now?

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Brian Williams -

I am wanting to use activity locking with the 1.9.10 version of the core. I have read that a few people have had success with this, but I have not been able to do so. My site was using moodle 1.9 when activity locking was working. I tried to upgrade and didn't have any luck. I wasn't sure I did things correctly, so i just intalled a fresh copy of Moodle locally and followed the direction in the activity locking 1.9.9 readme. I created a new course with some dummy information. Then I installed activity locking and everything said it was ok. I bumped the version up to 20010090401 and went to the notifications page again. This time it added the extra fields and again said everything was good. I then copied over the locking folder to the courses/format/ folder. I do not get the activity locking icons for activities that I have had in the past. As far as I can tell its not working. If i visted the notifications page again, it says that the course/foramt/locking needs updating and that everything has been upgraded and is working correctly, but still no icons. I have 2 courses that used Activity locking pretty heavily and are now not functioning correctly with the new version of the core. Any help would be much appreciated. You can email me directly at brian@djcase.com if you have suggestions.  Thanks.

In reply to Brian Williams

Re: Conditional activities: Activity Locking course format update

by Brian Williams -

I was going to delete my previous post but maybe my mistake will help somebody else as well. I didn't see the other thread on this topic that starts out with the intsructions on installing. I was using the readme file for that explanation, however, my problem was that the activity locking feature changed a bit from the old version i was using. I failed to see the part about changing the course format to 'activity locking' so it actually was working the whole time, both on my regular site and on my local install.

In reply to Brian Williams

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

Which previous thread had instructions for installing?  Can you include the link for it?   I too was following the readme.txt file and the instructions didn't work as they should.  So if there are other instructions out there that do work, let me know please!  I have a course going on at present that needs this tool, but I could not get it to work.  FYI, I am not upgrading from a previous version, just trying to install for the first time on 1.9.10, so I don't know if that makes this irrelevant or not.  I'd be willing to uninstall and install an old version if that would help!

In reply to Brian Williams

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

Brian, Try turning off Ajax and see if the locks show up.  I got that far, but was never able to lock items within the course, in either 1.9.9 and 1.9.10 and I followed the instructions precisely.  I hope you can get it to work, and if so, maybe you have some clue as to why I am getting the error message I mentioned in a previous post.

In reply to Deb Smith

Re: Conditional activities: Activity Locking course format update

by Brian Williams -

Deb,
The previous thread i was talking about is at http://moodle.org/mod/forum/discuss.php?d=128318#p562002  The very first post by Chardelle contains similar information to the readme file, but it also mentions at the end that you need to go to the course and change the format to "activity locking." That was the key step that i was missing. Once i had done that, all my prevoius activity locks from the older version were still in tact and worked fine. I was just confused as to why i was not getting the lock icons right away. You are getting the lock icons but the locks are not actually working?

In reply to Brian Williams

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

Thanks, Brian, I'll give that a try.  Yes, I had changed the format within the course to Activity Locking in the Settings file, but it still wasn't working.  Until I disabled Ajax, the padlocks weren't showing up at all.  But, I keep getting error messages when I hit notifications, and I think it has something to do with the instructions giving the wrong info for the version number, but no one has replied to my posts about that.  In the 1.9.9 readme file it says:

Open the blocks/activity_locking/block_activity_locking.php file and “bump up” the version number by changing:
$this->version = 2001009040;
to
$this->version = 2001009041;

I think it should be 2010 instead of 2001 but I am at a loss what these numbers stand for, so I really don't want to mess things up by just playing with them.  I added the digit as instructed by Chardelle to make sure I had 11 digits, but it still didn't work.  If you are using version 1.9.10+, can you copy and paste what you have in that line of the block_activity_locking.php file that allows it to work?  Maybe that is all I need.

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Todd Thornton -

To get the benefits of additional security fixes in the Moodle code, what would be the steps to get this AL version to work with 1.9.10? In the instructions there's instructions on changing the version number by bumping it up 1, but that's for 1.9.9 and I'm not sure how/where that would appear/need to be changed in the code. I'm using the older version of the AL code currently on 1.9.3 so I'm not sure what needs to be changed.

Thanks,

Todd

In reply to Todd Thornton

Re: Conditional activities: Activity Locking course format update

by Chardelle Busch -
Picture of Core developers

Hi Todd,

If you already have it installed, just copy over the new format files and your fine.

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by brian avery -

Chardelle,

I have added this to my 1.9.10 moodle for the first time and it seems to work like a dream. There are some odd moments when moodle seems to ignore locks, but I figure that has largely been my fault until now. It does what it says on the tin, nothing has blown up or tried to delete my files, so I'm delighted with it!

However...

I have a question. I plan, as I'm sure other people do, to upgrade to 2.0 whenever I stop seeing the 'kill zone' warnings. When I do that, I'm hoping that it will be a simple matter of backing up a course and restoring it to 2.0 (yes, I'll read the manual when the time comes and I'll bet my next 5 babies that it won't be so simple). My question is; will course activity locking work in 2.0 or not? I'm guessing that the answer is no. If not, do I have to manually remove the locks from the course prior to backing it up and transferring it? I'm just debating what to do. I don't really want to create a full course now (on a currently non-production site) and then face hours undoing locks before I upgrade, but want to retain the same facilities that I have now.

Sorry if my question isn't clear or is dumb, but can you offer a few words of advice?

Many thanks.

Brian

In reply to brian avery

Re: Conditional activities: Activity Locking course format update

by Chardelle Busch -
Picture of Core developers

Hi Brian,

2.0 has conditional activities in the core, so I assume most people will want to use it instead of this code.  However, if there is a need, I could update it to 2.0.

There will be no need to "unlock" the current activities, simply delete the course_modules_locks db table.   You can also delete the "visiblewhenlocked" and "checkboxesforprereqs"  fields from the course_modules table. (Of course, always backup your db first.)

Unfortunately, you will have to reset every lock--in 2.0 this is done in the activity settings.

Average of ratings: Useful (1)
In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by brian avery -

Thank you Chardelle. I've seen mention of the conditionals in 2.0 and in fact I read them again tonight, but I already know ACL does the trick for me but not if I'll like 2.0's version as nicely fitting. However, I'll try it first and see. I was just wary of creating extra work for myself (creating a course and then upgrading moodle) and wondered if there was an easier transition with a plug-in I already like.

Thanks anyway!

Brian

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Silvana Costa -

Hello, Chardelle.

Thanks for your job here!

I installed the AL course (1.9.9 version) and it works well, but I've been a problem about the student access. When I logged as a student, I couldn't go to the second lesson. I did all the lesson, but the padlock is still locked. The message is "This activity is currently locked. You must complete the following prerequisites first:" ... and nothing!

Everything I know about moodle I learned doing... so, I'll appreaciate your help to solve this issue.

My e-mail is silsame@yahoo.com.br

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Rhonda Goetz -

Where do I find the certificate in 2.0?  I am unable to find instructions for working with the Activity Locking and Certificate in 2.0.

 

Rhonda

In reply to brian avery

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

I tried the reworked AL_Format_1.9.9.zip that Chardelle posted here (http://moodle.org/mod/forum/discuss.php?d=159160), but there were some errors in the code.  I have a course starting the beginning of December and I need this module to work for me, but like you I am not willing to install 2.0 until the bugs are fully worked out and it is stable.  Clearly that won't happen within a week.

I made the change in the block_activity_locking.php file that Chardelle mentioned, although I think her change was also incorrect in that it should have been 2010, not 2001.  That installed two database tables, but I still got an error message and no locks in the course.   I upgraded to version 1.9.10 as that has solved the problem for some, but still no locks in the course.

PLEASE!  Any help from anyone?  I am not on Skype, so if you can email me that would be great.

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by John Anderson -

I got it working with a fresh install of 1.9.10, thank you a bunch Chardelle. The version number hiccup got me for a second, but the answers were here in the thread.

In reply to John Anderson

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

Exactly WHICH thread has the answers?  I have asked repeatedly and have not yet found the answer I need.  Specifically, I need to know exactly what version number should go in the following for a first time install with 1.9.10:

class block_activity_locking extends block_base {
function init() {
$this->title = get_string('activitylocking', 'format_locking');
$this->version = 20010090400;
}

As it is written, that version number doesn't work.  Neither did the correction that Chardelle mentioned.  A little help here would be much appreciated!

In reply to Deb Smith

Re: Conditional activities: Activity Locking course format update

by John Anderson -

Ok I will try to elaborate some, but I was starting from a fresh moodle install:

1. In this new package there is a readme.txt file that incorrectly states the version dates:

Open the blocks/activity_locking/block_activity_locking.php file and “bump up” the version number by changing:

$this->version = 2001009040;
to
$this->version = 2001009041;

2. So if you try to complete this task by say, copy and paste, it will fail. It will fail because:

$this->version = 2001009041;

is missing a zero at the tail end. It should be:

$this->version = 20010090410;   - 11 digits did it for me.

Then re-running your moodle/admin page picks up the date change and does the 2nd half of the install, again, I was installing AL module on a new site.

In reply to John Anderson

Re: Conditional activities: Activity Locking course format update

by Deb Smith -

I am making progress, but it still isn't working.   Changing it to 20010090410 generated an error message and no tables, so I tried 20100090410 and that at least generated a course_modules table in the database, but I still get an error message regarding a version mismatch. I get zero locks when I test locking within the course.

 

This is a new install, but maybe what I need to do is remove all the new install files, and try to install again from scratch following your directions.  Sigh, this is giving me a headache.  I hope I don't have to wait until Moodle 2.0 has all the bugs worked out, but I am getting a sick feeling that that is exactly what I will have to do.

 

Thanks!  If you have any further suggestions please pass them on.  The screen showing the errors I am getting is attached here.

Attachment error.gif
In reply to Deb Smith

Re: Conditional activities: Activity Locking course format update

by Chardelle Busch -
Picture of Core developers

The warning message you show is for your course summay block, not the activity locking block.

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by Judy Hsu -

Does the AL_format_1.9.9.zip file work with Moodle 1.9.10 and 1.9.11?? Thanks!

In reply to Judy Hsu

Re: Conditional activities: Activity Locking course format update

by Angela Carswell -

Yes it does with a few modifications:

I received these helpful instructions for Roel....


I used the Activity Locking course format above 1.9.9.1 and followed the
included instruction for a fresh install. I have tested/installed it after
a moodle installation and also before the moodle installation i.e. the
tables were installed along with all new tables. For any one using this I
suggests testing it first on a test server with a new moodle installation
and turning on debug - php error reporting to trace problems.



I quote the instructions provided by Chardelle below:

1. Put the blocks/activity_locking folder under your moodle/blocks folder.

2. Put the course/format/locking folder under your moodle/course/format
folder.

3. To set activities to visible and provide warnings about prerequisites
I altered moodlelib.php file:

3.1 backup your moodle/lib/moodlelib.php e.g. copy it and rename new file
moodlelib.php.orig

3.2 open your moodle/lib/moodlelib.php file with a text editor (gedit,
notepad; warning: in my experience sometimes when you edit a file in
windows and your server is in unix or vice versa the file is messed up
because of line endings and other hidden characters).

under the function_require_login find the following code:
/// If the site is currently under maintenance, then print a message

if (!has_capability('moodle/site:config', $sysctx)) {if
(file_exists($CFG->dataroot.'/'.SITEID.'/maintenance.html'))
{print_maintenance_message();exit;}}

3.3 paste in the following code BELOW the above code:
//Check to see if Activity Locking criteria have been
metrequire_once($CFG->dirroot.'/course/format/locking/locklib.php');global
$cm;check_locks($cm);

I'm running things on an Ubuntu Lucid Lynx amd 64 server so I usually
change the owner of the AL files by issuing the commands:

chown -R www-data.www-data *

If the AL course format is installed after an moodle install, hit
notifications to update the database tables.

Hope this helps,

Roel

In reply to Angela Carswell

Re: Conditional activities: Activity Locking course format update

by Tieku Bortei-Doku -

Who can help me figure out why Activity Locking course format does not work with this Completion Tracking Hack which only modifies course/lib.php.
http://tracker.moodle.org/browse/CONTRIB-1787
http://moodle.org/mod/forum/discuss.php?d=130675&parent=575949
It would be great to have the 2 working together for me. It works with Topics course format but not Activity Locking course format.

In reply to Chardelle Busch

Re: Activity Locking course format adding to TopicCollapse

by Gordon Brooks -

Hi Chardelle,

Thank you for your efforts on this.  How difficult would it be to create this AL using the Topics Collapse format?  I assumeit is not as simple as moving your files into my TC folder.  If you could give me a general direction or some steps to get started I can give it try.

Thanks,
Gordon

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by DeWayne Demland -

I think I have found a bug. I have both a hosted moodle and a local test moodle. I have installed the activity lock on both machines, and they are both acting the same way. Attached is a screen shot of what I have. Number 1 is the first event to be accomplished. After it is accomplished the green check mark occurs in the box. Number 2 is then done. When it is completed you see the check in the boxes for quiz 2 and 3, but it cannot be accessed for quiz 1 which is what should follow. Quiz 1is not allowed to be accessed. Each event is dependent on the one directly above it only. is there a bug here? My hosted moodle is 1.9.5 and my test server is 1.9.11. I have the correct files installed on both machines, according to the documentation.

I have been working 2 years to get a license to be able to start this program up. The board would like to have access to see how this works. I do not have a lot of time to get this working. Can anyone help me?

Attachment Lock.jpg
In reply to DeWayne Demland

Re: Conditional activities: Activity Locking course format update

by Roel Cantada -

Hi DeWayne,

Please share the screenshots of your Quiz 1 moodle settings and its lock condition settings so I can try to replicate the problem.

Roel

 

In reply to Roel Cantada

Re: Conditional activities: Activity Locking course format update

by DeWayne Demland -

Go to this link to see the the quiz settings:

http://automotivepartstraining.com/ap100_%20editing_quiz.pdf

And look at this one for the lock setttings:

http://automotivepartstraining.com/ap100_locks.pdf

In reply to DeWayne Demland

Re: Conditional activities: Activity Locking course format update

by DeWayne Demland -

I am not sure if you can duplicate this situation. I have done extensive research and have come up with the following information. I have three other courses set up the exact same way. All the setting in the course and all modules are the same. This three courses work like they are suppose to. Only this one course does not function like it should. Does any one have any ideas as to why this is happening and how to correct it?

Let me also note that if I import any course into a new course it acts the same way as in the situation above.

This is driving me nuts.

In reply to Chardelle Busch

Re: Conditional activities: Activity Locking course format update

by John Brady -

Hi Chardelle

We
installed Activity Locking on Moodle 1.9.13+ (Build: 20110803).
MSSQL 2008
Windows Server 2003 R2 Standard Edition Service Pack 2, i586

It works.  smile 

Thank you for all your development and support time on Activity Locking.