"MDL-14129, fix print_error call"

This commit is contained in:
dongsheng 2008-05-22 07:20:45 +00:00
parent d07fe1a930
commit a939f681bb
11 changed files with 50 additions and 50 deletions

View file

@ -8,25 +8,25 @@
if ($id) { if ($id) {
if (! $cm = get_coursemodule_from_id('assignment', $id)) { if (! $cm = get_coursemodule_from_id('assignment', $id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
if (! $assignment = get_record('assignment', 'id', $cm->instance)) { if (! $assignment = get_record('assignment', 'id', $cm->instance)) {
print_error("assignment ID was incorrect"); print_error('invalidid', 'assignment');
} }
if (! $course = get_record('course', 'id', $assignment->course)) { if (! $course = get_record('course', 'id', $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
} else { } else {
if (!$assignment = get_record('assignment', 'id', $a)) { if (!$assignment = get_record('assignment', 'id', $a)) {
print_error("Course module is incorrect"); print_error('invalidcoursemodule');
} }
if (! $course = get_record('course', 'id', $assignment->course)) { if (! $course = get_record('course', 'id', $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignement');
} }
if (! $cm = get_coursemodule_from_instance('assignment', $assignment->id, $course->id)) { if (! $cm = get_coursemodule_from_instance('assignment', $assignment->id, $course->id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
} }

View file

@ -5,15 +5,15 @@
$id = required_param('id', PARAM_INT); // Course module ID $id = required_param('id', PARAM_INT); // Course module ID
if (! $cm = get_coursemodule_from_id('assignment', $id)) { if (! $cm = get_coursemodule_from_id('assignment', $id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
if (! $assignment = get_record("assignment", "id", $cm->instance)) { if (! $assignment = get_record("assignment", "id", $cm->instance)) {
print_error("assignment ID was incorrect"); print_error('invalidid', 'assignment');
} }
if (! $course = get_record("course", "id", $assignment->course)) { if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
require_login($course->id, false, $cm); require_login($course->id, false, $cm);

View file

@ -7,7 +7,7 @@
$id = required_param('id', PARAM_INT); // course $id = required_param('id', PARAM_INT); // course
if (! $course = get_record("course", "id", $id)) { if (! $course = get_record("course", "id", $id)) {
print_error("Course ID is incorrect"); print_error('invalidcourseid');
} }
require_course_login($course); require_course_login($course);

View file

@ -52,7 +52,7 @@ class assignment_base {
if ($cm) { if ($cm) {
$this->cm = $cm; $this->cm = $cm;
} else if (! $this->cm = get_coursemodule_from_id('assignment', $cmid)) { } else if (! $this->cm = get_coursemodule_from_id('assignment', $cmid)) {
print_error('Course Module ID was incorrect'); print_error('invalidcoursemodule');
} }
$this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id); $this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
@ -62,13 +62,13 @@ class assignment_base {
} else if ($this->cm->course == $COURSE->id) { } else if ($this->cm->course == $COURSE->id) {
$this->course = $COURSE; $this->course = $COURSE;
} else if (! $this->course = get_record('course', 'id', $this->cm->course)) { } else if (! $this->course = get_record('course', 'id', $this->cm->course)) {
print_error('Course is misconfigured'); print_error('invalidid', 'assignment');
} }
if ($assignment) { if ($assignment) {
$this->assignment = $assignment; $this->assignment = $assignment;
} else if (! $this->assignment = get_record('assignment', 'id', $this->cm->instance)) { } else if (! $this->assignment = get_record('assignment', 'id', $this->cm->instance)) {
print_error('assignment ID was incorrect'); print_error('invalidid', 'assignment');
} }
$this->assignment->cmidnumber = $this->cm->id; // compatibility with modedit assignment obj $this->assignment->cmidnumber = $this->cm->id; // compatibility with modedit assignment obj
@ -235,7 +235,7 @@ class assignment_base {
/// We need the teacher info /// We need the teacher info
if (!$teacher = get_record('user', 'id', $graded_by)) { if (!$teacher = get_record('user', 'id', $graded_by)) {
print_error('Could not find the teacher'); print_error('cannotfindteacher');
} }
/// Print the feedback /// Print the feedback
@ -787,7 +787,7 @@ class assignment_base {
$offset = required_param('offset', PARAM_INT);//offset for where to start looking for student. $offset = required_param('offset', PARAM_INT);//offset for where to start looking for student.
if (!$user = get_record('user', 'id', $userid)) { if (!$user = get_record('user', 'id', $userid)) {
print_error('No such user!'); print_error('nousers');
} }
if (!$submission = $this->get_submission($user->id)) { if (!$submission = $this->get_submission($user->id)) {
@ -1490,7 +1490,7 @@ class assignment_base {
} }
$newsubmission = $this->prepare_new_submission($userid, $teachermodified); $newsubmission = $this->prepare_new_submission($userid, $teachermodified);
if (!insert_record("assignment_submissions", $newsubmission)) { if (!insert_record("assignment_submissions", $newsubmission)) {
print_error("Could not insert a new empty submission"); print_error('cannotinsertempty', 'assignment');
} }
return get_record('assignment_submissions', 'assignment', $this->assignment->id, 'userid', $userid); return get_record('assignment_submissions', 'assignment', $this->assignment->id, 'userid', $userid);

View file

@ -12,7 +12,7 @@ class mod_assignment_mod_form extends moodleform_mod {
if($ass = get_record('assignment', 'id', (int)$this->_instance)) { if($ass = get_record('assignment', 'id', (int)$this->_instance)) {
$type = $ass->assignmenttype; $type = $ass->assignmenttype;
} else { } else {
print_error('incorrect assignment'); print_error('invalidassignment', 'assignment');
} }
} else { } else {
$type = required_param('type', PARAM_ALPHA); $type = required_param('type', PARAM_ALPHA);
@ -68,4 +68,4 @@ class mod_assignment_mod_form extends moodleform_mod {
} }
?> ?>

View file

@ -9,25 +9,25 @@
if ($id) { if ($id) {
if (! $cm = get_coursemodule_from_id('assignment', $id)) { if (! $cm = get_coursemodule_from_id('assignment', $id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
if (! $assignment = get_record("assignment", "id", $cm->instance)) { if (! $assignment = get_record("assignment", "id", $cm->instance)) {
print_error("assignment ID was incorrect"); print_error('invalidid', 'assignment');
} }
if (! $course = get_record("course", "id", $assignment->course)) { if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
} else { } else {
if (!$assignment = get_record("assignment", "id", $a)) { if (!$assignment = get_record("assignment", "id", $a)) {
print_error("Course module is incorrect"); print_error('invalidcoursemodule');
} }
if (! $course = get_record("course", "id", $assignment->course)) { if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) { if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
} }

View file

@ -8,29 +8,29 @@
$userid = required_param('userid', PARAM_INT); // User ID $userid = required_param('userid', PARAM_INT); // User ID
if (! $cm = get_coursemodule_from_id('assignment', $id)) { if (! $cm = get_coursemodule_from_id('assignment', $id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
if (! $assignment = get_record("assignment", "id", $cm->instance)) { if (! $assignment = get_record("assignment", "id", $cm->instance)) {
print_error("Assignment ID was incorrect"); print_error('invalidid', 'assignment');
} }
if (! $course = get_record("course", "id", $assignment->course)) { if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
if (! $user = get_record("user", "id", $userid)) { if (! $user = get_record("user", "id", $userid)) {
print_error("User is misconfigured"); print_error('usermisconf', 'assignment');
} }
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
if (($USER->id != $user->id) && !has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) { if (($USER->id != $user->id) && !has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
print_error("You can not view this assignment"); print_error('cannotviewassignment', 'assignment');
} }
if ($assignment->assignmenttype != 'online') { if ($assignment->assignmenttype != 'online') {
print_error("Incorrect assignment type"); print_error('invalidtype', 'assignment');
} }
$assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course); $assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course);

View file

@ -105,7 +105,7 @@ class assignment_upload extends assignment_base {
/// We need the teacher info /// We need the teacher info
if (!$teacher = get_record('user', 'id', $graded_by)) { if (!$teacher = get_record('user', 'id', $graded_by)) {
print_error('Could not find the teacher'); print_error('cannotfindteacher');
} }
/// Print the feedback /// Print the feedback
@ -466,7 +466,7 @@ class assignment_upload extends assignment_base {
case 'editnotes': case 'editnotes':
$this->upload_notes(); $this->upload_notes();
default: default:
print_error('Error: Unknow upload action ('.$action.').'); print_error('unknowuploadaction', '', '', $action);
} }
} }

View file

@ -10,29 +10,29 @@
$mode = optional_param('mode', '', PARAM_ALPHA); $mode = optional_param('mode', '', PARAM_ALPHA);
if (! $cm = get_coursemodule_from_id('assignment', $id)) { if (! $cm = get_coursemodule_from_id('assignment', $id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
if (! $assignment = get_record('assignment', 'id', $cm->instance)) { if (! $assignment = get_record('assignment', 'id', $cm->instance)) {
print_error("Assignment ID was incorrect"); print_error('invalidid', 'assignment');
} }
if (! $course = get_record('course', 'id', $assignment->course)) { if (! $course = get_record('course', 'id', $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
if (! $user = get_record('user', 'id', $userid)) { if (! $user = get_record('user', 'id', $userid)) {
print_error("User is misconfigured"); print_error("invaliduserid");
} }
require_login($course->id, false, $cm); require_login($course->id, false, $cm);
if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) { if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
print_error("You can not view this assignment"); print_error('cannotviewassignment', 'assignment');
} }
if ($assignment->assignmenttype != 'upload') { if ($assignment->assignmenttype != 'upload') {
print_error("Incorrect assignment type"); print_error('invalidtype', 'assignment');
} }
$assignmentinstance = new assignment_upload($cm->id, $assignment, $cm, $course); $assignmentinstance = new assignment_upload($cm->id, $assignment, $cm, $course);

View file

@ -8,25 +8,25 @@
if ($id) { if ($id) {
if (! $cm = get_coursemodule_from_id('assignment', $id)) { if (! $cm = get_coursemodule_from_id('assignment', $id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
if (! $assignment = get_record("assignment", "id", $cm->instance)) { if (! $assignment = get_record("assignment", "id", $cm->instance)) {
print_error("assignment ID was incorrect"); print_error('invalidid', 'assignment');
} }
if (! $course = get_record("course", "id", $assignment->course)) { if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
} else { } else {
if (!$assignment = get_record("assignment", "id", $a)) { if (!$assignment = get_record("assignment", "id", $a)) {
print_error("Course module is incorrect"); print_error('invalidcoursemodule');
} }
if (! $course = get_record("course", "id", $assignment->course)) { if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured"); print_error('invalidid', 'assignment');
} }
if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) { if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule', 'assignement');
} }
} }

View file

@ -8,25 +8,25 @@
if ($id) { if ($id) {
if (! $cm = get_coursemodule_from_id('assignment', $id)) { if (! $cm = get_coursemodule_from_id('assignment', $id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
if (! $assignment = get_record("assignment", "id", $cm->instance)) { if (! $assignment = get_record("assignment", "id", $cm->instance)) {
print_error("assignment ID was incorrect"); print_error('invalidid', 'assignment');
} }
if (! $course = get_record("course", "id", $assignment->course)) { if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
} else { } else {
if (!$assignment = get_record("assignment", "id", $a)) { if (!$assignment = get_record("assignment", "id", $a)) {
print_error("Course module is incorrect"); print_error('invalidid', 'assignment');
} }
if (! $course = get_record("course", "id", $assignment->course)) { if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured"); print_error('coursemisconf', 'assignment');
} }
if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) { if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
print_error("Course Module ID was incorrect"); print_error('invalidcoursemodule');
} }
} }