Closing "In Progress" Quizzes After Close Date

Closing "In Progress" Quizzes After Close Date

د David Housman لخوا -
د ځوابونو شمیر: 12

I use Moodle Quizzes for student homework.  I set a "Close the quiz" date/time but do not enable a time limit.  "How questions behave" is set to "Adaptive mode (no penalties)" so that students can try a question again if they intially give an incorrect answer.  Some students answer some or all of the questions and "Check" each answer, but then never "Submit" the quiz.  In the "Attempts" report for the quiz, I can see that these students have gotten some or all of the automatically graded questions correct; however, their "State" is "In progress."  For the manually graded problems, their answers do not appear when I do the manual grading.  In my grade book, no grade appears.  Of course, since the quiz has closed, students cannot go back in and submit.

I would like for "In progress" quizzes to automatically change to "Finished" when the closing time has past.  I thought that setting the "When time expires" option to "Open attempts are submitted automatically" would do this, but it has not (perhaps this option is only active when a time limit is imposed).

Any advice?  Is this a bug?

د درجې بندۍ اوسط:  -
In reply to David Housman

Re: Closing "In Progress" Quizzes After Close Date

د Tim Hunt لخوا -
د Core developers انځور د Documentation writers انځور د Particularly helpful Moodlers انځور د Peer reviewers انځور د Plugin developers انځور

Is cron running on your servers?

In reply to Tim Hunt

Re: Closing "In Progress" Quizzes After Close Date

د David Housman لخوا -

From my Moodle administrator: "There is a specific moodle script that had stopped being run; I remade scheduling so I think the problem has been solved"

"cron is running the admin/cli/cron.php script every 15 minutes.  It's possible that Moodle is expecting it to run every minute but occasionally the script takes more than a minute to run.  I've upped the frequency to every 5 minutes but that still might not be often enough for you." 

Another deadline has past and the symptoms are the same.

In reply to David Housman

Re: Closing "In Progress" Quizzes After Close Date

د Tim Hunt لخوا -
د Core developers انځور د Documentation writers انځور د Particularly helpful Moodlers انځور د Peer reviewers انځور د Plugin developers انځور

That is odd. Is your admin sure that cron is runing with no errors?

In reply to Tim Hunt

Re: Closing "In Progress" Quizzes After Close Date

د E. L. Cooper لخوا -

First moodle does not do every job on every cron so give it a day of running.

Second because he had cron turned off it may now be timing out- basically it may have very big jobs to do but the jobs can not complete due to timeout settings from the server.

Try this - try a manual cron- the path would be www.whereeveryourmoodleis.com/admin/cron.php

If manual cron is not disabled a page of text will start to scroll and either complete or time out.

In reply to E. L. Cooper

Re: Closing "In Progress" Quizzes After Close Date

د David Housman لخوا -

The symptoms were the same a couple of days ago.  However, either things are working or all of my students finished the last assignment on Friday.  I have set up a test student in an "in progress" state for the assignment due in 36 hours.  If cron does not work automatically, I will ask my administrator to try the manual suggestion.  I will let you know the outcome of the experiment.

In reply to David Housman

Re: Closing "In Progress" Quizzes After Close Date

د Tim Hunt لخوا -
د Core developers انځور د Documentation writers انځور د Particularly helpful Moodlers انځور د Peer reviewers انځور د Plugin developers انځور

A possible explanation for this: The first time cron is run in Moodle 2.3.x is quite slow, because it has to process all the quiz attempts that happened in the past. Once it has caught up, everthing will then work smoothly. (That is just a guess.)

In reply to Tim Hunt

Re: Closing "In Progress" Quizzes After Close Date

د David Housman لخوا -

After not working again and informing my Moodle administrator of your suggestions, he replied, "Well, that was odd. I verified that it was indeed running, but it only checks for quizzes that have become overdue since it last ran. Somehow your quizzes managed to go overdue in a time span that it thought was already processed.

I suspect the cause was that the script logic had a bit of logic that caused it to skip the check if the cron had run in the last 6 minutes. I suspect that if the cron is run in that 6 minute window, it would update the time last run, skip the check, and still update the last run time. I removed that 6 minute window logic so HOPEFULLY this won't happen again.

