Moodle for mobile

how to force user answer to all question?

 
sadafe
how to force user answer to all question?
 

hi...

i do something in moodle server to force user to answer all question of quiz (write some code in mod/quiz/processattempt.php) and it is work in the moodle web side.

now i want do similar in the moodle mobile and force user to check all question in each quiz page and if he don't check that, the nextpage button not redirect to nextpage or redirect to CurrentPage. I read some function about nextpage in https://docs.moodle.org/dev/Quiz_support_in_the_Mobile_app#Moodle_Web_Services

but i don't understand what file is better to edit or is needed server file edited or need edit moodle mobile file's edit too?

 
Average of ratings: -
sadafe
Re: how to force user answer to all question?
 

i do this and it work for me only for moodle web not moodle mobile.

modify mod/quiz/processattempt.php line 84 by add this:

//1360 is your quiz id

// Check all questions in this page MUST be completed

$quizIDs_MustCompleteAnswered = Array ("1360");

if (in_array($attemptobj->get_cmid(), $quizIDs_MustCompleteAnswered)) {

// V2

$questionids = $attemptobj->get_slots($thispage);

$questions = array();

$questions_state = array();

foreach ($questionids as $key => $id) {

$questions[$key] = $attemptobj->get_question_attempt($id);

$questions_state[$key] = $attemptobj->get_question_state($id);

if ($questions_state[$key] != question_state::$complete) {

$next = false;

break;

}



also add custom js for "Next page" button to your moodle is good but both php and js is best way.


 
Average of ratings: -
Picture of Dani Palou
Re: how to force user answer to all question?
Core developersMoodle HQParticularly helpful MoodlersPlugin developers

Hi,

the mobile app calls the WebService mod_quiz_process_attempt with the answers when changing page. You should modify that WebService to check if all the answers have been supplied, and return an error if they aren't.

Cheers,

Dani

 
Average of ratings: -