Problem in Cron Job

Re: Problem in Cron Job

by Benjamin Ellis -
Number of replies: 5
Picture of Particularly helpful Moodlers
Do you have a 3rd party activity modules installed? On upgrading it is always a good idea to exclude any 3rd party plugins and then re-introduce them after the upgrade.
In reply to Benjamin Ellis

Re: Problem in Cron Job

by Pawan Pandey -

Thanks for reply!!

Actually what you told is something new for me i.e remove external plugins before up-gradation.

But if we closely look the last line of cron, it is related to quiz and we dont have any external plugin for quiz based activitiesBut we utilized quiz activities in lot of courses. 

Is there any possibility that it is happening in corruption of quiz related data in database ?? And if yes how we can rectify it or any further information which i can provide so that it can help you to assist in resolving this issue.


Thanks!

In reply to Pawan Pandey

Re: Problem in Cron Job

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

this is the code. So the context is null for some reason.
has_capability('mod/quiz:ignoretimelimits', $this->context, null, false));

Maybee you can had in the code some traces to know the course that cause problem and the quiz.

Like
mtrace ('Tintin - courseid : ' . $course->id );
mtrace ('Tintin - quizid : ' . $quiz->id,);

Tintin is just to find it quickly in log...
I think that the good place to put it is in the function create() of the file
\mod\quiz\attemptlib.php

between these two lines :
$course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('quiz', $quiz->id, $course->id, false, MUST_EXIST);

I hope it's not just.... stupid.

Sometime record is missing for some reasons...

Dominique.
Average of ratings: Useful (1)
In reply to Dominique Palumbo

Re: Problem in Cron Job

by Pawan Pandey -
Sorry for delayed response, I was able to identify the course by putting logger in code. But I dont know how to resolve this issues, as i dont have strong understanding about Moodle Context. And regarding the function create() in attemptlib.php, i put logger there, but it didnt work. Can you tell how we can fix this ??


Thanks
In reply to Pawan Pandey

Re: Problem in Cron Job

by Benjamin Ellis -
Picture of Particularly helpful Moodlers

The problem you have is that $this->context in mod/quiz/attemptlib.php is null as Dominique has mentioned.  The context for the class is set in the __construct() function based on the course module but may not be set if not required.   It may be worth adding some trace code in that function as well as the create() function.  The issue suggests to me a Quiz or Quiz attempt record that does not relate back to a course module.  I would check my quiz database records 1st.  

At the risk of telling you something you know already, if you are going to add debugging to core files, I suggest you backup the file first so you can restore it once you have determined what the issue is. 

In reply to Benjamin Ellis

Re: Problem in Cron Job

by Pawan Pandey -
Thanks for reply..
Actually we have run some cli admin commands like,

Fix orphaned question categories
--------------------------------------
admin/cli/fix_orphaned_question_categories.php --fix

Fix course/module sequences
-----------------------------------
php admin/cli/fix_course_sequence.php -c=* --fix

After this we are running cron.

Does the above command like can create a problem which justify your statement "The issue suggests to me a Quiz or Quiz attempt record that does not relate back to a course module."

Thanks for tips on backup, we are using git checkout -- * to undo changes.
Average of ratings: Useful (1)