In any event, modifying the code to spoof the date that it last ran was trivial enough, so if it does happen again, just let me know and I should be able to have it fixed in under 5 minutes.
"

It does now work.  Thank you all!

In reply to David Housman

Re: Closing "In Progress" Quizzes After Close Date

د Tim Hunt لخوا -
د Core developers انځور د Documentation writers انځور د Particularly helpful Moodlers انځور د Peer reviewers انځور د Plugin developers انځور

Can you thank your admin for me. The time is quite late now in the UK, so I will review that bit of code carefully in the morning to make sure it cannot miss anything.

In reply to Tim Hunt

Re: Closing "In Progress" Quizzes After Close Date

د Tim Hunt لخوا -
د Core developers انځور د Documentation writers انځور د Particularly helpful Moodlers انځور د Peer reviewers انځور د Plugin developers انځور

I have checked the code again, and as far as I can see, it is correct.

It uses two variables:

$quizconfig->overduedoneto = get_config('quiz', 'overduedoneto');

which is the time up until which we have completed processing, and then

$processto = $timenow - $quizconfig->graceperiodmin;

We then process all attempts that were last modified between those two times - using <= on the start time, and < on the end time.

If the processing complete successfully, then we do

set_config('overduedoneto', $processto, 'quiz');

so that the next time, processing continues from where it left off.

The relevant code is in quiz_cron in mod/quiz/lib.php if anyone else wants to check my logic.

There is a separate variable: get_config('quiz', 'overduelastrun'); which is used to ensure that this processing is only done about once per hour.

In reply to Tim Hunt

Re: Closing "In Progress" Quizzes After Close Date

د Roger Emery لخوا -

I think my question is ...'say that again?!?"

Same issue with unfinished quiz attempts - I've reset the quiz settings to "Open attempts are submitted automatically" and set the time so the close dates/time is past and run the cron (which is running fine, but I kicked it off manually to monitor the results)

However the quiz attampets are still 'unifinished'
I decided to leave it over night so a few cron's could run (every 15 mins) but still the same today.

Can you re-advise the combination of finish date and cron timing please (or any other settings I'm missing).

 typical cron extract:

Processing module function quiz_cron ...
Starting quiz reports
Processing cron function for quiz_statistics...
done. (1 dbqueries, 0 seconds)
Finished quiz reports
... used 6 dbqueries
... used 0.019401073455811 seconds
done.
In reply to Roger Emery

Re: Closing "In Progress" Quizzes After Close Date

د Tim Hunt لخوا -
د Core developers انځور د Documentation writers انځور د Particularly helpful Moodlers انځور د Peer reviewers انځور د Plugin developers انځور

That was really me talking to myself, arguing that the code was logically correct. Unfortunately, it turns out that my analysis was faulty. Matt Petro managed to work out exactly what was going wrong, and we now have a bug report: MDL-35717

In reply to David Housman

Re: Closing "In Progress" Quizzes After Close Date

د Noat Tran لخوا -

Hello,

I was also stuck in this case many times before.

And I found the function in Moodle's library, called quiz_cron(), it saved my life.

And if you're PHP developer, you can write your own code for solving this problem, similar to my code below:

global $CFG, $USER;
if ($USER->username!='admin') {header("Location: /index.php");die();}   
require_once($CFG->dirroot . '/mod/quiz/cronlib.php');
mtrace('');
	
$timenow = time();
$overduehander = new mod_quiz_overdue_attempt_updater();
	
$processto = $timenow - get_config('quiz', 'graceperiodmin');
	
mtrace('  Looking for quiz overdue quiz attempts...');
	
list($count, $quizcount) = $overduehander->update_overdue_attempts($timenow, $processto);
	
mtrace('  Considered ' . $count . ' attempts in ' . $quizcount . ' quizzes. <a href="/index.php">Go back</a>');
	
// Run cron for our sub-plugin types.
cron_execute_plugin_type('quiz', 'quiz reports');
cron_execute_plugin_type('quizaccess', 'quiz access rules');
die();
If you have any confuses, please don't hesitate to reply here, I am willing to help. Kind regards, Toan