using webservice to download audiofiles for quiz questions?

using webservice to download audiofiles for quiz questions?

by Jerry Kalkhof -
Number of replies: 0

Hi guys,

I've been developing a mobile app to display quiz questions, however I ran into a particular problem with the quiz information question type.

Normally I can use the files api to download audio files this way:

When I submit a url query based on the data sent back in question get attempt:

http://localhost/moodle//webservice/pluginfile.php/181/question/questiontext/527/i/157/pinyin.mp3?token=33d918456dca5f5577fd307444ddfa0d

I get this error:

{"error":"Coding error detected, it must be fixed by a programmer: There is no question_attempt number 0 in this attempt.","stacktrace":null,"debuginfo":null,"reproductionlink":null}

The only way I found around this was to add in a "fix" in mod/quiz/lib.php : in function quiz_question_pluginfile

// fix to handle getting audio for information type questions from webservice/pluginfile.php
    if (($slot != 'i') && !$attemptobj->check_file_access($slot, $isreviewing, $context->id,
            $component, $filearea, $args, $forcedownload)) {
        error_log("mod/quiz/lib.php: quiz_question_pluginfile: check_file_access FAILED!");
        send_file_not_found();
    }


Is there a better way around this problem? I haven't found anything from my research in Moodle Tracker.


thanks

Average of ratings: -