diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
index 8f73734f0d9..c9ec637754f 100644
--- a/mod/assignment/lib.php
+++ b/mod/assignment/lib.php
@@ -98,22 +98,13 @@ class assignment_base {
$this->view_header();
- print_simple_box_start('center');
- echo format_text($this->assignment->description, $this->assignment->format);
- print_simple_box_end();
+ $this->view_intro();
- print_simple_box_start('center', '', '', '', 'time');
- echo '
';
echo '
';
@@ -635,11 +661,12 @@ class assignment_base {
}
if ($auser->timemarked > 0) {
$teachermodified = '
'.userdate($auser->timemarked).'
';
+ $grade = '
'.$this->display_grade($auser->grade).'
';
} else {
$teachermodified = '
';
+ $grade = '
';
}
- $grade = '
'.$this->display_grade($auser->grade).'
';
$comment = '
'.shorten_text($auser->comment, 15).'
';
} else {
@@ -714,7 +741,13 @@ class assignment_base {
}
- function get_submission($userid, $createnew=false) {
+ function get_submission($userid=0, $createnew=false) {
+ global $USER;
+
+ if (empty($userid)) {
+ $userid = $USER->id;
+ }
+
$submission = get_record('assignment_submissions', 'assignment', $this->assignment->id, 'userid', $userid);
if ($submission || !$createnew) {
@@ -904,6 +937,15 @@ class assignment_base {
return make_upload_directory( $this->file_area_name($userid) );
}
+ function isopen() {
+ $time = time();
+ if ($this->assignment->preventlate) {
+ return ($this->assignment->timeavailable <= $time && $time <= $this->assignment->timedue);
+ } else {
+ return ($this->assignment->timeavailable <= $time);
+ }
+ }
+
function user_outline($user) {
if ($submission = $this->get_submission($user->id)) {
diff --git a/mod/assignment/mod.html b/mod/assignment/mod.html
index 2ccbbb429d1..d89054f301b 100644
--- a/mod/assignment/mod.html
+++ b/mod/assignment/mod.html
@@ -116,7 +116,7 @@
assignmenttype, "");
- helpbutton("assignmenttype", get_string("assignmenttype", "assignment"), "assignment");
+ helpbutton("assignment/types", get_string("assignmenttype", "assignment"), "moodle");
?>
@@ -132,7 +132,7 @@
-
+
diff --git a/mod/assignment/styles.php b/mod/assignment/styles.php
index 58bb9130ccc..831e6f582ab 100644
--- a/mod/assignment/styles.php
+++ b/mod/assignment/styles.php
@@ -77,6 +77,20 @@
text-align: center;
}
+#mod-assignment-view #online .singlebutton {
+ text-align: center;
+}
+
+#mod-assignment-view #dates {
+ font-size: 0.8em;
+ margin-top: 30px;
+ margin-bottom: 30px;
+}
+
+#mod-assignment-view #dates .c0{
+ text-align:right;
+ font-weight:bold;
+}
#mod-assignment-view .feedback {
border-width:1px;
diff --git a/mod/assignment/type/offline/assignment.class.php b/mod/assignment/type/offline/assignment.class.php
index e019c8fc86d..84b16ea2f3c 100644
--- a/mod/assignment/type/offline/assignment.class.php
+++ b/mod/assignment/type/offline/assignment.class.php
@@ -10,14 +10,6 @@ class assignment_offline extends assignment_base {
parent::assignment_base($cmid);
}
- function setup($form) {
- global $CFG, $usehtmleditor;
-
- parent::setup($form);
- include("$CFG->dirroot/mod/assignment/type/offline/mod.html");
- parent::setup_end();
- }
-
function submittedlink() {
global $USER;
diff --git a/mod/assignment/type/online/assignment.class.php b/mod/assignment/type/online/assignment.class.php
new file mode 100644
index 00000000000..a3144adc473
--- /dev/null
+++ b/mod/assignment/type/online/assignment.class.php
@@ -0,0 +1,205 @@
+course->id)) {
+ if ($this->currentgroup and isteacheredit($this->course->id)) {
+ $group = get_record('groups', 'id', $this->currentgroup);
+ $groupname = ' ('.$group->name.')';
+ } else {
+ $groupname = '';
+ }
+ $count = $this->count_real_submissions($this->currentgroup);
+ $submitted = '
'.
+ get_string('viewsubmissions', 'assignment', $count).''.$groupname;
+ } else {
+ if (isset($USER->id)) {
+ if ($submission = $this->get_submission()) {
+ if ($submission->timemodified <= $this->assignment->timedue) {
+ $submitted = userdate($submission->timemodified);
+ } else {
+ $submitted = '
'.userdate($submission->timemodified).'';
+ }
+ }
+ }
+ }
+
+ return $submitted;
+ }
+
+ function view() {
+
+ global $USER;
+
+ $editmode = ($this->isopen() && !empty($_GET['edit']));
+
+ if ($editmode) {
+ $this->view_header(get_string('editmysubmission', 'assignment'));
+ } else {
+ $this->view_header();
+ }
+
+ $this->view_intro();
+
+ $this->view_dates();
+
+ if ($data = data_submitted()) { // No incoming data?
+ if ($this->update_submission($data)) {
+ notify(get_string('submissionsaved', 'assignment'));
+ }
+ }
+
+ print_simple_box_start('center', '70%', '', '', 'generalbox', 'online');
+ $submission = $this->get_submission();
+ if ($editmode) {
+ $this->view_edit_form($submission);
+ } else {
+ if ($submission) {
+ echo format_text($submission->data1, $submission->data2);
+ } else {
+ print_string('emptysubmission', 'assignment');
+ }
+ if ($this->isopen()) {
+ print_single_button('view.php', array('id'=>$this->cm->id,'edit'=>'1'),
+ get_string('editmysubmission', 'assignment'));
+ }
+ }
+ print_simple_box_end();
+
+ if ($editmode and $this->usehtmleditor) {
+ use_html_editor(); // MUst be at the end of the page
+ }
+
+ $this->view_feedback();
+
+ $this->view_footer();
+ }
+
+ function view_edit_form($submission = NULL) {
+ global $CFG;
+
+ $defaulttext = $submission ? $submission->data1 : '';
+ $defaultformat = $submission ? $submission->data2 : $this->defaultformat;
+
+ echo '
';
+
+ }
+
+ function update_submission($data) {
+ global $CFG, $USER;
+
+ $submission = $this->get_submission($USER->id, true);
+
+ $submission->data1 = $data->text;
+ $submission->format = $data->format;
+ $submission->timemodified = time();
+
+ return update_record('assignment_submissions', $submission);
+ }
+
+
+ /*
+ * Display and process the submissions
+ */
+ function process_feedback() {
+
+ global $USER;
+
+ if (!$feedback = data_submitted()) { // No incoming data?
+ return false;
+ }
+
+ if (!empty($feedback->cancel)) { // User hit cancel button
+ return false;
+ }
+
+ $newsubmission = $this->get_submission($feedback->userid, true); // Get or make one
+
+ $newsubmission->grade = $feedback->grade;
+ $newsubmission->comment = $feedback->comment;
+ $newsubmission->format = $feedback->format;
+ $newsubmission->teacher = $USER->id;
+ $newsubmission->mailed = 0; // Make sure mail goes out (again, even)
+ $newsubmission->timemarked = time();
+
+ if (! update_record('assignment_submissions', $newsubmission)) {
+ return false;
+ }
+
+ add_to_log($this->course->id, 'assignment', 'update grades',
+ 'submissions.php?id='.$this->assignment->id.'&user='.$feedback->userid, $feedback->userid, $this->cm->id);
+
+ return $newsubmission;
+
+ }
+
+ function print_user_files($userid, $return=false) {
+ global $CFG;
+
+ if (!$submission = $this->get_submission($userid)) {
+ return '';
+ }
+ $output = '
'.
+ '

'.
+ link_to_popup_window ('/mod/assignment/type/online/file.php?id='.$this->cm->id.'&userid='.
+ $submission->userid, 'file'.$userid, shorten_text($submission->data1, 15), 450, 580,
+ get_string('submission', 'assignment'), 'none', true).
+ '
';
+
+ if ($return) {
+ return $output;
+ }
+ echo $output;
+ }
+
+}
+
+?>
diff --git a/mod/assignment/type/online/file.php b/mod/assignment/type/online/file.php
new file mode 100644
index 00000000000..6c0457765d6
--- /dev/null
+++ b/mod/assignment/type/online/file.php
@@ -0,0 +1,48 @@
+forcelogin)) {
+ require_login();
+ }
+
+ 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");
+ }
+
+ if (! $course = get_record("course", "id", $assignment->course)) {
+ error("Course is misconfigured");
+ }
+
+ if (! $user = get_record("user", "id", $userid)) {
+ error("User is misconfigured");
+ }
+
+ require_login($course->id, false, $cm);
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ require ("$CFG->dirroot/mod/assignment/type/$assignment->assignmenttype/assignment.class.php");
+ $assignmentclass = "assignment_$assignment->assignmenttype";
+ $assignmentinstance = new $assignmentclass($cm->id, $assignment, $cm, $course);
+
+ if ($submission = $assignmentinstance->get_submission($userid)) {
+ print_header(fullname($user,true).': '.$assignment->name);
+ print_simple_box(format_text($submission->data1, $submission->data2), 'center', '100%');
+ close_window_button();
+ print_footer('none');
+ } else {
+ print_string('emptysubmission', 'assignment');
+ }
+
+?>
diff --git a/mod/assignment/type/online/mod.html b/mod/assignment/type/online/mod.html
new file mode 100644
index 00000000000..ca9a0baf329
--- /dev/null
+++ b/mod/assignment/type/online/mod.html
@@ -0,0 +1,54 @@
+resubmit)) {
+ $form->resubmit = 1;
+ }
+ if (!isset($form->emailteachers)) {
+ $form->emailteachers = 0;
+ }
+ if (!isset($form->var1)) {
+ $form->var1 = 0;
+ }
+?>
+
+
+
+
+ | : |
+
+ resubmit, "");
+ helpbutton("resubmit", get_string("allowresubmit", "assignment"), "assignment");
+ ?>
+ |
+
+
+
+ | : |
+
+ emailteachers, "");
+ helpbutton("emailteachers", get_string("emailteachers", "assignment"), "assignment");
+ ?>
+ |
+
+
+
+ | : |
+
+ var1, "");
+ helpbutton("commentinline", get_string("commentinline", "assignment"), "assignment");
+ ?>
+ |
+
+
+
+
+
+
+
+" />
+
diff --git a/mod/assignment/type/uploadsingle/assignment.class.php b/mod/assignment/type/uploadsingle/assignment.class.php
index 312fc1c8b62..3124f202727 100644
--- a/mod/assignment/type/uploadsingle/assignment.class.php
+++ b/mod/assignment/type/uploadsingle/assignment.class.php
@@ -11,17 +11,6 @@ class assignment_uploadsingle extends assignment_base {
}
- function setup($form) {
- global $CFG, $usehtmleditor;
-
- parent::setup($form);
-
- print_simple_box(get_string('', 'assignment'), 'center');
-
- include("$CFG->dirroot/mod/assignment/type/uploadsingle/mod.html");
- parent::setup_end();
- }
-
function submittedlink() {
global $USER;
@@ -58,18 +47,9 @@ class assignment_uploadsingle extends assignment_base {
$this->view_header();
- print_simple_box_start('center');
- echo format_text($this->assignment->description, $this->assignment->format);
- print_simple_box_end();
+ $this->view_intro();
- print_simple_box_start('center', '', '', '', 'time');
- echo '
';
- echo '| '.get_string('availabledate','assignment').': | ';
- echo ' '.userdate($this->assignment->timeavailable).' |
';
- echo '| '.get_string('duedate','assignment').': | ';
- echo ' '.userdate($this->assignment->timedue).' |
';
- echo '
';
- print_simple_box_end();
+ $this->view_dates();
$this->view_feedback();
@@ -164,6 +144,7 @@ class assignment_uploadsingle extends assignment_base {
$newsubmission->grade = $feedback->grade;
$newsubmission->comment = $feedback->comment;
+ $newsubmission->format = $feedback->format;
$newsubmission->teacher = $USER->id;
$newsubmission->mailed = 0; // Make sure mail goes out (again, even)
$newsubmission->timemarked = time();
diff --git a/mod/assignment/type/uploadsingle/mod.html b/mod/assignment/type/uploadsingle/mod.html
index 2e64ad4c182..706575e80f6 100644
--- a/mod/assignment/type/uploadsingle/mod.html
+++ b/mod/assignment/type/uploadsingle/mod.html
@@ -10,7 +10,7 @@
}
?>
-