Conditional activities: Activity Locking not working on localhost

Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Number of replies: 31
Hello,

I hav installed Moodle 1.9.5+ on my laptop(standalone). It is working fine. I tried to add ActivityLocking plugin feature but this features is not getting installed. Even after following the steps from video
http://moodlefairy.posterous.com/activity-locking-course-format-for-moodle-19. I am getting following errors when I click notifications:

Enabling the PHP setting display_errors is not recommended on production sites because some error messages may reveal sensitive information about your server.
The cron.php maintenance script has not been run for at least 24 hours. Help with Installation (new window)
Please register your site to remove this button


Can anyone please tell me how to solve this problem??? I am not able to install this feature on my localhost.
Average of ratings: -
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Hi there. Just a recap from other posts so others can help you -those settings are not important if you are running on local host and not online.
You have said in other posts that your Moodle is working ok and that you can select the Activity locking course format in course administration>settings.
Could you please clarify what exactly is NOT working? What happens when you select the activity locking course format and then you start building your course?
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
As Chardelle says in this forum http://moodle.org/mod/forum/discuss.php?d=128318.
that after copying activity_locking folder into moodle/blocks, by clicking Notification one shuld be able to install this feature. But I am unable to insatll it. But when I copy locking folder into moodle/format, i can see the activity_locking option while creating a course.
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Hurray.... I made it to work. The activity_locking feature is working fine. Mary thanks for all ur help. I actually reinstalled the whole Moodle and tried adding the featrue and it worked.... smile
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Glad you got it working smile What you did is I suppose an equivalent of the switchitoffandswitchitonagain solution that seems to solve so many techie problems!
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Hello Mary,

I have another problem now. I am not able to lock the courses as shown in the video. I mean.... three tasks are created and I set task-2 to be locked until task-1 is completeled, and task-3 to be locked until task-1 and 2 are completed. But it seems to be not being locked. When I login as a student I am able to access task-2 without completing task-1. Can you please tell me if I hav to add any code or make any changes to it.
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Have you gone into tast 1 and set activity completion - for it to have to be completed?It is very difficult to help when your Moodle is not online really-what icons(boxes/locks etc) do you see next to your 3 activities as a brand new student to the course? If you create a new user, then enrol them in the course as a student and take a screenshot - could you do that?
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Thanks for your reply. No I do not have an option that asks for completion of activity. But I can see the lock image next to the activity when I login as a student. I can send you a document that contains screenshots to ur email. i am not able to upload the document to the forum.
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Thanks Divya. I got your screenshots. First of all, have you had a look at shows how you can set a completion of activity requirement - which you should do for activity 1 so that they must complete task 1 before they are allowed to go to task 2.
In your email you seemed to be looking at the actual task itself for the completion requirement rather than clicking on the lock. Try this and see if it works.
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Its not working sad.... I followed the steps as shown in the video. The activities are not getting locked. I am able to access quiz-2 without completing quiz-1.
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
well, again; this shouldn't really make any difference I know and I don't understand why it might, but DeWayne Demland had the same problem as you with his Moodle offline and as soon as he put it online the activity locking worked. Could you post a screenshot of the activity locking requirements for accessing quiz 1 and also quiz 2?
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Ravishankar Somasundaram -
Dear Mary cooch,

Technically speaking i fail to understand the fact when people say they are able to make work AL code properly when they host it through internet and the same AL code with same moodle engine with dependencies running on their localhost dosent seem to work properly.

Divya muvvala as mary cooch mentioned , it would be easier for us to isolate the problem if you post some screen shots of what locks you have applied to those activities.
In reply to Ravishankar Somasundaram

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Thanks for all your replies. Sorry I am not able to upload the file as it is too big. I have emailed Mary the file. Ravishankar I can email you if you wish so.

In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Hi Divya. I see from your screenshots that you want them to access quiz one only after they have accessed the forum but you have not set any activity completion in the forum.I suggest you click on the lock next to the forum and scroll down to activity completion -click on access forum and then try again. I suggest then you log of and then log in as student (ie, not using the log in as feature from admin) and test it out then. I have tried this and it works.
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
I have another question, when I create a new course there is a default New forum created automatically by Moodle. When I set lock to this and login as a student I get this screen( Note: will send u by email) I am not sure if this is correct way.
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Every time you create a new course Moodle automatically creates a news forum. If you don't want it, you can either switch if off all your courses in Site admin>courses>course default settings or else you can go to the individual course settings in course admin, turn news items to 0 and then delete the news forum with the x on your course page. Note that students cannot post to a news forum; they can only read the news.
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Divya - your latest screenshot showed the news forum with a message to students "no news has been posted yet" This is correct. The news forum is a general announcement forum for teachers to post news about the course. Students can only read and not reply. Test it out by logging in as admin or a teacher and then posting an announcement.
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Now I changed the default settings in course and do not see News forum. I tried again setting-up activities as shown is video but still didnt work. Do I hav to change any default setting at course or activity level?????
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
What is the first activity that your students must complete before they are allowed to access quiz 1? And on that first activity (which is obviously not the news forum) have you set the lock to make sure that activity is completed? If yes, I can only go back to the thought that somehow this is not working offline as it didn't for DeWayne - but that does not make sense...
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Here how I created----

  • I selected Forum from the 'Add an activity' dropdown box. Then set the name of the forum and selected 'save changes' button. Similarly I selected quiz from 'Add an activity' dropdown box and set some questions (Note: i didnt change default settings for both activities)
  • I turned on editing ON and clicked locking image present beside Forum activity, ticked the box 'User must access this activity' and clicked saves changes button
  • Then clicked locking image beside Quiz-1 activity, ticked the box 'User must access this acitivity' for Forum and set the maximum marks for activity completion of Quiz-1 to 5. Selected Sava changes button
  • Similarly clicked locking image present beside Quiz-2 activity, ticked for Forum and set maximum marks for Quiz-1 and set maimum marks for activity completion for Quiz-2.
