Skip to content

Commit

Permalink
"MDL-14129, fixed hardcoded print_header in quiz module"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Sep 25, 2008
1 parent 2aa98ea commit a6344df
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
5 changes: 5 additions & 0 deletions lang/en_utf8/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,18 @@
$string['cannotfindprevattempt'] = 'Cannot find previous attempt to build on.';
$string['cannotfindquestionregard'] = 'Failed to get questions for regrading!';
$string['cannotinsert'] = 'Cannot insert question';
$string['cannotinsertrandomquestion'] = 'Could not insert new random question!';
$string['cannotloadtypeinfo'] = 'Unable to load questiontype specific question information';
$string['cannotloadquestion'] = 'Could not load question options';
$string['cannotopen'] = 'Cannot open export file ($a)';
$string['cannotread'] = 'Cannot read import file (or file is empty)';
$string['cannotrestore'] = 'Could not restore question sessions';
$string['cannotreviewopen'] = 'You cannot review this attempt, it is still open.';
$string['cannotsavelayout'] = 'Could not save layout';
$string['cannotsavequestion'] = 'Cannot save question list';
$string['cannotsavenumberofquestion'] = 'Could not save number of questions per page';
$string['cannotsetgrade'] = 'Could not set a new maximum grade for the quiz';
$string['cannotsetsumgrades'] = 'Failed to set sumgrades';
$string['cannotwrite'] = 'Cannot write to export file ($a)';
$string['caseno'] = 'No, case is unimportant';
$string['casesensitive'] = 'Case sensitivity';
Expand Down
3 changes: 3 additions & 0 deletions lang/en_utf8/quiz_grading.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// quiz_grading.php - created with Moodle 1.7 beta + (2006101003)


$string['cannotloadquestioninfo'] = 'Unable to load questiontype specific question information';
$string['essayonly'] = 'The following questions need to be graded manually';
$string['invalidquestionid'] = 'Gradeable question with id $a not found';
$string['invalidattemptid'] = 'No such attempt ID exists';
$string['grading'] = 'Manual grading';
$string['gradingreport'] = 'Manual grading report';
$string['gradeall'] = 'Grade all $a attempts';
Expand Down
22 changes: 11 additions & 11 deletions mod/quiz/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){

// Get the course object and related bits.
if (! $course = $DB->get_record('course', array('id' => $quiz->course))) {
error("This course doesn't exist");
print_error('invalidcourseid', 'error');
}

// Log this visit.
Expand Down Expand Up @@ -141,7 +141,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){
// Avoid duplicate page breaks
$quiz->questions = str_replace(',0,0', ',0', $quiz->questions);
if (!$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->instance))) {
error('Could not save question list');
print_error('cannotsavequestion', 'quiz');
}
$significantchangemade = true;
}
Expand All @@ -158,7 +158,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){
// Avoid duplicate page breaks
$quiz->questions = str_replace(',0,0', ',0', $quiz->questions);
if (!$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->instance))) {
error('Could not save question list');
print_error('cannotsavequestion', 'quiz');
}
$significantchangemade = true;
}
Expand Down Expand Up @@ -186,7 +186,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){
$randomcount = required_param('randomcount', PARAM_INT);
// load category
if (! $category = $DB->get_record('question_categories', array('id' => $categoryid))) {
error('Category ID is incorrect');
print_error('invalidcategoryid', 'error');
}
$catcontext = get_context_instance_by_id($category->contextid);
require_capability('moodle/question:useall', $catcontext);
Expand Down Expand Up @@ -221,7 +221,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){
$question->qtype = RANDOM;
$question = $QTYPES[RANDOM]->save_question($question, $form, $course);
if(!isset($question->id)) {
error('Could not insert new random question!');
print_error('cannotinsertrandomquestion', 'quiz');
}
quiz_add_quiz_question($question->id, $quiz);
}
Expand All @@ -234,12 +234,12 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){
if ($questionsperpage != $quiz->questionsperpage) {
$quiz->questionsperpage = $questionsperpage;
if (!$DB->set_field('quiz', 'questionsperpage', $quiz->questionsperpage, array('id' => $quiz->id))) {
error('Could not save number of questions per page');
print_error('cannotsavenumberofquestion', 'quiz');
}
}
$quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage);
if (!$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id))) {
error('Could not save layout');
print_error('cannotsavelayout', 'quiz');
}
$significantchangemade = true;
}
Expand Down Expand Up @@ -288,15 +288,15 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){
$quiz->questions = str_replace(',0,0', ',0', $quiz->questions);
}
if (!$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->instance))) {
error('Could not save question list');
print_error('cannotsavequestion', 'quiz');
}
}

// If rescaling is required save the new maximum
$maxgrade = optional_param('maxgrade', -1, PARAM_NUMBER);
if ($maxgrade >= 0) {
if (!quiz_set_grade($maxgrade, $quiz)) {
error('Could not set a new maximum grade for the quiz');
print_error('cannotsetgrade', 'quiz');
}
}
$significantchangemade = true;
Expand Down Expand Up @@ -342,7 +342,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){

$sumgrades = quiz_print_question_list($quiz, $thispageurl, false, $quiz_showbreaks, $quiz_reordertool);
if (!$DB->set_field('quiz', 'sumgrades', $sumgrades, array('id' => $quiz->instance))) {
error('Failed to set sumgrades');
print_error('cannotsetsumgrades', 'quiz');
}

print_box_end();
Expand All @@ -369,7 +369,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid){

$sumgrades = quiz_print_question_list($quiz, $thispageurl, true, $quiz_showbreaks, $quiz_reordertool);
if (!$DB->set_field('quiz', 'sumgrades', $sumgrades, array('id' => $quiz->instance))) {
error('Failed to set sumgrades');
print_error('cannotsetsumgrades', 'quiz');
}

print_box_end();
Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/report/grading/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function display($quiz, $cm, $course) {

if (!empty($questionid)) {
if (!isset($gradeableqs[$questionid])){
error("Gradeable question with id $questionid not found");
print_error('invalidquestionid', 'quiz_grading', '', $questionid);
} else {
$question =& $gradeableqs[$questionid];
}
Expand All @@ -101,7 +101,7 @@ function display($quiz, $cm, $course) {
// We need to add additional questiontype specific information to
// the question objects.
if (!get_question_options($questions)) {
error("Unable to load questiontype specific question information");
print_error('cannotloadquestioninfo', 'quiz_grading');
}
// This will have extended the question object so that it now holds
// all the information about the questions that may be needed later.
Expand All @@ -125,7 +125,7 @@ function display($quiz, $cm, $course) {
"WHERE uniqueid = ? AND " .
"userid $usql AND " .
"quiz=?", array_merge(array($uniqueid), $params, array($quiz->id)))){
error('No such attempt ID exists');
print_error('invalidattemptid', 'quiz_grading');
}

// Load the state for this attempt (The questions array was created earlier)
Expand Down

0 comments on commit a6344df

Please sign in to comment.