This is mainly a bugfix release. It's been a while since the last release, and I'm not sure if there are any new features.
As always, any and all coments are welcome and remember - USE AT YOUR OWN RISK
By the way, this is now also available via CVS in the contrib folder.
Ah. I appear to have exceeded the 100kb limit for the zip file. I'll post it in two posts here, but in the future this may have to go CVS only
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Hmm, I didn't see it in CVS. named activity.... right?
Dave.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
If however, you use a CVS client and try to check out contrib/activity_locking it works fine.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Well, I tried both a client and through the web. I'll just wait until later in the day and see if it shows up.
Dave.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
It might be my first journey into CVS use hasn't been altogether successful.
We'll see.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Re: Conditional activities: Activity Locking for Moodle 1.5.1
first thanks.
The pcakage should be updated and zipped automatically every 24 hours to ( will start tomorrow only ) :
http://download.moodle.org/download.php/modules/activity_locking.zip
Bye,
Bernard
Re: Conditional activities: Activity Locking for Moodle 1.5.1
The activity locking is working great for me. One question.
I use evaluation forms (using the new feedback module by Andreas). The student has to submit these evaluations before they can complete their course. When I look at the feedback forms though in activity locking, it just says the student has to access the feedback. However, I would like them to have to submit it rather than just open the page.
There are two tables - feedback and feedback_completed. How can I make the activity locking look in feedback_completed rather than just feedback?
Nikki
Re: Conditional activities: Activity Locking for Moodle 1.5.1
I'll have a look at the feedback module and see if I can "fix" it for you...
Re: Conditional activities: Activity Locking for Moodle 1.5.1
I think I have figured out how to do what you want with the feedback module. Unfortunately, I can't check if it works as I can't get the feedback module to work at all on my system.
Getting it to do what you want involves 2 steps:
- Firstly, you need to add a field to the feedback_completed table.
ALTER TABLE `mdl_feedback_completed` ADD `completed` TINYINT UNSIGNED DEFAULT '1' NOT NULL AFTER `userid` ;
Basically, all you need to add is a fielde called "completed" which has a default value of 1 - Next you need to edit the file mod/feedback/lib.php
Go down to line 121. You should be at a function called "feedback_grades". You need to edit that function so that it is as follows
function feedback_grades($feedbackid) {
/// Must return an array of grades for a given instance of this module,
/// indexed by user. It also returns a maximum allowed grade.
///
/// $return->grades = array of grades;
/// $return->maxgrade = maximum allowed grade;
///
/// return $return;
$feedback = get_record("feedback", "id", $feedbackid);
if (empty($feedback)) {
return NULL;
}
$return->grades = get_records_menu("feedback_completed", "feedback", $feedbackid, "", "userid,completed");
$return->maxgrade = 1;
return $return;
}
Let me know if it works...
Re: Conditional activities: Activity Locking for Moodle 1.5.1
OK, so part worked and part did not.
I created the extra field in the database - worked fine.
I changed the function in the lib.php file - worked fine.
I went into the course and opened the locked activity - and sure enough, there was a drop down list now showing the option of flag 0 or 1, for viewed or submitted - worked fine
I went on to a dummy student account and submitted the feedback form. Checked the database (feedback_completed) and the flag had been set to 1 correctly - worked fine.
However, the student still could not access the locked activity that was dependant on this feedback form being submitted. The form is definitely there - i can see it on the feedback pages under analysis. But from the students view, they still cannot access the activity that was conditional on the submission.
If it is easier to test and see what i mean I have set up a dummy teacher and student account for you to take a look at. I will send a message directly to you with the access details. The url is:
www.childbirthinternational.com/study
The course is Testing (under Administration). There are two feedback forms - one that should be submitted and one that does not have to be. And one conditional activity - a request for certification to be processed form that is reliant on the first feedback form being submitted.
Thanks so much for all your help with this.
Nikki
Re: Conditional activities: Activity Locking for Moodle 1.5.1
(although I may well be wrong)
I think it is because you have renamed the module to "evaluation" instead of "feedback". It all depends where you changed the name of the module.
Did you change the record for feedback in the "modules" table? If so, change it back and see if it then works.
If you'd like to change the name of a module that appears to a user, then you only need to edit it in the language files (assuming it is written according to Moodle's rules)
Re: Conditional activities: Activity Locking for Moodle 1.5.1
I can see the feedback has been updated with the grade of 1 in the feedback_completed table. It appears in the gradebook with the correct score of 1. Just is not unlocking once it has been submitted. Confused???
Nikki
Re: Conditional activities: Activity Locking for Moodle 1.5.1
What makes it all the more difficult is that I can't get the feedback module to work at all here on any of my systems.
I think the next step is to start putting some debug code in the locking code.
Is there any chance you could download this version of locklib.php and put it in your lib folder of your moodle installation. It will hopefully show what is going wrong...
Bear in mind that this will print ugly debugging code above any locked activity.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
OK, I have attached one file - at the beginning is what i see in the debugging on the course topics page, and second is what I see in the locked activity itself.
Good luck!
Nikki
Re: Conditional activities: Activity Locking for Moodle 1.5.1
I've figured out why it's not working.
Basically, the piece of code that checks if a module is (un)locked works as follows:
- It looks at each module that is locking that module
- For each module, it forst looks in the logs for an entry. If there isn't one it assumes the module hasn't been accessed and stops.
- Only if there is an entry in the logs does it continue to see if a user has the necessary grade
With that in mind, try the attached locklib.php file.
Hopefully it should work for you. There may be more issues, though, with this anonymous thing.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
You are a star!! This worked perfectly. I created a feedback form that was nonanonymous and it was perfect. I have no need for anonymous forms but would you like me to test to see if it works ok?
Nikki
Re: Conditional activities: Activity Locking for Moodle 1.5.1
If you wouldn't mind.
As I said, I've got no way of checking it as feedback doesn't seem to work on my system. It'd be nice to know it works.
It should...
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Nikki
Re: Conditional activities: Activity Locking for Moodle 1.5.1
...but can see it would nice if it worked for others...
It would. But then thinking about it, adding an entry to the log when a user submits an "anonymous" feedback kind of makes a mockery of the anonimity.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Re: Conditional activities: Activity Locking for Moodle 1.5.1
sorry to not be as fast as Stuart who his the activity locking creator!
It is a good idea to try to adapt Andreas nice feedback module with activity locking.
You are on a right way with Stuart suggestions.
Bye,
Bernard
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Bit of a pain that CVS is, wouldn't let me grab an export copy(without all the cvs dirs).
OK. I have a clean install of moodle 1.5.1, new db, and latest al_0.41.
Label problem doesn't appear. Cool.
- When the locked message comes up "This activity is currently locked. You must complete the following prerequisites first "Time Delay" . I think the amount of time remaining should be displayed.
- By clicking the topic lock, you can select pre-requisites for that topic, I assumed. So I selected all the activities in the previous topic as pre-requisites. Now, the lock only seems to appear on the first activity of the topic I locked. Seems it ought to lock the whole topic.
Topic 1
activity 1
activity 2
Topic 2
activity 3
activity 4
IE. By clicking on the topic 2 lock, and setting activity 1 and 2 as pre-requisites, locks should be placed on activity 3 and 4. Sound right? It is only placing a lock on activity 3 currently.
3. The lock page (http://192.168.1.100/moodle/course/lock.php?) is not completing its output. Please add:
print_footer($course);
just before closing php tag:
?>
Dave.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Think I have found a minor bug - at least I think it is minor!
It seems I cannot have activity locking together with copy resources. I had copy resources a few days ago. Then I copied in activity locking and copy resources disappeared - did not connect the two at the time.
I just now copied in copy resources again and activity locking was lost straight away.
Would be nice to have both features. Do I post this here or somewhere else since it crosses over two different features?
Nikki
Re: Conditional activities: Activity Locking for Moodle 1.5.1
I recently upgraded from 1.4.5 to 1.5.+, and now to 1.5.2 the certificate locks where running perfectly but after the upgrade I get this error:
"Call to undefined function: islocked() in /home/minnay/public_html/CEU/course/lib.php on line 1062", students can print a certificate without going through a course lesson. I have been carefully following the discussions and silently using the hacks but now I am kind like stuck.
Any idea on how to fix would greatly be appreciated.
Thanks
Luke
Re: Conditional activities: Activity Locking for Moodle 1.5.1
The first thing I would suggest you try is go to
http://download.moodle.org/download.php/modules/activity_locking.zip
to get the latest version of activity locking.
Unzip it to the relevent folders and it should fix your problem.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Thanks Stuart
I have just downloaded and added the newer files but it has not fix the problem, the error line now moved to /course/lib.php line 1061 with the same message. Fatal error: Call to undefined function: islocked() in /home/minnay/public_html/CEU/course/lib.php on line 1061
Any further suggestions
Luke
Re: Conditional activities: Activity Locking for Moodle 1.5.1
If you have overrwitten your existing files with the ones in the zip then I can't see what has happened.
One thing you could check for me. Can you have a look near the top of the course\lib.php and see whether it has a "require_once" line for lib\locklib.php
Anyone got any other suggestions? I'm stumped.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Line 1163:
require_once("$CFG->dirroot/mod/resource/lib.php");
Line 1424:
require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
This is all that is in there that says require_once.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
That's correct; the two require_once lines are found at 1163 and 1464
Luke
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Here is what I found
if (file_exists($libfile)) { //4 require_once($libfile); line 33
if (file_exists($libfile)) { require_once($libfile); line 67
global $USER, $CFG, $course; //It there an alternative to global $course?
require_once($CFG->dirroot.'/course/lib.php');
get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
$locklist = ""; line 102
Thanks
Luke
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Re: Conditional activities: Activity Locking for Moodle 1.5.1
This is what is found
require_once('../config.php');
require_once('lib.php');
require_once($CFG->libdir.'/blocklib.php');
require_once($CFG->libdir.'/locklib.php');
on line 5
and
require_once($CFG->dirroot.'/calendar/lib.php') line 46
Luke
Any suggestions on what I should try to crank?
Luke
I too am getting Fatal error: Call to undefined function: islocked() with Moodle 1.5.2 and the latest version of activity_locking.
Has anyone found the solution?
Thanks
Thanks Perito
Where exactly do you insert require_once($CFG->libdir.'/locklib.php');? I have tried different places but it still gives me the same fatal error.
Luke
Re: Conditional activities: Activity Locking for Moodle 1.5.1
///Activity Locking ///
}
require_once($CFG->libdir.'/locklib.php');
if (($locks = islocked($mod)) and (array_search("closed", $locks) or isteacher($course->id))) {
$linkcss = " class=\"dimmed\" ";
echo "<img src=\"$icon\"".
" height=16 width=16 alt=\"$mod->modfullname\">".
" <font size=2><a title=\"$mod->modfullname\" $linkcss $extra".
" href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename (".get_string("locked", "lock").")</a></font>";
} else { // Normal activity
$linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
echo '<img src="'.$icon.'"'.
' class="activityicon" alt="'.$mod->modfullname.'" />'.
' <a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.
$instancename.'</a>';
}
if ($locks) {
if (isset($course->showactivitytracking) and $course->showactivitytracking == 1) {
foreach ($locks as $lock => $state) {
if ($state == "open") {
echo " <img src=\"$CFG->pixpath/t/open.gif\" height=\"11\" width=\"11\"".
" title=\"".get_string("predecessorcomplete", "lock").": ".urldecode($modinfo[$lock]->name)."\"".
" alt=\"".get_string("predecessorcomplete", "lock").": ".urldecode($modinfo[$lock]->name)."\">";
} else {
echo " <img src=\"$CFG->pixpath/t/closed.gif\" height=\"11\" width=\"11\"".
" title=\"".get_string("predecessornotcomplete", "lock").": ".urldecode($modinfo[$lock]->name)."\"".
" alt=\"".get_string("predecessornotcomplete", "lock").": ".urldecode($modinfo[$lock]->name)."\">";
}
}
}
}
///End Activity Locking ///
Re: Conditional activities: Activity Locking for Moodle 1.5.1
I'm soooooo sorry, I sent you my copy from contrib and didn't realize that Stuart hadn't added that line.
I'm glad you've gotten it all figured out!!!
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Oh,- Chardelle...
I thought you've given me this as a task in your Lifeworkout programme.
Maybe Stuart needs a hand to keep the CVS up to date?
So Stuart if you are back from vacation, then you can let us know, if you need help.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
I have been using activity locking on my localhost without problem. I have added the line shown. Do I need to do anything else?
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Hi Stuart and others!
I have identified this error too, with the latest Moodle 1.52+ version of today.
The error is 'only' seen on the frontpage,
Look forward to see what we can do about it.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Hi Moodlers,
Regarding the fatal error with the locklib issue, then it seems you only can reproduce it IF you have a subject in the middle of your front page.
If I set the site settings to only show the courses, then I don't see the fatal error, but it is still there of course.
I use it with Moodle 1.5.2 + (2005060222) version.
And when I try to lock an activity it says: Warning: Variable passed to each() is not an array or object in C:\minixampp\htdocs\moodle\lib\locklib.php on line 145
Chardelle thank you for the files you send me, I am sorry it did not help, so for now we can maybe conclude that this works with up til Moodle version 1.5.2 (2005060220) - the version that Chardelle has success with?
So fellow Moodlers don't get to tempted to update your Moodle with this great mod yet.
KR
Jens
Re: Conditional activities: Activity Locking for Moodle 1.5.1
It would require manually editing that (and possibly other) file to include both pieces of custom code.
As both hack are under development, it would be difficult to keep it all up to date.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Very strange behaviour. I looked at PHP and zend bugs, and nothing.
It appears that you need to place in lib/locklib.php:
reset($passmarks);
right before the
while(list($predecessor, $passmark) = each($passmarks)){
call. Otherwise this statement fails after first call. IE, if you need to lock 3 activities in a section, only first 1 will lock.
Dave.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
I think I know why.
As you know, $passmarks is an array. The elements delayday, delayhour, delaymin are the last 3 entries in the array.
The lines above the one you have referenced above work with those last 3 elements, e.g $delay = $passmarks->delayday or something.
After that has been done this must leave (on some versions of php) the array's internal pointer pointing to one of those elements, which is at the end of the array.
When the foreach function is called, it works its way through the array from the pointer to the end of the array. In this case, the pointer is at, or almost at, the end of the array so nothing is done.
That's why the reset() function works nicely.
That's my guess anyway.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Stuart,
Any bugs still outstanding? I am having some trouble getting locking to work based on a grade. I can still click on a link, thats greyed, and says locked. And enter that activity. Is that suppose to happen?
Where is the code that checks that a grade has been met, which file, and function?
Dave.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Off the top of my head, it's the lib/locklib.php file.
I believe the function is called islocked().
The checking of user grades happens, I think, somewhere around the deepest part of the nesting within that function.
Re: Conditional activities: Activity Locking for Moodle 1.5.1
Hi Stuart,
I was just wondering what the status was of this/
Thanks!
Ralph