fixed resubmit logic and students can review their online assignment through file.php; merged from MOODLE_15_STABLE
This commit is contained in:
@@ -15,7 +15,9 @@ class assignment_online extends assignment_base {
|
||||
|
||||
global $USER;
|
||||
|
||||
$editmode = ($this->isopen() && !empty($_GET['edit']));
|
||||
$submission = $this->get_submission();
|
||||
$editable = $this->isopen() && (!$submission || $this->assignment->resubmit);
|
||||
$editmode = ($editable && !empty($_GET['edit']));
|
||||
|
||||
if ($editmode) {
|
||||
$this->view_header(get_string('editmysubmission', 'assignment'));
|
||||
@@ -28,9 +30,12 @@ class assignment_online extends assignment_base {
|
||||
$this->view_dates();
|
||||
|
||||
if ($data = data_submitted()) { // No incoming data?
|
||||
if ($this->update_submission($data)) {
|
||||
if ($editable && $this->update_submission($data)) {
|
||||
//redirect to get updated submission date and word count
|
||||
redirect('view.php?id='.$this->cm->id.'&saved=1');
|
||||
} else {
|
||||
// TODO: add better error message
|
||||
notify(get_string("error")); //submitting not allowed!
|
||||
}
|
||||
} else if (!empty($_GET['saved'])) {
|
||||
notify(get_string('submissionsaved', 'assignment'));
|
||||
@@ -46,7 +51,7 @@ class assignment_online extends assignment_base {
|
||||
} else {
|
||||
echo '<center>'.get_string('emptysubmission', 'assignment').'</center>';
|
||||
}
|
||||
if ($this->isopen()) {
|
||||
if ($editable) {
|
||||
print_single_button('view.php', array('id'=>$this->cm->id,'edit'=>'1'),
|
||||
get_string('editmysubmission', 'assignment'));
|
||||
}
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once("../../../../config.php");
|
||||
require_once("../../lib.php");
|
||||
require("../../../../config.php");
|
||||
require("../../lib.php");
|
||||
require("assignment.class.php");
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
$userid = required_param('userid', PARAM_INT); // Course Module ID
|
||||
|
||||
if (!empty($CFG->forcelogin)) {
|
||||
require_login();
|
||||
}
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
$userid = required_param('userid', PARAM_INT); // User ID
|
||||
|
||||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
|
||||
if (! $assignment = get_record("assignment", "id", $cm->instance)) {
|
||||
error("assignment ID was incorrect");
|
||||
error("Assignment ID was incorrect");
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $assignment->course)) {
|
||||
@@ -28,15 +25,17 @@
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
error("Only teachers can look at this page");
|
||||
if (($USER->id != $user->id) && !isteacher($course->id)) {
|
||||
error("You can not view this assignment");
|
||||
}
|
||||
|
||||
require ("$CFG->dirroot/mod/assignment/type/$assignment->assignmenttype/assignment.class.php");
|
||||
$assignmentclass = "assignment_$assignment->assignmenttype";
|
||||
$assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm, $course);
|
||||
if ($assignment->assignmenttype != 'online') {
|
||||
error("Incorrect assignment type");
|
||||
}
|
||||
|
||||
if ($submission = $assignmentinstance->get_submission($userid)) {
|
||||
$assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course);
|
||||
|
||||
if ($submission = $assignmentinstance->get_submission($user->id)) {
|
||||
print_header(fullname($user,true).': '.$assignment->name);
|
||||
|
||||
print_simple_box_start('center', '', '', '', 'generalbox', 'dates');
|
||||
|
||||
@@ -66,9 +66,9 @@ class assignment_uploadsingle extends assignment_base {
|
||||
|
||||
$this->view_header(get_string('upload'));
|
||||
|
||||
if (!$this->isopen()) {
|
||||
notify(get_string("uploadfailnoupdate", "assignment"));
|
||||
} else {
|
||||
$filecount = $this->count_user_files($USER->id);
|
||||
|
||||
if ($this->isopen() && (!$filecount || $this->assignment->resubmit)) {
|
||||
if ($submission = $this->get_submission($USER->id)) {
|
||||
if ($submission->grade and !$this->assignment->resubmit) {
|
||||
notify(get_string('alreadygraded', 'assignment'));
|
||||
@@ -107,6 +107,8 @@ class assignment_uploadsingle extends assignment_base {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
notify(get_string("uploaderror", "assignment")); //submitting not allowed!
|
||||
}
|
||||
|
||||
print_continue('view.php?id='.$this->cm->id);
|
||||
|
||||
Reference in New Issue
Block a user