Index: temp_moodle_dev/moodle/mod/assignment/type/upload/assignment.class.php =================================================================== RCS file: /usr/local/cvsroot/temp_moodle_dev/moodle/mod/assignment/type/upload/assignment.class.php,v diff -u -r1.1 -r1.2 --- temp_moodle_dev/moodle/mod/assignment/type/upload/assignment.class.php 14 Nov 2008 06:30:02 -0000 1.1 +++ temp_moodle_dev/moodle/mod/assignment/type/upload/assignment.class.php 11 Dec 2008 04:10:06 -0000 1.2 @@ -17,7 +17,7 @@ function view() { global $USER; - + require_capability('mod/assignment:view', $this->context); add_to_log($this->course->id, 'assignment', 'view', "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id); @@ -50,6 +50,7 @@ if ($filecount and $submission) { print_simple_box($this->print_user_files($USER->id, true), 'center'); + } else { if (!$this->isopen() or $this->is_finalized($submission)) { print_simple_box(get_string('nofiles', 'assignment'), 'center'); @@ -58,7 +59,7 @@ } } - $this->view_upload_form(); + $saved=$this->view_upload_form(); if ($this->notes_allowed()) { print_heading(get_string('notes', 'assignment'), '', 3); @@ -67,14 +68,15 @@ $this->view_final_submission(); } + $this->view_footer(); } function view_feedback($submission=NULL) { global $USER, $CFG; require_once($CFG->libdir.'/gradelib.php'); - + if (!$submission) { /// Get submission for this assignment $submission = $this->get_submission($USER->id); } @@ -179,7 +181,7 @@ echo ''; echo '
'; } - + } function view_notes() { @@ -203,7 +205,6 @@ global $CFG, $USER; $submission = $this->get_submission($USER->id); - if ($this->isopen() and $this->can_finalize($submission)) { //print final submit button print_heading(get_string('submitformarking','assignment'), '', 3); @@ -246,7 +247,7 @@ $mode = optional_param('mode', '', PARAM_ALPHA); $offset = optional_param('offset', 0, PARAM_INT); $forcerefresh = optional_param('forcerefresh', 0, PARAM_BOOL); - + $output = get_string('responsefiles', 'assignment').': '; $output .= '
file_area_name($userid); $submission = $this->get_submission($userid); @@ -327,7 +328,7 @@ $mode = optional_param('mode', '', PARAM_ALPHA); $offset = optional_param('offset', 0, PARAM_INT); - + if (!$userid) { if (!isloggedin()) { return ''; @@ -446,7 +447,6 @@ function upload() { $action = required_param('action', PARAM_ALPHA); - switch ($action) { case 'finalize': $this->finalize(); @@ -458,7 +458,7 @@ $this->unfinalize(); break; case 'uploadresponse': - $this->upload_responsefile(); + $this->upload_responsefile(); break; case 'uploadfile': $this->upload_file(); @@ -571,7 +571,7 @@ $returnurl = 'view.php?id='.$this->cm->id; - $filecount = $this->count_user_files($USER->id); + //$filecount = $this->count_user_files($USER->id); $submission = $this->get_submission($USER->id); if (!$this->can_upload_file($submission)) { @@ -587,14 +587,19 @@ require_once($CFG->dirroot.'/lib/uploadlib.php'); $um = new upload_manager('newfile',false,true,$this->course,false,$this->assignment->maxbytes,true); - + if ($um->process_file_uploads($dir)) { $submission = $this->get_submission($USER->id, true); //create new submission if needed $updated = new object(); $updated->id = $submission->id; + //lams: store in the database the number of files submitted + $filecount = $this->count_user_files($USER->id); + $updated->numfiles = $filecount; $updated->timemodified = time(); if (update_record('assignment_submissions', $updated)) { + //lams: add 'saved' variable so lams can recognize if the student have uploaded a file + $saved=1; add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id); $submission = $this->get_submission($USER->id); @@ -610,7 +615,8 @@ $this->view_footer(); die; } - redirect('view.php?id='.$this->cm->id); + //lams: add 'saved' variable so lams can recognize if the student have uploaded a file + redirect('view.php?id='.$this->cm->id.'&saved='.$saved); } $this->view_header(get_string('upload')); notify(get_string('uploaderror', 'assignment')); @@ -622,7 +628,6 @@ function finalize() { global $USER; - $confirm = optional_param('confirm', 0, PARAM_BOOL); $returnurl = 'view.php?id='.$this->cm->id; $submission = $this->get_submission($USER->id);