So from this, I hav first set to access the forum then quiz-1 and then quiz-2. But this is not happening so. I can access quiz-2 before completing quiz-1/ forum.
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Am I doing wrong while settin-up an activity, is ther anything i shuld change the default values??? Can you please tell me an alternative solution for this. I tried doing it from first but still not working.
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Ravishankar Somasundaram -
Dear Divya muvvala,

I dont see any flaw in the procedure that you have followed to put locks, This should work.

If you lock some activity or resource does locking icons appear for both admin and student ?

Are you sure that the AL CODE got installed properly , i would suggest you to turn debuging on to developers mode, and then do the same procedure once again to see whether you get any errors.

Dear Mary cooch

If i lock some activity or resource , i can access them i if i login as admin :O

it says "This activity is currently locked. You must complete the following prerequisites first: "

I know this shouldn be the case , posting it here to ask whether thats the way it is designed or i screwed up my system as i played with lot of core files :P

In reply to Ravishankar Somasundaram

Re: Conditional activities: Activity Locking not working on localhost

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Ravi - I get the same message as you as Admin.
In reply to Mary Cooch

Re: Conditional activities: Activity Locking not working on localhost

by Ravishankar Somasundaram -
Dear Mary cooch,

Not to worry, i am uploading my work which resolved the problem.

please replace the locklib.php file with this.

If you want details of how i did this,Have commented out parts which i have changed.
In reply to Ravishankar Somasundaram

Re: Conditional activities: Activity Locking not working on localhost

by Ravishankar Somasundaram -
please ommit the above uploaded file , it didnt have proper error handling done in it,If you have debugging on to developers mode you will see ugly non userfriendly messages.


Heres the latest one in which all the errors are handled good enough for not only the above mentioned issue but for other issues as well which i had with AL CODE.
In reply to Ravishankar Somasundaram

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Hi Ravi,

Thanks for your reply. When I installed activityLocking everything showed me success and there were no warnings or errors. I can try as you said ... i mean to turn debugging on to developers site but I dont know how to do this. Can you please tell how I can go about it.

Did you try this plugin on your localhost or anyother server????
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Ravishankar Somasundaram -
Dear Divya muvvala,

this can help you.

And yeah i had no problems with it in my localhost till now.
In reply to Ravishankar Somasundaram

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
I tried changing the debugging there were no errors shown. watelse can be stopping.... sad
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Ravishankar Somasundaram -
Dear Divya muvvala,

you didnt answer for the another question of mine.


If you lock some activity or resource does
1. locking icons appear for both admin and student ?
2. unlocking icons appear for admin/teacher ?

In reply to Ravishankar Somasundaram

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Yes Locking icons appear for both admin and student and unlocking icons appear for admin/teacher. And when I login as a student, access forum or other activity first a tick mark is shown.

I have a question, I was checking with my locklib.php file with your file which you have attached in the above forum. Does the code be affected due to spaces???
In reply to Divya muvvala

Re: Conditional activities: Activity Locking not working on localhost

by Ravishankar Somasundaram -
Regarding locklib.php

NO , spaces wont affect the code execution format unless and untill its breaking some parameters...

ex : $variable_sample is different from $variable _sample

And regarding the AL CODE execution on your machine,

I am left with no choice right now than to ask you this,

did you insert the three lines in your lib/moodlelib.php on about line 1975 under the function_require_login AFTER this 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;
}
}

pasted in the following code there ?

//Check to see if Activity Locking criteria have been met
require_once($CFG->dirroot.'/course/format/locking/locklib.php');
global $cm;
check_locks($cm);



In reply to Ravishankar Somasundaram

Re: Conditional activities: Activity Locking not working on localhost

by Divya muvvala -
Yes I did copy tat piece of code in moodlelib.php. but still hav no luck sad...Am I doing wrong while setting activities, i mean shuld I change any default values???