Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed resubmit logic and students can review their online assignment …

…through file.php; merged from MOODLE_15_STABLE
  • Loading branch information...
commit f0a99707fd5bbb03680c11f09f375f5612f60ffd 1 parent 9a4d45a
skodak authored
View
11 mod/assignment/type/online/assignment.class.php
@@ -15,7 +15,9 @@ function view() {
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 @@ function view() {
$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 @@ function view() {
} 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'));
}
View
29 mod/assignment/type/online/file.php
@@ -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");
+ }
+
+ if ($assignment->assignmenttype != 'online') {
+ error("Incorrect assignment type");
}
- require ("$CFG->dirroot/mod/assignment/type/$assignment->assignmenttype/assignment.class.php");
- $assignmentclass = "assignment_$assignment->assignmenttype";
- $assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm, $course);
+ $assignmentinstance = new assignment_online($cm->id, $assignment, $cm, $course);
- if ($submission = $assignmentinstance->get_submission($userid)) {
+ if ($submission = $assignmentinstance->get_submission($user->id)) {
print_header(fullname($user,true).': '.$assignment->name);
print_simple_box_start('center', '', '', '', 'generalbox', 'dates');
View
8 mod/assignment/type/uploadsingle/assignment.class.php
@@ -66,9 +66,9 @@ function upload() {
$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 @@ function upload() {
}
}
}
+ } else {
+ notify(get_string("uploaderror", "assignment")); //submitting not allowed!
}
print_continue('view.php?id='.$this->cm->id);
Please sign in to comment.
Something went wrong with that request. Please try again.