// Add this to ujQuiz as a question
jrCore_register_event_listener('ujQuiz', 'section_contribution', 'ujCodePlay_quiz_section_contribution_listener');
// Contribute a section to ujQuiz
function ujCodePlay_quiz_section_contribution_listener($_data, $_user, $_conf, $_args, $event)
{
if (isset($_user['quota_ujCodePlay_allowed']) && $_user['quota_ujCodePlay_allowed'] == 'on') {
$_data['codeplayquiz'] = array(
'module' => 'ujCodePlay',
'name' => 'ujCodePlay quiz section',
'section_func' => 'ujCodePlay_section_codeplayquiz',
'process_func' => 'ujCodePlay_process_section_codeplayquiz',
'template_location' => 'ujCodePlay',
'template_tpl' => 'quiz_section_codeplayquiz.tpl',
'answer_func' => 'ujCodePlay_answer_codeplayquiz'
);
}
return $_data;
}
var quiz_func = 'ujQuiz_' + answer.question_type + '_result';
// run the contributing function (this js function will be part of the contributing module, but it MUST be prefixed with "ujQuiz_")
// check that this function exists
if (typeof window[quiz_func] === "function") {
window[quiz_func](answer, index, icon_correct, icon_incorrect);
}
/*
* Result js function - if the question has been answered this function runs when the answer is loaded into the page
*/
function ujQuiz_multiplechoice_result(answer, index, icon_correct, icon_incorrect)
{
var icon = icon_incorrect;
var resultclass = 'error';
if (answer.correct) {
resultclass = 'success';
icon = icon_correct;
}
$("#c" + index + " input[value='" + answer.answer_id + "']").attr("checked","checked").parent().addClass(resultclass).append(icon).siblings().removeClass("error success");
return true;
}