$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) {
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;
$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');
}
}
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"
$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
+?>
// 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) {
$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"
$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');
// 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
$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"
$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");
$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
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";
}
$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);
}
$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
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);
$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 {
$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
$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');
}
}
}
}
$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) {
}
$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) {
$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 {
$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";
}
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
$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
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
$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
}
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
if (!$newanswerid) {
- print_error("Update page: answer record not inserted");
+ print_error('cannotinsertanswer', 'lesson');
}
}
} else {
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 {
$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');
}
}
}
// 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
$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 {
$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
$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');
}
}
}
case 'add':
// Ensure that we came from view.php
if (!confirm_sesskey() or !data_submitted()) {
- print_error('Incorrect Form Data');
+ print_error('invalidformdata');
}
break;
}
$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 *
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
$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
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;
}
print_footer($course);
-?>
\ No newline at end of file
+?>
include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php');
break;
default:
- print_error("Fatal Error: Unknown action\n");
+ print_error('unknowaction');
}
print_footer($course);
$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
}
else {
- print_error("Fatal Error: Unknown Action: ".$action."\n");
+ print_error('unknowaction');
}
/// Finish the page
// 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) {
}
// 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)) {
$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');
$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');
}
}
}
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
$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
break;
}
} else {
- print_error('Navigation: No answers on EOB');
+ print_error('cannotfindanswer', 'lesson');
}
}
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
}
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');
}
}
$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);
}
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');
}
}
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 {
$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");