diff --git a/lang/en/quiz.php b/lang/en/quiz.php index 1fb53e3c565..5ba553dd64d 100644 --- a/lang/en/quiz.php +++ b/lang/en/quiz.php @@ -10,6 +10,7 @@ $string['addquestionstoquiz'] = 'Add questions to current quiz'; $string['addrandom1'] = ' Add '; $string['addrandom2'] = 'random questions '; $string['addselectedtoquiz'] = 'Add selected to quiz'; +$string['addtoquiz'] = 'Add to quiz'; $string['affectedstudents'] = 'Affected $a'; $string['aiken'] = 'Aiken format'; $string['allinone'] = 'Unlimited'; diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index ab80eacf6d6..1014ab993ff 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -101,7 +101,32 @@ } } - if (isset($_REQUEST['add']) and confirm_sesskey()) { /// Add a question to the current quiz + if (isset($_REQUEST['addquestion']) and confirm_sesskey()) { /// Add a single question to the current quiz + + // add question to quiz->questions + $key = $_REQUEST['addquestion']; + if (!empty($modform->questions)) { + $questions = explode(",", $modform->questions); + } + $questions[] = $key; + $modform->questions = implode(",", $questions); + if (!set_field('quiz', 'questions', $modform->questions, 'id', $modform->instance)) { + error('Could not save question list'); + } + + // update question grades + $questionrecord = get_record("quiz_questions", "id", $key); + if (!empty($questionrecord->defaultgrade)) { + $modform->grades[$key] = $questionrecord->defaultgrade; + } else if ($questionrecord->qtype == DESCRIPTION){ + $modform->grades[$key] = 0; + } else { + $modform->grades[$key] = 1; + } + quiz_questiongrades_update($modform->grades, $modform->instance); + } + + if (isset($_REQUEST['add']) and confirm_sesskey()) { /// Add selected questions to the current quiz $rawquestions = $_POST; if (!empty($modform->questions)) { $questions = explode(",", $modform->questions); diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 2cb52d3d22e..41c70ed9d89 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -1338,8 +1338,10 @@ function quiz_print_cat_question_list($categoryid, $quizselected=true, $recurse= $strquestionname = get_string("questionname", "quiz"); $strdelete = get_string("delete"); $stredit = get_string("edit"); + $straction = get_string("action"); $straddselectedtoquiz = get_string("addselectedtoquiz", "quiz"); + $straddtoquiz = get_string("addtoquiz", "quiz"); $strtype = get_string("type", "quiz"); $strcreatemultiple = get_string("createmultiple", "quiz"); $strpreview = get_string("preview","quiz"); @@ -1412,32 +1414,22 @@ function quiz_print_cat_question_list($categoryid, $quizselected=true, $recurse= echo "sesskey\">"; echo "
| $strselect | "; + if ($canedit) { + echo "$straction | "; } echo "$strquestionname | $strtype | "; - if ($canedit) { - echo "$stredit | "; - } echo "|
|---|---|---|---|---|---|
| "; - echo "id\" value=\"1\" />\n"; - echo " | "; - } - echo "".$question->name." | \n"; - echo "\n"; - quiz_print_question_icon($question, $canedit); - echo " | \n"; if ($canedit) { echo "\n";
- echo "id&delete=$question->id\">\n ";
+ if ($quizselected) {
+ echo "id&sesskey=$USER->sesskey\"> ";
+ }
echo "id','$strpreview','scrollbars=yes,resizable=yes,width=700,height=480', false)\"> ";
echo "id\"> ";
+ if ($quizselected) {
+ echo " id\" value=\"1\" />";
+ }
echo " | \n";
}
+
+ echo "".$question->name." | \n"; + echo "\n"; + quiz_print_question_icon($question, $canedit); + echo " | \n"; echo "