"MDL-14129, fix print_error"

This commit is contained in:
dongsheng
2008-05-14 08:37:38 +00:00
parent d7bdb1c2ea
commit d89ec019db
3 changed files with 16 additions and 9 deletions
+9 -9
View File
@@ -1025,7 +1025,7 @@ function save_question_session(&$question, &$state) {
$session->sumpenalty = $state->sumpenalty;
$session->manualcomment = $state->manualcomment;
if (!insert_record('question_sessions', $session)) {
print_error('Could not insert entry in question_sessions');
print_error('cannotinsert', 'question');
}
} else {
$session->newest = $state->id;
@@ -1102,7 +1102,7 @@ function question_extract_responses($questions, $formdata, $defaultevent=QUESTIO
if (false !== ($quid = question_get_id_from_name_prefix($key))) {
// check if this is a valid id
if (!isset($questions[$quid])) {
print_error('Form contained question that is not in questionids');
print_error('formquestionnotinids', 'question');
}
// Remove the name prefix from the name
@@ -1511,7 +1511,7 @@ function get_question_image($question) {
$img = '';
if (!$category = get_record('question_categories', 'id', $question->category)){
print_error('invalid category id '.$question->category);
print_error('invalidcategory');
}
$coursefilesdir = get_filesdir_from_context(get_context_instance_by_id($category->contextid));
@@ -1555,7 +1555,7 @@ function question_process_comment($question, &$state, &$attempt, $comment, $grad
$comment = trim($comment);
$state->manualcomment = $comment;
if (!set_field('question_sessions', 'manualcomment', $comment, 'attemptid', $attempt->uniqueid, 'questionid', $question->id)) {
print_error("Cannot save comment");
print_error('cannotsavecomment');
}
// Update the attempt if the score has changed.
@@ -1563,7 +1563,7 @@ function question_process_comment($question, &$state, &$attempt, $comment, $grad
$attempt->sumgrades = $attempt->sumgrades - $state->last_graded->grade + $grade;
$attempt->timemodified = time();
if (!update_record('quiz_attempts', $attempt)) {
print_error('Failed to save the current quiz attempt!');
print_error('cannotsavequiz');
}
}
@@ -1639,7 +1639,7 @@ function question_new_attempt_uniqueid($modulename='quiz') {
$attempt = new stdClass;
$attempt->modulename = $modulename;
if (!$id = insert_record('question_attempts', $attempt)) {
print_error('Could not create new entry in question_attempts table');
print_error('cannotcreate', 'question');
}
return $id;
}
@@ -1883,7 +1883,7 @@ function question_make_default_categories($contexts) {
// If it already exists, just return it.
foreach ($contexts as $key => $context) {
if (!$categoryrs = get_recordset_select("question_categories", "contextid = '{$context->id}'", 'sortorder, name', '*', '', 1)) {
print_error('error getting category record');
print_error('cannotgetcats');
} else {
if (!$category = rs_fetch_record($categoryrs)){
// Otherwise, we need to make one
@@ -1896,7 +1896,7 @@ function question_make_default_categories($contexts) {
$category->sortorder = 999; // By default, all categories get this number, and are sorted alphabetically.
$category->stamp = make_unique_id_code();
if (!$category->id = insert_record('question_categories', $category)) {
print_error('Error creating a default category for context '.print_context_name($context));
print_error('cannotcreatedefaultcat', '', '', print_context_name($context));
}
}
}
@@ -2309,7 +2309,7 @@ function get_filesdir_from_context($context){
$courseid = SITEID;
break;
default :
print_error('Unsupported contextlevel in category record!');
print_error('invalidcontext');
}
return $courseid;
}