if ($firstpage = $DB->get_record('lesson_pages', array('lessonid' => $lesson->id, 'prevpageid' => 0))) {
if (!$pages = $DB->get_records('lesson_pages', array('lessonid' => $lesson->id))) {
- print_error('Could not find lesson pages');
+ print_error('cannotfindrecords', 'lesson');
}
}
if ($pageid) {
if (!$singlepage = $DB->get_record('lesson_pages', array('id' => $pageid))) {
- print_error('Could not find page ID: '.$pageid);
+ print_error('invalidpageid', 'lesson');
}
}
$attemptid = required_param('attemptid', PARAM_INT);
if (!$attempt = $DB->get_record('lesson_attempts', array('id' => $attemptid))) {
- print_error('Error: could not find attempt');
+ print_error('cannotfindattempt', 'lesson');
}
if (!$page = $DB->get_record('lesson_pages', array('id' => $attempt->pageid))) {
- print_error('Error: could not find lesson page');
+ print_error('cannotfindpages', 'lesson');
}
if (!$user = $DB->get_record('user', array('id' => $attempt->userid))) {
- print_error('Error: could not find users');
+ print_error('cannotfinduser', 'lesson');
}
if (!$answer = $DB->get_record('lesson_answers', array('lessonid' => $lesson->id, 'pageid' => $page->id))) {
- print_error('Error: could not find answer');
+ print_error('cannotfindanswer', 'lesson');
}
break;
case 'update':
$attemptid = required_param('attemptid', PARAM_INT);
if (!$attempt = $DB->get_record('lesson_attempts', array('id' => $attemptid))) {
- print_error('Error: could not find essay');
+ print_error('cannotfindattempt', 'lesson');
}
$params = array ("lessonid" => $lesson->id, "userid" => $attempt->userid);
if (!$grades = $DB->get_records_select('lesson_grades', "lessonid = :lessonid and userid = :userid", $params, 'completed', '*', $attempt->retry, 1)) {
- print_error('Error: could not find grades');
+ print_error('cannotfindgrade', 'lesson');
}
$essayinfo = new stdClass;
$attempt->useranswer = serialize($essayinfo);
if (!$DB->update_record('lesson_attempts', $attempt)) {
- print_error('Could not update essay score');
+ print_error('cannotupdateessayscore', 'lesson');
}
// Get grade information
redirect("$CFG->wwwroot/mod/lesson/essay.php?id=$cm->id");
} else {
- print_error('Something is wrong with the form data');
+ print_error('invalidformdata');
}
break;
case 'email': // Sending an email(s) to a single user or all
if ($userid = optional_param('userid', 0, PARAM_INT)) {
$queryadd = " AND userid = :userid";
if (! $users = $DB->get_records('user', array('id' => $userid))) {
- print_error('Error: could not find users');
+ print_error('cannotfinduser', 'lesson');
}
} else {
$queryadd = '';
WHERE a.lessonid = :lessonid and
u.id = a.userid
ORDER BY u.lastname", $params)) {
- print_error('Error: could not find users');
+ print_error('cannotfinduser', 'lesson');
}
}
// Get lesson pages that are essay
$params = array ("lessonid" => $lesson->id, "qtype" => LESSON_ESSAY);
if (!$pages = $DB->get_records_select('lesson_pages', "lessonid = :lessonid AND qtype = :qtype", $params)) {
- print_error('Error: could not find lesson pages');
+ print_error('cannotfindpages', 'lesson');
}
// Get only the attempts that are in response to essay questions
// Log it
add_to_log($course->id, 'lesson', 'update email essay grade', "essay.php?id=$cm->id", format_string($pages[$attempt->pageid]->title,true).': '.fullname($users[$attempt->userid]), $cm->id);
} else {
- print_error('Emailing Failed');
+ print_error('emailfail');
}
}
}
}
print_footer($course);
-?>
\ No newline at end of file
+?>
$id = required_param('id', PARAM_INT); // Course module ID
if (! $cm = get_coursemodule_from_id('lesson', $id)) {
- print_error("Course Module ID was incorrect");
+ print_error('invalidcoursemodule');
}
if (! $lesson = $DB->get_record("lesson", array("id" => $cm->instance))) {
- print_error("lesson ID was incorrect");
+ print_error('invalidlessonid', 'lesson');
}
if (! $course = $DB->get_record("course", array("id" => $lesson->course))) {
- print_error("Course is misconfigured");
+ print_error('coursemisconf');
}
require_login($course->id, false, $cm);
$pageid = optional_param('pageid', '', PARAM_INT); // Page ID
if (! $cm = get_coursemodule_from_id('lesson', $id)) {
- print_error("Course Module ID was incorrect");
+ print_error('invalidcoursemodule');
}
if (! $course = $DB->get_record("course", array("id" => $cm->course))) {
- print_error("Course is misconfigured");
+ print_error('coursemisconf');
}
if (! $lesson = $DB->get_record("lesson", array("id" => $cm->instance))) {
- print_error("Course module is incorrect");
+ print_error('invalidcoursemodule');
}
} else { // Valid file is found
if (! is_readable("$CFG->dirroot/question/format/$form->format/format.php")) {
- print_error("Format not known ($form->format)");
+ print_error('unknowformat','', '', $form->format);
}
require("format.php"); // Parent class
$format = new $classname();
if (! $format->importpreprocess()) { // Do anything before that we need to
- print_error("Error occurred during pre-processing!");
+ print_error('preprocesserror', 'lesson');
}
if (! $format->importprocess($_FILES['newfile']['tmp_name'], $lesson, $pageid)) { // Process the uploaded file
- print_error("Error occurred during processing!");
+ print_error('processerror', 'lesson');
}
if (! $format->importpostprocess()) { // In case anything needs to be done after
- print_error("Error occurred during post-processing!");
+ print_error('postprocesserror', 'lesson');
}
echo "<hr>";
if ($cmid) {
if (!$cm = get_coursemodule_from_id('lesson', $cmid)) {
- print_error('Course Module ID was incorrect');
+ print_error('invalidcoursemodule');
}
if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
- print_error('Course is misconfigured');
+ print_error('coursemisconf');
}
if (!$lesson = $DB->get_record('lesson', array('id' => $cm->instance))) {
- print_error('Course module is incorrect');
+ print_error('invalidcoursemodule');
}
} else if ($lessonid) {
if (!$lesson = $DB->get_record('lesson', array('id' => $lessonid))) {
- print_error('Course module is incorrect');
+ print_error('invalidcoursemodule');
}
if (!$course = $DB->get_record('course', array('id' => $lesson->course))) {
- print_error('Course is misconfigured');
+ print_error('coursemisconf');
}
if (!$cm = get_coursemodule_from_instance('lesson', $lesson->id, $course->id)) {
- print_error('Course Module ID was incorrect');
+ print_error('invalidcoursemodule');
}
} else {
- print_error('No course module ID or lesson ID were passed');
+ print_error('invalidid', 'lesson');
}
return array($cm, $course, $lesson);
// get the lesson pages
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
- print_error("Error: could not find records in lesson_pages table");
+ print_error('cannotfindrecords', 'lesson');
}
// find the start of the cluster
while ($pageid != 0) { // this condition should not be satisfied... should be a cluster page
// get the lesson pages
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
- print_error("Error: could not find records in lesson_pages table");
+ print_error('cannotfindpages', 'lesson');
}
if ($pageid == LESSON_UNSEENBRANCHPAGE) { // this only happens when a student leaves in the middle of an unseen question within a branch series
$params = array ("lessonid" => $lessonid, "userid" => $userid, "retry" => $retakes);
if (!$seenbranches = $DB->get_records_select("lesson_branch", "lessonid = :lessonid AND userid = :userid AND retry = :retry", $params,
"timeseen DESC")) {
- print_error("Error: could not find records in lesson_branch table");
+ print_error('cannotfindrecords', 'lesson');
}
// get the lesson pages
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
- print_error("Error: could not find records in lesson_pages table");
+ print_error('cannotfindpages', 'lesson');
}
// this loads all the viewed branch tables into $seen untill it finds the branch table with the flag
// get the lesson pages
$params = array ("lessonid" => $lessonid);
if (!$lessonpages = $DB->get_records_select("lesson_pages", "lessonid = :lessonid", $params)) {
- print_error("Error: could not find records in lesson_pages table");
+ print_error('cannotfindpages', 'lesson');
}
// go up the pages till branch table
/// This file to be included so we can assume config.php has already been included.
global $DB;
if (empty($lesson)) {
- print_error('You cannot call this script in that way');
+ print_error('cannotcallscript');
}
if (!isset($currenttab)) {
$currenttab = '';