mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 09:55:33 +02:00
It is now no longer possible to add or delete questions in a quiz that students have already attempted, see http://moodle.org/mod/forum/discuss.php?d=16479#86488
This commit is contained in:
parent
7f3c54ab17
commit
b37cacae47
mod/quiz
@ -196,6 +196,36 @@
|
||||
$strediting = get_string('editquestions', "quiz");
|
||||
|
||||
// Print basic page layout.
|
||||
|
||||
if (isset($modform->instance) and record_exists_sql("SELECT * FROM {$CFG->prefix}quiz_attempts WHERE quiz = '$modform->instance' AND NOT (userid = '$USER->id') LIMIT 1")){
|
||||
// one column layout with table of questions used in this quiz
|
||||
print_header_simple($strediting, '',
|
||||
"<a href=\"index.php?id=$course->id\">$strquizzes</a>".
|
||||
" -> <a href=\"view.php?q=$modform->instance\">$modform->name</a>".
|
||||
" -> $strediting");
|
||||
print_simple_box_start("center");
|
||||
print_heading($modform->name);
|
||||
$attemptcount = count_records_select("quiz_attempts", "quiz = '$modform->instance' AND timefinish > 0");
|
||||
|
||||
$strviewallanswers = get_string("viewallanswers","quiz",$attemptcount);
|
||||
$strattemptsexist = get_string("attemptsexist","quiz");
|
||||
$usercount = count_records("quiz_grades", "quiz", "$modform->instance");
|
||||
$strusers = get_string("users");
|
||||
if (! $cm = get_coursemodule_from_instance("quiz", $modform->instance, $course->id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
notify("$strattemptsexist<br /><a href=\"report.php?id=$cm->id\">$strviewallanswers ($usercount $strusers)</a>");
|
||||
|
||||
$sumgrades = quiz_print_question_list($modform->questions, $modform->grades, false);
|
||||
if (!set_field('quiz', 'sumgrades', $sumgrades, 'id', $modform->instance)) {
|
||||
error('Failed to set sumgrades');
|
||||
}
|
||||
|
||||
print_simple_box_end();
|
||||
print_continue('view.php?q='.$modform->instance);
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($modform->instance)) {
|
||||
// one column layout for non-quiz-specific editing page
|
||||
@ -220,18 +250,8 @@
|
||||
error('Failed to set sumgrades');
|
||||
}
|
||||
|
||||
if ($attemptcount = count_records_select("quiz_attempts", "quiz = '$modform->instance' AND timefinish > 0")) {
|
||||
$strviewallanswers = get_string("viewallanswers","quiz",$attemptcount);
|
||||
$strattemptsexist = get_string("attemptsexist","quiz");
|
||||
$usercount = count_records("quiz_grades", "quiz", "$modform->instance");
|
||||
$strusers = get_string("users");
|
||||
if (! $cm = get_coursemodule_from_instance("quiz", $modform->instance, $course->id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
notify("$strattemptsexist<br /><a href=\"report.php?id=$cm->id\">$strviewallanswers ($usercount $strusers)</a>");
|
||||
}
|
||||
|
||||
print_simple_box_end();
|
||||
print_continue('view.php?q='.$modform->instance);
|
||||
echo '</td><td valign="top" width="50%">';
|
||||
}
|
||||
// non-quiz-specific column
|
||||
@ -246,15 +266,15 @@
|
||||
quiz_print_cat_question_list($modform->category,
|
||||
isset($modform->instance), $modform->recurse, $page, $perpage);
|
||||
print_simple_box_end();
|
||||
|
||||
echo '</td></tr>';
|
||||
echo '</table>';
|
||||
|
||||
if (!isset($modform->instance)) {
|
||||
print_continue("index.php?id=$modform->course");
|
||||
} else {
|
||||
print_continue('view.php?q='.$modform->instance);
|
||||
}
|
||||
echo '</td></tr>';
|
||||
echo '</table>';
|
||||
|
||||
|
||||
|
||||
print_footer($course);
|
||||
?>
|
||||
|
@ -1132,7 +1132,7 @@ function quiz_gradesmenu_options($defaultgrade) {
|
||||
return $gradesmenu;
|
||||
}
|
||||
|
||||
function quiz_print_question_list($questionlist, $grades) {
|
||||
function quiz_print_question_list($questionlist, $grades, $allowdelete=true) {
|
||||
// Prints a list of quiz questions in a small layout form with knobs
|
||||
// returns sum of maximum grades
|
||||
// $questionlist is comma-separated list
|
||||
@ -1212,8 +1212,10 @@ function quiz_print_question_list($questionlist, $grades) {
|
||||
if ($canedit) {
|
||||
echo "<a title=\"$stredit\" href=\"question.php?id=$qnum\">
|
||||
<img src=\"../../pix/t/edit.gif\" border=\"0\" alt=\"$stredit\" /></a> ";
|
||||
echo "<a title=\"$strdelete\" href=\"edit.php?delete=$qnum&sesskey=$USER->sesskey\">
|
||||
<img src=\"../../pix/t/delete.gif\" border=\"0\" alt=\"$strdelete\" /></a> ";
|
||||
if ($allowdelete) {
|
||||
echo "<a title=\"$strdelete\" href=\"edit.php?delete=$qnum&sesskey=$USER->sesskey\">
|
||||
<img src=\"../../pix/t/delete.gif\" border=\"0\" alt=\"$strdelete\" /></a> ";
|
||||
}
|
||||
echo "<a title=\"$strpreview\" href=\"#\" onClick=\"openpopup('/mod/quiz/preview.php?id=$qnum','$strpreview','scrollbars=yes,resizable=yes,width=700,height=480', false)\">
|
||||
<img src=\"../../pix/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /></a>";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user