Skip to content

Commit

Permalink
"MDL-14129, fix print_error call"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed May 22, 2008
1 parent d07fe1a commit a939f68
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 50 deletions.
12 changes: 6 additions & 6 deletions mod/assignment/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

if ($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)) {
print_error("assignment ID was incorrect");
print_error('invalidid', 'assignment');
}

if (! $course = get_record('course', 'id', $assignment->course)) {
print_error("Course is misconfigured");
print_error('coursemisconf', 'assignment');
}
} else {
if (!$assignment = get_record('assignment', 'id', $a)) {
print_error("Course module is incorrect");
print_error('invalidcoursemodule');
}
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)) {
print_error("Course Module ID was incorrect");
print_error('invalidcoursemodule');
}
}

Expand Down
6 changes: 3 additions & 3 deletions mod/assignment/grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
$id = required_param('id', PARAM_INT); // Course module 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)) {
print_error("assignment ID was incorrect");
print_error('invalidid', 'assignment');
}

if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured");
print_error('coursemisconf', 'assignment');
}

require_login($course->id, false, $cm);
Expand Down
2 changes: 1 addition & 1 deletion mod/assignment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$id = required_param('id', PARAM_INT); // course

if (! $course = get_record("course", "id", $id)) {
print_error("Course ID is incorrect");
print_error('invalidcourseid');
}

require_course_login($course);
Expand Down
12 changes: 6 additions & 6 deletions mod/assignment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function assignment_base($cmid='staticonly', $assignment=NULL, $cm=NULL, $course
if ($cm) {
$this->cm = $cm;
} 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);
Expand All @@ -62,13 +62,13 @@ function assignment_base($cmid='staticonly', $assignment=NULL, $cm=NULL, $course
} else if ($this->cm->course == $COURSE->id) {
$this->course = $COURSE;
} else if (! $this->course = get_record('course', 'id', $this->cm->course)) {
print_error('Course is misconfigured');
print_error('invalidid', 'assignment');
}

if ($assignment) {
$this->assignment = $assignment;
} 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
Expand Down Expand Up @@ -235,7 +235,7 @@ function view_feedback($submission=NULL) {

/// We need the teacher info
if (!$teacher = get_record('user', 'id', $graded_by)) {
print_error('Could not find the teacher');
print_error('cannotfindteacher');
}

/// Print the feedback
Expand Down Expand Up @@ -787,7 +787,7 @@ function display_submission($extra_javascript = '') {
$offset = required_param('offset', PARAM_INT);//offset for where to start looking for student.

if (!$user = get_record('user', 'id', $userid)) {
print_error('No such user!');
print_error('nousers');
}

if (!$submission = $this->get_submission($user->id)) {
Expand Down Expand Up @@ -1490,7 +1490,7 @@ function get_submission($userid=0, $createnew=false, $teachermodified=false) {
}
$newsubmission = $this->prepare_new_submission($userid, $teachermodified);
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);
Expand Down
4 changes: 2 additions & 2 deletions mod/assignment/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function definition() {
if($ass = get_record('assignment', 'id', (int)$this->_instance)) {
$type = $ass->assignmenttype;
} else {
print_error('incorrect assignment');
print_error('invalidassignment', 'assignment');
}
} else {
$type = required_param('type', PARAM_ALPHA);
Expand Down Expand Up @@ -68,4 +68,4 @@ function definition() {


}
?>
?>
12 changes: 6 additions & 6 deletions mod/assignment/submissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
if ($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)) {
print_error("assignment ID was incorrect");
print_error('invalidid', 'assignment');
}

if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured");
print_error('coursemisconf', 'assignment');
}
} else {
if (!$assignment = get_record("assignment", "id", $a)) {
print_error("Course module is incorrect");
print_error('invalidcoursemodule');
}
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)) {
print_error("Course Module ID was incorrect");
print_error('invalidcoursemodule');
}
}

Expand Down
12 changes: 6 additions & 6 deletions mod/assignment/type/online/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
$userid = required_param('userid', PARAM_INT); // User 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)) {
print_error("Assignment ID was incorrect");
print_error('invalidid', 'assignment');
}

if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured");
print_error('coursemisconf', 'assignment');
}

if (! $user = get_record("user", "id", $userid)) {
print_error("User is misconfigured");
print_error('usermisconf', 'assignment');
}

require_login($course->id, false, $cm);

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') {
print_error("Incorrect assignment type");
print_error('invalidtype', 'assignment');
}

$assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course);
Expand Down
4 changes: 2 additions & 2 deletions mod/assignment/type/upload/assignment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function view_feedback($submission=NULL) {

/// We need the teacher info
if (!$teacher = get_record('user', 'id', $graded_by)) {
print_error('Could not find the teacher');
print_error('cannotfindteacher');
}

/// Print the feedback
Expand Down Expand Up @@ -466,7 +466,7 @@ function upload() {
case 'editnotes':
$this->upload_notes();
default:
print_error('Error: Unknow upload action ('.$action.').');
print_error('unknowuploadaction', '', '', $action);
}
}

Expand Down
12 changes: 6 additions & 6 deletions mod/assignment/type/upload/notes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
$mode = optional_param('mode', '', PARAM_ALPHA);

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)) {
print_error("Assignment ID was incorrect");
print_error('invalidid', 'assignment');
}

if (! $course = get_record('course', 'id', $assignment->course)) {
print_error("Course is misconfigured");
print_error('coursemisconf', 'assignment');
}

if (! $user = get_record('user', 'id', $userid)) {
print_error("User is misconfigured");
print_error("invaliduserid");
}

require_login($course->id, false, $cm);

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') {
print_error("Incorrect assignment type");
print_error('invalidtype', 'assignment');
}

$assignmentinstance = new assignment_upload($cm->id, $assignment, $cm, $course);
Expand Down
12 changes: 6 additions & 6 deletions mod/assignment/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

if ($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)) {
print_error("assignment ID was incorrect");
print_error('invalidid', 'assignment');
}

if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured");
print_error('coursemisconf', 'assignment');
}
} else {
if (!$assignment = get_record("assignment", "id", $a)) {
print_error("Course module is incorrect");
print_error('invalidcoursemodule');
}
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)) {
print_error("Course Module ID was incorrect");
print_error('invalidcoursemodule', 'assignement');
}
}

Expand Down
12 changes: 6 additions & 6 deletions mod/assignment/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

if ($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)) {
print_error("assignment ID was incorrect");
print_error('invalidid', 'assignment');
}

if (! $course = get_record("course", "id", $assignment->course)) {
print_error("Course is misconfigured");
print_error('coursemisconf', 'assignment');
}
} else {
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)) {
print_error("Course is misconfigured");
print_error('coursemisconf', 'assignment');
}
if (! $cm = get_coursemodule_from_instance("assignment", $assignment->id, $course->id)) {
print_error("Course Module ID was incorrect");
print_error('invalidcoursemodule');
}
}

Expand Down

0 comments on commit a939f68

Please sign in to comment.