Hi all, I hope this is in the right section.
I've setup a lesson that needs to be viewed which then allows a quiz through a conditional activity to be accessed immediately.
If one of the answers is incorrect on the quiz, I want the quiz to immediately end and become hidden again until the lesson is retaken.
From reading, I don't think this is possible without modification and having a bit of a play, I have narrowed down the relevant tables and completion code.
I've got the completion code to change
back to not viewed for the course->module->user when a certain
"failed" content page is shown in the quiz but I can't find how to
apply the change. The completion snippets below:
require_once("{$CFG->libdir}/classes/task/completion_regular_task.php");
$ci = new \completion_info($course);
$ci->update_state($cm,COMPLETION_NOT_VIEWED,3);
Interestingly, if I refresh the logs by hitting the button under siteadmin->Reports->Logs--"Get these logs", my completion code from above is applied and the user is locked out of quiz again. Something in that button code is instantly applying the completion revocation.
Would someone be able to tell me which function the log update button uses or how to apply completion changes immediately?
Thankyou
Jason