From 1858ba0c6745d7f6ba53941236c81881669a64e6 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Thu, 12 Jun 2008 11:52:15 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- mod/lesson/action/addbranchtable.php | 2 +- mod/lesson/action/addcluster.php | 14 +++++----- mod/lesson/action/addendofbranch.php | 14 +++++----- mod/lesson/action/addendofcluster.php | 12 ++++----- mod/lesson/action/confirmdelete.php | 4 +-- mod/lesson/action/editpage.php | 6 ++--- mod/lesson/action/insertpage.php | 20 +++++++------- mod/lesson/action/move.php | 4 +-- mod/lesson/action/updatepage.php | 16 +++++------ mod/lesson/backuplib.php | 2 +- mod/lesson/format.php | 10 +++---- mod/lesson/highscores.php | 14 +++++----- mod/lesson/lesson.php | 2 +- mod/lesson/report.php | 6 ++--- mod/lesson/view.php | 38 +++++++++++++-------------- 15 files changed, 82 insertions(+), 82 deletions(-) diff --git a/mod/lesson/action/addbranchtable.php b/mod/lesson/action/addbranchtable.php index e8f1148cb0..29e914b697 100644 --- a/mod/lesson/action/addbranchtable.php +++ b/mod/lesson/action/addbranchtable.php @@ -20,7 +20,7 @@ $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); if (!optional_param('firstpage', 0, PARAM_INT)) { if (!$apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0))) { - print_error("Add page: first page not found"); + print_error('cannotfindfirstpage', 'lesson'); } while (true) { if ($apageid) { diff --git a/mod/lesson/action/addcluster.php b/mod/lesson/action/addcluster.php index e61fdf7530..e2ed47da33 100644 --- a/mod/lesson/action/addcluster.php +++ b/mod/lesson/action/addcluster.php @@ -16,11 +16,11 @@ if ($pageid == 0) { if (!$page = $DB->get_record("lesson_pages", array("prevpageid" => 0, "lessonid" => $lesson->id))) { - print_error("Error: Add cluster: page record not found"); + print_error('cannotfindpagerecord', 'lesson'); } } else { if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) { - print_error("Error: Add cluster: page record not found"); + print_error('cannotfindpagerecord', 'lesson'); } } $newpage = new stdClass; @@ -36,12 +36,12 @@ $newpage->title = get_string("clustertitle", "lesson"); $newpage->contents = get_string("clustertitle", "lesson"); if (!$newpageid = $DB->insert_record("lesson_pages", $newpage)) { - print_error("Insert page: new page not inserted"); + print_error('cannotinsertpage', 'lesson'); } // update the linked list... if ($pageid != 0) { if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid))) { - print_error("Add cluster: unable to update link"); + print_error('cannotupdatelink', 'lesson'); } } @@ -51,7 +51,7 @@ if ($page->nextpageid) { // the new page is not the last page if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid))) { - print_error("Insert page: unable to update previous link"); + print_error('cannotupdatelink', 'lesson'); } } // ..and the single "answer" @@ -61,8 +61,8 @@ $newanswer->timecreated = $timenow; $newanswer->jumpto = LESSON_CLUSTERJUMP; if(!$newanswerid = $DB->insert_record("lesson_answers", $newanswer)) { - print_error("Add cluster: answer record not inserted"); + print_error('cannotinsertanswer', 'lesson'); } lesson_set_message(get_string('addedcluster', 'lesson'), 'notifysuccess'); redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); -?> \ No newline at end of file +?> diff --git a/mod/lesson/action/addendofbranch.php b/mod/lesson/action/addendofbranch.php index 3839b9befe..1419094a68 100644 --- a/mod/lesson/action/addendofbranch.php +++ b/mod/lesson/action/addendofbranch.php @@ -15,17 +15,17 @@ // the new page is not the first page (end of branch always comes after an existing page) if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) { - print_error("Add end of branch: page record not found"); + print_error('cannotfindpagerecord', 'lesson'); } // chain back up to find the (nearest branch table) $btpageid = $pageid; if (!$btpage = $DB->get_record("lesson_pages", array("id" => $btpageid))) { - print_error("Add end of branch: btpage record not found"); + print_error('cannotfindpagerecord', 'lesson'); } while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) { $btpageid = $btpage->prevpageid; if (!$btpage = $DB->get_record("lesson_pages", array("id" => $btpageid))) { - print_error("Add end of branch: btpage record not found"); + print_error('cannotfindpagerecord', 'lesson'); } } if ($btpage->qtype == LESSON_BRANCHTABLE) { @@ -38,16 +38,16 @@ $newpage->title = get_string("endofbranch", "lesson"); $newpage->contents = get_string("endofbranch", "lesson"); if (!$newpageid = $DB->insert_record("lesson_pages", $newpage)) { - print_error("Insert page: new page not inserted"); + print_error('cannotinsertpage', 'lesson'); } // update the linked list... if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid))) { - print_error("Add end of branch: unable to update link"); + print_error('cannotupdatelink', 'lesson'); } if ($page->nextpageid) { // the new page is not the last page if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid))) { - print_error("Insert page: unable to update previous link"); + print_error('cannotupdatelink', 'lesson'); } } // ..and the single "answer" @@ -57,7 +57,7 @@ $newanswer->timecreated = $timenow; $newanswer->jumpto = $btpageid; if(!$newanswerid = $DB->insert_record("lesson_answers", $newanswer)) { - print_error("Add end of branch: answer record not inserted"); + print_error('cannotinsertanswer', 'lesson'); } lesson_set_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess'); diff --git a/mod/lesson/action/addendofcluster.php b/mod/lesson/action/addendofcluster.php index 9656fe92d9..be6a346a8f 100644 --- a/mod/lesson/action/addendofcluster.php +++ b/mod/lesson/action/addendofcluster.php @@ -15,7 +15,7 @@ // the new page is not the first page (end of cluster always comes after an existing page) if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) { - print_error("Error: Could not find page"); + print_error('cannotfindpages', 'lesson'); } // could put code in here to check if the user really can insert an end of cluster @@ -29,16 +29,16 @@ $newpage->title = get_string("endofclustertitle", "lesson"); $newpage->contents = get_string("endofclustertitle", "lesson"); if (!$newpageid = $DB->insert_record("lesson_pages", $newpage)) { - print_error("Insert page: end of cluster page not inserted"); + print_error('cannotinsertpage', 'lesson'); } // update the linked list... if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid))) { - print_error("Add end of cluster: unable to update link"); + print_error('cannotupdatelink', 'lesson'); } if ($page->nextpageid) { // the new page is not the last page if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid))) { - print_error("Insert end of cluster: unable to update previous link"); + print_error('cannotupdatelink', 'lesson'); } } // ..and the single "answer" @@ -48,7 +48,7 @@ $newanswer->timecreated = $timenow; $newanswer->jumpto = LESSON_NEXTPAGE; if(!$newanswerid = $DB->insert_record("lesson_answers", $newanswer)) { - print_error("Add end of cluster: answer record not inserted"); + print_error('cannotinsertanswer', 'lesson'); } lesson_set_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess'); - redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); \ No newline at end of file + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); diff --git a/mod/lesson/action/confirmdelete.php b/mod/lesson/action/confirmdelete.php index 70a4b11ca6..6b1b10d6ba 100644 --- a/mod/lesson/action/confirmdelete.php +++ b/mod/lesson/action/confirmdelete.php @@ -10,7 +10,7 @@ $pageid = required_param('pageid', PARAM_INT); if (!$thispage = $DB->get_record("lesson_pages", array ("id" => $pageid))) { - print_error("Confirm delete: the page record not found"); + print_error('cannotfindpages', 'lesson'); } print_heading(get_string("deletingpage", "lesson", format_string($thispage->title))); // print the jumps to this page @@ -20,7 +20,7 @@ echo "

\n"; foreach ($answers as $answer) { if (!$title = $DB->get_field("lesson_pages", "title", array("id" => $answer->pageid))) { - print_error("Confirm delete: page title not found"); + print_error('cannotfindpagetitle', 'lesson'); } echo $title."
\n"; } diff --git a/mod/lesson/action/editpage.php b/mod/lesson/action/editpage.php index c431a82aad..432bd6af69 100644 --- a/mod/lesson/action/editpage.php +++ b/mod/lesson/action/editpage.php @@ -12,7 +12,7 @@ $redirect = optional_param('redirect', '', PARAM_ALPHA); if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) { - print_error("Edit page: page record not found"); + print_error('cannotfindpages', 'lesson'); } $page->qtype = optional_param('qtype', $page->qtype, PARAM_INT); @@ -34,12 +34,12 @@ } $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); if (!$apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0))) { - print_error("Edit page: first page not found"); + print_error('cannotfindfirstpage', 'lesson'); } while (true) { if ($apageid) { if (!$apage = $DB->get_record("lesson_pages", array("id" => $apageid))) { - print_error("Edit page: apage record not found"); + print_error('cannotfindpages', 'lesson'); } // removed != LESSON_ENDOFBRANCH... if (trim($page->title)) { // ...nor nuffin pages diff --git a/mod/lesson/action/insertpage.php b/mod/lesson/action/insertpage.php index 819e46704c..63a6d3b4fd 100644 --- a/mod/lesson/action/insertpage.php +++ b/mod/lesson/action/insertpage.php @@ -21,7 +21,7 @@ if ($form->pageid) { // the new page is not the first page if (!$page = $DB->get_record("lesson_pages", array("id" => $form->pageid))) { - print_error("Insert page: page record not found"); + print_error('cannotfindpages', 'lesson'); } $newpage->lessonid = clean_param($lesson->id, PARAM_INT); $newpage->prevpageid = clean_param($form->pageid, PARAM_INT); @@ -48,16 +48,16 @@ $newpage->title = $newpage->title; $newpageid = $DB->insert_record("lesson_pages", $newpage); if (!$newpageid) { - print_error("Insert page: new page not inserted"); + print_error('cannotinsertpage', 'lesson'); } // update the linked list (point the previous page to this new one) if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $newpage->prevpageid))) { - print_error("Insert page: unable to update next link"); + print_error('cannotupdatelink', 'lesson'); } if ($page->nextpageid) { // new page is not the last page if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid))) { - print_error("Insert page: unable to update previous link"); + print_error('cannotupdatelink', 'lesson'); } } } else { @@ -91,7 +91,7 @@ $newpage->title = $newpage->title; $newpageid = $DB->insert_record("lesson_pages", $newpage); if (!$newpageid) { - print_error("Insert page: new first page not inserted"); + print_error('cannotinsertpage', 'lesson'); } } else { // there are existing pages put this at the start @@ -120,11 +120,11 @@ $newpage->title = $newpage->title; $newpageid = $DB->insert_record("lesson_pages", $newpage); if (!$newpageid) { - print_error("Insert page: first page not inserted"); + print_error('cannotfindfirstpage', 'lesson'); } // update the linked list if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $newpage->nextpageid))) { - print_error("Insert page: unable to update link"); + print_error('cannotupdatelink', 'lesson'); } } } @@ -141,7 +141,7 @@ } $newanswerid = $DB->insert_record("lesson_answers", $newanswer); if (!$newanswerid) { - print_error("Insert Page: answer record not inserted"); + print_error('cannotinsertanswer', 'lesson'); } } else { if ($form->qtype == LESSON_MATCHING) { @@ -167,7 +167,7 @@ } $newanswerid = $DB->insert_record("lesson_answers", $newanswer); if (!$newanswerid) { - print_error("Insert Page: answer record $i not inserted"); + print_error('cannotinsertanswer', 'lesson'); } } else { if ($form->qtype == LESSON_MATCHING) { @@ -177,7 +177,7 @@ $newanswer->timecreated = $timenow; $newanswerid = $DB->insert_record("lesson_answers", $newanswer); if (!$newanswerid) { - print_error("Insert Page: answer record $i not inserted"); + print_error('cannotinsertanswer', 'lesson'); } } } else { diff --git a/mod/lesson/action/move.php b/mod/lesson/action/move.php index 518f81c5fe..217528f0c5 100644 --- a/mod/lesson/action/move.php +++ b/mod/lesson/action/move.php @@ -13,7 +13,7 @@ $params = array ("lessonid" => $lesson->id, "prevpageid" => 0); if (!$page = $DB->get_record_select("lesson_pages", "lessonid = :lessonid AND prevpageid = :prevpageid", $params)) { - print_error("Move: first page not found"); + print_error('cannotfindfirstpage', 'lesson'); } echo "

\n"; @@ -30,7 +30,7 @@ } if ($page->nextpageid) { if (!$page = $DB->get_record("lesson_pages", array("id" => $page->nextpageid))) { - print_error("Teacher view: Next page not found!"); + print_error('cannotfindnextpage', 'lesson'); } } else { // last page reached diff --git a/mod/lesson/action/updatepage.php b/mod/lesson/action/updatepage.php index d7d26dccc9..576c740bed 100644 --- a/mod/lesson/action/updatepage.php +++ b/mod/lesson/action/updatepage.php @@ -48,7 +48,7 @@ $page->title = $page->title; if (!$DB->update_record("lesson_pages", $page)) { - print_error("Update page: page not updated"); + print_error('cannotupdatepage', 'lesson'); } if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_ESSAY || $page->qtype == LESSON_CLUSTER || $page->qtype == LESSON_ENDOFCLUSTER) { // there's just a single answer with a jump @@ -67,13 +67,13 @@ foreach ($answers as $answer) { if ($answer->id != clean_param($form->answerid[0], PARAM_INT)) { if (!$DB->delete_records("lesson_answers", array("id" => $answer->id))) { - print_error("Update page: unable to delete answer record"); + print_error('cannotdeleteanswer', 'lesson'); } } } } if (!$DB->update_record("lesson_answers", $oldanswer)) { - print_error("Update page: EOB not updated"); + print_error('cannotupdateanswer', 'lesson'); } } else { // it's an "ordinary" page @@ -108,7 +108,7 @@ $oldanswer->score = clean_param($form->score[$i], PARAM_INT); } if (!$DB->update_record("lesson_answers", $oldanswer)) { - print_error("Update page: answer $i not updated"); + print_error('cannotupdateanswer', 'lesson'); } } else { // it's a new answer @@ -134,7 +134,7 @@ } $newanswerid = $DB->insert_record("lesson_answers", $newanswer); if (!$newanswerid) { - print_error("Update page: answer record not inserted"); + print_error('cannotinsertanswer', 'lesson'); } } } else { @@ -143,7 +143,7 @@ if ($form->answerid[$i]) { // need to delete blanked out answer if (!$DB->delete_records("lesson_answers", array("id" => clean_param($form->answerid[$i], PARAM_INT)))) { - print_error("Update page: unable to delete answer record"); + print_error('cannotdeleteanswer', 'lesson'); } } } else { @@ -160,13 +160,13 @@ $oldanswer->timemodified = $timenow; $oldanswer->answer = NULL; if (!$DB->update_record("lesson_answers", $oldanswer)) { - print_error("Update page: answer $i not updated"); + print_error('cannotupdateanswer', 'lesson'); } } } elseif (!empty($form->answerid[$i])) { // need to delete blanked out answer if (!$DB->delete_records("lesson_answers", array("id" => clean_param($form->answerid[$i], PARAM_INT)))) { - print_error("Update page: unable to delete answer record"); + print_error('cannotdeleteanswer', 'lesson'); } } } diff --git a/mod/lesson/backuplib.php b/mod/lesson/backuplib.php index ee73d3e82b..4f4a2e8be0 100644 --- a/mod/lesson/backuplib.php +++ b/mod/lesson/backuplib.php @@ -176,7 +176,7 @@ // move to the next (logical) page if ($page->nextpageid) { if (!$page = $DB->get_record("lesson_pages", array ("id" => $page->nextpageid))) { - print_error("Lesson Backup: Next page not found!"); + print_error('cannotfindnextpage', 'lesson'); } } else { // last page reached diff --git a/mod/lesson/format.php b/mod/lesson/format.php index 7891a8eff0..eb3573236f 100644 --- a/mod/lesson/format.php +++ b/mod/lesson/format.php @@ -94,11 +94,11 @@ class qformat_default { $newpage->nextpageid = $page->nextpageid; // insert the page and reset $pageid if (!$newpageid = $DB->insert_record("lesson_pages", $newpage)) { - print_error("Format: Could not insert new page!"); + print_error('cannotinsertpage', 'lesson'); } // update the linked list if (!$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid))) { - print_error("Format: unable to update link"); + print_error('cannotupdateanswer', 'lesson'); } } else { @@ -111,7 +111,7 @@ class qformat_default { $newpage->nextpageid = 0; // this is the only page $newpageid = $DB->insert_record("lesson_pages", $newpage); if (!$newpageid) { - print_error("Insert page: new first page not inserted"); + print_error('cannotinsertpage', 'lesson'); } } else { // there are existing pages put this at the start @@ -119,11 +119,11 @@ class qformat_default { $newpage->nextpageid = $page->id; $newpageid = $DB->insert_record("lesson_pages", $newpage); if (!$newpageid) { - print_error("Insert page: first page not inserted"); + print_error('cannotinsertpage', 'lesson'); } // update the linked list if (!$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->id))) { - print_error("Insert page: unable to update link"); + print_error('cannotupdatelink', 'lesson'); } } } diff --git a/mod/lesson/highscores.php b/mod/lesson/highscores.php index 9ef4e8bc46..25ff04d325 100644 --- a/mod/lesson/highscores.php +++ b/mod/lesson/highscores.php @@ -26,7 +26,7 @@ case 'add': // Ensure that we came from view.php if (!confirm_sesskey() or !data_submitted()) { - print_error('Incorrect Form Data'); + print_error('invalidformdata'); } break; @@ -55,7 +55,7 @@ } $params = array ("lessonid" => $lesson->id, "userid" => $USER->id); if (!$grades = $DB->get_records_select('lesson_grades', "lessonid = :lessonid", $params, 'completed')) { - print_error('Error: could not find grades'); + print_error('cannotfindfirstgrade', 'lesson'); } if (!$newgrade = $DB->get_record_sql("SELECT * @@ -63,12 +63,12 @@ WHERE lessonid = :lessonid AND userid = :userid ORDER BY completed DESC", $params, true)) { - print_error('Error: could not find newest grade'); + print_error('cannotfindnewestgrade', 'lesson'); } // Check for multiple submissions if ($DB->record_exists('lesson_high_scores', array('gradeid' => $newgrade->id))) { - print_error('Only one posting per grade'); + print_error('onpostperpage', 'lesson'); } // Find out if we need to delete any records @@ -117,7 +117,7 @@ $newhighscore->nickname = $name; if (!$DB->insert_record('lesson_high_scores', $newhighscore)) { - print_error("Insert of new high score Failed!"); + print_error('cannotinserthighscore', 'lesson'); } // Log it @@ -126,7 +126,7 @@ lesson_set_message(get_string('postsuccess', 'lesson'), 'notifysuccess'); redirect("$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id&link=1"); } else { - print_error('Something is wrong with the form data'); + print_error('invalidformdata'); } break; } @@ -208,4 +208,4 @@ print_footer($course); -?> \ No newline at end of file +?> diff --git a/mod/lesson/lesson.php b/mod/lesson/lesson.php index f4c0e19442..9f3f338f3a 100644 --- a/mod/lesson/lesson.php +++ b/mod/lesson/lesson.php @@ -55,7 +55,7 @@ include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php'); break; default: - print_error("Fatal Error: Unknown action\n"); + print_error('unknowaction'); } print_footer($course); diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 43e1fcff21..f7eae99f59 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -346,10 +346,10 @@ $try = optional_param('try', NULL, PARAM_INT); if (! $lessonpages = $DB->get_records("lesson_pages", array("lessonid" => $lesson->id))) { - print_error("Could not find Lesson Pages"); + print_error('cannotfindpages', 'lesson'); } if (! $pageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0))) { - print_error("Could not find first page"); + print_error('cannotfindfirstpage', 'lesson'); } // now gather the stats into an object @@ -916,7 +916,7 @@ } else { - print_error("Fatal Error: Unknown Action: ".$action."\n"); + print_error('unknowaction'); } /// Finish the page diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 7b927382b5..fb45236cdb 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -254,7 +254,7 @@ // get the first page if (!$firstpageid = $DB->get_field('lesson_pages', 'id', array('lessonid' => $lesson->id, 'prevpageid' => 0))) { - print_error('Navigation: first page not found'); + print_error('cannotfindfirstpage', 'lesson'); } lesson_print_header($cm, $course, $lesson); if ($lesson->timed) { @@ -313,7 +313,7 @@ } // start at the first page if (!$pageid = $DB->get_field('lesson_pages', 'id', array('lessonid' => $lesson->id, 'prevpageid' => 0))) { - print_error('Navigation: first page not found'); + print_error('cannotfindfirstpage', 'lesson'); } /// This is the code for starting a timed test if(!isset($USER->startlesson[$lesson->id]) && !has_capability('mod/lesson:manage', $context)) { @@ -325,7 +325,7 @@ $startlesson->lessontime = time(); if (!$DB->insert_record('lesson_timer', $startlesson)) { - print_error('Error: could not insert row into lesson_timer table'); + print_error('cannotinserttimer', 'lesson'); } if ($lesson->timed) { lesson_set_message(get_string('maxtimewarning', 'lesson', $lesson->maxtime), 'center'); @@ -344,10 +344,10 @@ $retries = 0; } if (!$DB->delete_records('lesson_attempts', array('userid' => $USER->id, 'lessonid' => $lesson->id, 'retry' => $retries))) { - print_error('Error: could not delete old attempts'); + print_error('cannotdeleteattempt', 'lesson'); } if (!$DB->delete_records('lesson_branch', array('userid' => $USER->id, 'lessonid' => $lesson->id, 'retry' => $retries))) { - print_error('Error: could not delete old seen branches'); + print_error('cannotdeletebranch', 'lesson'); } } } @@ -355,7 +355,7 @@ add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id); if (!$page = $DB->get_record('lesson_pages', array('id' => $pageid))) { - print_error('Navigation: the page record not found'); + print_error('cannotfindpages', 'lesson'); } if ($page->qtype == LESSON_CLUSTER) { //this only gets called when a user starts up a new lesson and the first page is a cluster page @@ -364,14 +364,14 @@ $pageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid); // get new page info if (!$page = $DB->get_record('lesson_pages', array('id' => $pageid))) { - print_error('Navigation: the page record not found'); + print_error('cannotfindpages', 'lesson'); } add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id); } else { // get the next page $pageid = $page->nextpageid; if (!$page = $DB->get_record('lesson_pages', array('id' => $pageid))) { - print_error('Navigation: the page record not found'); + print_error('cannotfindpages', 'lesson'); } } } elseif ($page->qtype == LESSON_ENDOFCLUSTER) { // Check for endofclusters @@ -413,7 +413,7 @@ break; } } else { - print_error('Navigation: No answers on EOB'); + print_error('cannotfindanswer', 'lesson'); } } @@ -431,7 +431,7 @@ if(!has_capability('mod/lesson:manage', $context)) { $params = array ("lessonid" => $lesson->id, "userid" => $USER->id); if (!$timer = $DB->get_records_select('lesson_timer', "lessonid = :lessonid AND userid = :userid", $params, 'starttime')) { - print_error('Error: could not find records'); + print_error('cannotfindtimer', 'lesson'); } else { $timer = array_pop($timer); // this will get the latest start time record } @@ -470,7 +470,7 @@ if (!has_capability('mod/lesson:manage', $context)) { $timer->lessontime = time(); if (!$DB->update_record('lesson_timer', $timer)) { - print_error('Error: could not update lesson_timer table'); + print_error('cannotupdatetimer', 'lesson'); } } @@ -553,7 +553,7 @@ $retries--; $params = array ("lessonid" => $lesson->id, "userid" => $USER->id, "pageid" => $page->id, "retry" => $retries); if (! $attempts = $DB->get_records_select("lesson_attempts", "lessonid = :lessonid AND userid = :userid AND pageid = :pageid AND retry = :retry", $params, "timeseen")) { - print_error("Previous attempt record could not be found!"); + print_error('cannotfindpreattempt', 'lesson'); } $attempt = end($attempts); } @@ -836,14 +836,14 @@ unset($USER->startlesson[$lesson->id]); $params = array ("lessonid" => $lesson->id, "userid" => $USER->id); if (!$timer = $DB->get_records_select('lesson_timer', "lessonid = :lessonid AND userid = :userid", $params, 'starttime')) { - print_error('Error: could not find records'); + print_error('cannotfindtimer', 'lesson'); } else { $timer = array_pop($timer); // this will get the latest start time record } $timer->lessontime = time(); if (!$DB->update_record("lesson_timer", $timer)) { - print_error("Error: could not update lesson_timer table"); + print_error('cannotupdatetimer', 'lesson'); } } @@ -897,21 +897,21 @@ if (isset($USER->modattempts[$lesson->id])) { // if reviewing, make sure update old grade record $params = array ("lessonid" => $lesson->id, "userid" => $USER->id); if (!$grades = $DB->get_records_select("lesson_grades", "lessonid = :lessonid and userid = :userid", $params, "completed")) { - print_error("Could not find Grade Records"); + print_error('cannotfindgrade', 'lesson'); } $oldgrade = end($grades); $grade->id = $oldgrade->id; if (!$update = $DB->update_record("lesson_grades", $grade)) { - print_error("Navigation: grade not updated"); + print_error('cannotupdategrade', 'lesson'); } } else { if (!$newgradeid = $DB->insert_record("lesson_grades", $grade)) { - print_error("Navigation: grade not inserted"); + print_error('cannotinsertgrade', 'lesson'); } } } else { if (!$DB->delete_records("lesson_attempts", array("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $ntries))) { - print_error("Could not delete lesson attempts"); + print_error('cannotdeleteattempt', 'lesson'); } } } else { @@ -924,7 +924,7 @@ $grade->completed = time(); if (!$lesson->practice) { if (!$newgradeid = $DB->insert_record("lesson_grades", $grade)) { - print_error("Navigation: grade not inserted"); + print_error('cannotinsertgrade', 'lesson'); } } echo get_string("eolstudentoutoftimenoanswers", "lesson"); -- 2.39.5