function quiz_generate_dummy_multichoice_question_info in Quiz 7.6
Same name and namespace in other branches
- 8.6 quiz.devel.inc \quiz_generate_dummy_multichoice_question_info()
- 8.5 quiz.devel.inc \quiz_generate_dummy_multichoice_question_info()
- 7.5 quiz.devel.inc \quiz_generate_dummy_multichoice_question_info()
- 6.x quiz.devel.inc \quiz_generate_dummy_multichoice_question_info()
Template for multichoice questions.
Return value
array
1 call to quiz_generate_dummy_multichoice_question_info()
- quiz_generate_questions in ./
quiz.devel.inc - Generate Quiz questions.
File
- ./
quiz.devel.inc, line 197
Code
function quiz_generate_dummy_multichoice_question_info() {
$array = array(
'choice_multi' => array_rand(array(
0,
1,
)),
'choice_random' => array_rand(array(
0,
1,
)),
'choice_boolean' => array_rand(array(
0,
1,
)),
);
$rand = $array['choice_multi'] ? 1 : rand(2, 10);
for ($i = 0; $i < $rand; ++$i) {
if (!$array['choice_multi']) {
// Not multi answer - we can only do 1 correct answer.
if ($i == 0) {
$correct = 1;
}
else {
$correct = 0;
}
}
else {
// Multi answer.
$correct = rand(0, 1);
}
$array['alternatives'][] = array(
'correct' => $correct,
'answer' => array(
'value' => devel_create_greeking(rand(2, 10)),
'format' => filter_default_format(),
),
'feedback_if_chosen' => array(
'value' => devel_create_greeking(rand(5, 10)),
'format' => filter_default_format(),
),
'feedback_if_not_chosen' => array(
'value' => devel_create_greeking(rand(5, 10)),
'format' => filter_default_format(),
),
'score_if_chosen' => 1,
'score_if_not_chosen' => 0,
);
}
return $array;
}