Skip to content

Commit

Permalink
"MDL-14129, fix print_error"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Jun 12, 2008
1 parent eb7687e commit 1858ba0
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 82 deletions.
2 changes: 1 addition & 1 deletion mod/lesson/action/addbranchtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions mod/lesson/action/addcluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
}

Expand All @@ -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"
Expand All @@ -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");
?>
?>
14 changes: 7 additions & 7 deletions mod/lesson/action/addendofbranch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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"
Expand All @@ -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');
Expand Down
12 changes: 6 additions & 6 deletions mod/lesson/action/addendofcluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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");
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
4 changes: 2 additions & 2 deletions mod/lesson/action/confirmdelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +20,7 @@
echo "<p align=\"center\">\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."<br />\n";
}
Expand Down
6 changes: 3 additions & 3 deletions mod/lesson/action/editpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions mod/lesson/action/insertpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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');
}
}
}
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions mod/lesson/action/move.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<center><table cellpadding=\"5\" border=\"1\">\n";
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions mod/lesson/action/updatepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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');
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/backuplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function backup_lesson_pages ($bf, $preferences, $lessonid) {
// 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
Expand Down
Loading

0 comments on commit 1858ba0

Please sign in to comment.