From d2b6ee29f217ece4a5363a69bbb528950a289891 Mon Sep 17 00:00:00 2001
From: aparup
{$a}';
$string['coursemisconf'] = 'Course is misconfigured';
+$string['currentgrade'] = 'Current grade in gradebook';
$string['deleteallsubmissions'] = 'Delete all submissions';
$string['deletefilefailed'] = 'Deleting of file failed.';
$string['description'] = 'Description';
@@ -125,6 +126,7 @@ $string['invalidid'] = 'assignment ID was incorrect';
$string['invalidtype'] = 'Incorrect assignment type';
$string['invaliduserid'] = 'Invalid user ID';
$string['itemstocount'] = 'Count';
+$string['lastgrade'] = 'Last grade';
$string['late'] = '{$a} late';
$string['maximumgrade'] = 'Maximum grade';
$string['maximumsize'] = 'Maximum size';
@@ -147,6 +149,7 @@ $string['notesupdateerror'] = 'Error when updating notes';
$string['notgradedyet'] = 'Not graded yet';
$string['notsubmittedyet'] = 'Not submitted yet';
$string['onceassignmentsent'] = 'Once the assignment is sent for marking, you will no longer be able to delete or attach file(s). Do you want to continue?';
+$string['operation'] = 'Operation';
$string['overwritewarning'] = 'Warning: uploading again will REPLACE your current submission';
$string['pagesize'] = 'Submissions shown per page';
$string['preventlate'] = 'Prevent late submissions';
diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php
index 3fa7269ddcd..71e2d79dae5 100644
--- a/mod/assignment/lib.php
+++ b/mod/assignment/lib.php
@@ -563,26 +563,40 @@ class assignment_base {
global $USER, $OUTPUT, $DB, $PAGE;
$mailinfo = optional_param('mailinfo', null, PARAM_BOOL);
+ $saved = optional_param('saved', null, PARAM_BOOL);
+
+ if(optional_param('next', null, PARAM_BOOL)) {
+ $mode='next';
+ }
+ if(optional_param('saveandnext', null, PARAM_BOOL)) {
+ $mode='saveandnext';
+ }
+
if (is_null($mailinfo)) {
$mailinfo = get_user_preferences('assignment_mailinfo', 0);
} else {
set_user_preference('assignment_mailinfo', $mailinfo);
}
+ if($saved) {
+ $OUTPUT->heading(get_string('changessaved'));
+ }
+
switch ($mode) {
- case 'grade': // We are in a popup window grading
+ case 'grade': // We are in a main window grading
if ($submission = $this->process_feedback()) {
- //IE needs proper header with encoding
- $PAGE->set_title(get_string('feedback', 'assignment').':'.format_string($this->assignment->name));
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('changessaved'));
- print $this->update_main_listing($submission);
+ $this->display_submissions(get_string('changessaved'));
+ } else {
+ $this->display_submissions();
}
- close_window();
break;
- case 'single': // We are in a popup window displaying submission
- $this->display_submission();
+ case 'single': // We are in a main window displaying one submission
+ if ($submission = $this->process_feedback()) {
+ $this->display_submissions(get_string('changessaved'));
+ } else {
+ $this->display_submission();
+ }
break;
case 'all': // Main window, display everything
@@ -591,7 +605,6 @@ class assignment_base {
case 'fastgrade':
///do the fast grading stuff - this process should work for all 3 subclasses
-
$grading = false;
$commenting = false;
$col = false;
@@ -682,24 +695,24 @@ class assignment_base {
break;
- case 'next':
- /// We are currently in pop up, but we want to skip to next one without saving.
- /// This turns out to be similar to a single case
- /// The URL used is for the next submission.
-
- $this->display_submission();
- break;
-
case 'saveandnext':
///We are in pop up. save the current one and go to the next one.
//first we save the current changes
if ($submission = $this->process_feedback()) {
//print_heading(get_string('changessaved'));
- $extra_javascript = $this->update_main_listing($submission);
+ //$extra_javascript = $this->update_main_listing($submission);
}
- //then we display the next submission
- $this->display_submission($extra_javascript);
+ case 'next':
+ /// We are currently in pop up, but we want to skip to next one without saving.
+ /// This turns out to be similar to a single case
+ /// The URL used is for the next submission.
+ $offset = required_param('offset', PARAM_INT);
+ $nextid = required_param('nextid', PARAM_INT);
+ $id = required_param('id', PARAM_INT);
+ $offset = (int)$offset+1;
+ //$this->display_submission($offset+1 , $nextid);
+ redirect('submissions.php?id='.$id.'&userid='. $nextid . '&mode=single&offset='.$offset);
break;
default:
@@ -854,13 +867,12 @@ class assignment_base {
* @global object
* @param string $extra_javascript
*/
- function display_submission($extra_javascript = '') {
+ function display_submission( $offset=-1 , $userid =-1) {
global $CFG, $DB, $PAGE, $OUTPUT;
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->libdir.'/tablelib.php');
-
- $userid = required_param('userid', PARAM_INT);
- $offset = required_param('offset', PARAM_INT);//offset for where to start looking for student.
+ if($userid==-1) $userid = required_param('userid', PARAM_INT);
+ if($offset==-1) $offset = required_param('offset', PARAM_INT);//offset for where to start looking for student.
if (!$user = $DB->get_record('user', array('id'=>$userid))) {
print_error('nousers');
@@ -876,7 +888,7 @@ class assignment_base {
}
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array($user->id));
- $disabled = $grading_info->items[0]->grades[$userid]->locked || $grading_info->items[0]->grades[$userid]->overridden;
+ $gradingdisabled = $grading_info->items[0]->grades[$userid]->locked || $grading_info->items[0]->grades[$userid]->overridden;
/// construct SQL, using current offset to find the data of the next student
$course = $this->course;
@@ -913,142 +925,71 @@ class assignment_base {
if ($sort = flexible_table::get_sort_for_table('mod-assignment-submissions')) {
$sort = 'ORDER BY '.$sort.' ';
}
+ $auser = $DB->get_records_sql($select.$sql.$sort, null, $offset, 2);
- $auser = $DB->get_records_sql($select.$sql.$sort, null, $offset+1, 1);
- if (is_array($auser) && count($auser)>0) {
- $nextuser = array_shift($auser);
+ if (is_array($auser) && count($auser)>1) {
+ $nextuser = next($auser);
/// Calculate user status
$nextuser->status = ($nextuser->timemarked > 0) && ($nextuser->timemarked >= $nextuser->timemodified);
$nextid = $nextuser->id;
}
}
- $PAGE->set_pagelayout('popup');
- $PAGE->set_title(get_string('feedback', 'assignment').':'.fullname($user, true).':'.format_string($this->assignment->name));
- echo $OUTPUT->header();
- /// Print any extra javascript needed for saveandnext
- echo $extra_javascript;
- echo html_writer::script(js_writer::function_call('initNext', array($nextid, $userid)));
-
- echo '';
-
- ///Start of teacher info row
-
- echo '
';
-
echo $OUTPUT->footer();
}
@@ -1113,8 +1054,9 @@ class assignment_base {
$tabindex = 1; //tabindex for quick grading tabbing; Not working for dropdowns yet
add_to_log($course->id, 'assignment', 'view submission', 'submissions.php?id='.$this->cm->id, $this->assignment->id, $this->cm->id);
- $PAGE->navbar->add($this->strsubmissions);
+
$PAGE->set_title(format_string($this->assignment->name,true));
+ $PAGE->set_heading($this->course->fullname);
echo $OUTPUT->header();
/// Print quickgrade form around the table
@@ -1216,6 +1158,7 @@ class assignment_base {
if (empty($users)) {
echo $OUTPUT->heading(get_string('nosubmitusers','assignment'));
+ echo '';
return true;
}
if ($this->assignment->assignmenttype=='upload' || $this->assignment->assignmenttype=='online' || $this->assignment->assignmenttype=='uploadsingle') {
@@ -1356,8 +1299,7 @@ class assignment_base {
$popup_url = '/mod/assignment/submissions.php?id='.$this->cm->id
. '&userid='.$auser->id.'&mode=single'.'&offset='.$offset++;
- $action = new popup_action('click', $popup_url, 'grade'.$auser->id, array('height' => 600, 'width' => 700));
- $button = $OUTPUT->action_link($popup_url, $buttontext, $action);
+ $button = $OUTPUT->action_link($popup_url, $buttontext);
$status = '';
- echo ' ';
-
- ///End of teacher info row, Start of student info row
- echo '';
if ($submission->teacher) {
$teacher = $DB->get_record('user', array('id'=>$submission->teacher));
} else {
global $USER;
$teacher = $USER;
}
- echo $OUTPUT->user_picture($teacher);
- echo ' ';
- echo '';
- echo '';
+ $PAGE->set_title($this->course->fullname . ': ' .get_string('feedback', 'assignment').' - '.fullname($user, true));
+ $PAGE->set_heading($this->course->fullname);
+ $PAGE->navbar->add( get_string('submissions', 'assignment') );
+
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading(get_string('feedback', 'assignment').': '.fullname($user, true));
+
+ // display mform here...
+ $submitform->display();
$customfeedback = $this->custom_feedbackform($submission, true);
if (!empty($customfeedback)) {
echo $customfeedback;
}
- echo ' ';
- echo ' ';
-
- ///End of student info row
-
- echo '';
- echo $OUTPUT->user_picture($user);
- echo ' ';
- echo '';
- echo ' ';
- echo '
'.$OUTPUT->help_icon('quickgrade', 'assignment').'
'; + echo ''; + echo ''; echo ''; /// Decide what to count if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) { - echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')'; + $wordcount .= ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')'; } else if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) { - echo ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')'; + $wordcount .= ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')'; } - echo $OUTPUT->box_end(); - echo $OUTPUT->box(format_text($submission->data1, $submission->data2), 'generalbox boxaligncenter boxwidthwide'); + $wordcount .= '
'; + + $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'assignment_online_submission', $submission->id); + return $wordcount . format_text($text, $submission->data2); - ///End of stolen code from file.php - if ($return) { - //return $output; } - //echo $output; - } function preprocess_submission(&$submission) { if ($this->assignment->var1 && empty($submission->submissioncomment)) { // comment inline @@ -463,13 +460,13 @@ class mod_assignment_online_edit_form extends moodleform { return parent::set_data($data); } - public function get_data() { + public function get_data($submission_id = null) { $data = parent::get_data(); if (!empty($this->_customdata->submission->id)) { $itemid = $this->_customdata->submission->id; } else { - $itemid = null; + $itemid = $submission_id; } if ($data) {