/** * Display a single submission, ready for grading on a popup window * * This default method prints the teacher info and submissioncomment box at the top and * the student info and submission at the bottom. * This method also fetches the necessary data in order to be able to * provide a "Next submission" button. * Calls preprocess_submission() to give assignment type plug-ins a chance * to process submissions before they are graded * This method gets its arguments from the page parameters userid and offset * * @global object * @global object * @param string $extra_javascript */ function display_submission($offset=-1,$userid =-1, $display=true) { global $CFG, $DB, $PAGE, $OUTPUT; require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->libdir.'/tablelib.php'); require_once("$CFG->dirroot/repository/lib.php"); 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. } $filter = optional_param('filter', 0, PARAM_INT); if (!$user = $DB->get_record('user', array('id'=>$userid))) { print_error('nousers'); } if (!$submission = $this->get_submission($user->id)) { $submission = $this->prepare_new_submission($userid); } if ($submission->timemodified > $submission->timemarked) { $subtype = 'assignmentnew'; } else { $subtype = 'assignmentold'; } $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array($user->id)); $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; $assignment = $this->assignment; $cm = $this->cm; $context = get_context_instance(CONTEXT_MODULE, $cm->id); /// Get all ppl that can submit assignments $currentgroup = groups_get_activity_group($cm); $users = get_enrolled_users($context, 'mod/assignment:view', $currentgroup, 'u.id'); if ($users) { $users = array_keys($users); // if groupmembersonly used, remove users who are not in any group if (!empty($CFG->enablegroupmembersonly) and $cm->groupmembersonly) { if ($groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id')) { $users = array_intersect($users, array_keys($groupingusers)); } } } $nextid = 0; $where = ''; if($filter == 'submitted') { $where .= 's.timemodified > 0 AND '; } else if($filter == 'requiregrading') { $where .= 's.timemarked < s.timemodified AND '; } if ($users) { $userfields = user_picture::fields('u', array('lastaccess')); $select = "SELECT $userfields, s.id AS submissionid, s.grade, s.submissioncomment, s.timemodified, s.timemarked, COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status "; $sql = 'FROM {user} u '. 'LEFT JOIN {assignment_submissions} s ON u.id = s.userid AND s.assignment = '.$this->assignment->id.' '. 'WHERE '.$where.'u.id IN ('.implode(',', $users).') '; 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); 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; } } if ($submission->teacher) { $teacher = $DB->get_record('user', array('id'=>$submission->teacher)); } else { global $USER; $teacher = $USER; } $this->preprocess_submission($submission); $mformdata = new stdClass(); $mformdata->context = $this->context; $mformdata->maxbytes = $this->course->maxbytes; $mformdata->courseid = $this->course->id; $mformdata->teacher = $teacher; $mformdata->assignment = $assignment; $mformdata->submission = $submission; $mformdata->lateness = $this->display_lateness($submission->timemodified); $mformdata->auser = $auser; $mformdata->user = $user; $mformdata->offset = $offset; $mformdata->userid = $userid; $mformdata->cm = $this->cm; $mformdata->grading_info = $grading_info; $mformdata->enableoutcomes = $CFG->enableoutcomes; $mformdata->grade = $this->assignment->grade; $mformdata->gradingdisabled = $gradingdisabled; $mformdata->nextid = $nextid; $mformdata->submissioncomment= $submission->submissioncomment; $mformdata->submissioncommentformat= FORMAT_HTML; $mformdata->submission_content= $this->print_user_files($user->id,true); $mformdata->filter = $filter; if ($assignment->assignmenttype == 'upload') { $mformdata->fileui_options = array('subdirs'=>1, 'maxbytes'=>$assignment->maxbytes, 'maxfiles'=>$assignment->var1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL); } elseif ($assignment->assignmenttype == 'uploadsingle') { $mformdata->fileui_options = array('subdirs'=>0, 'maxbytes'=>$CFG->userquota, 'maxfiles'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL); } $submitform = new mod_assignment_grading_form( null, $mformdata ); if (!$display) { $ret_data = new stdClass(); $ret_data->mform = $submitform; $ret_data->fileui_options = $mformdata->fileui_options; return $ret_data; } if ($submitform->is_cancelled()) { redirect('submissions.php?id='.$this->cm->id); } $submitform->set_data($mformdata); $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'), new moodle_url('/mod/assignment/submissions.php', array('id'=>$cm->id))); $PAGE->navbar->add(fullname($user, true)); 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 $OUTPUT->footer(); }
public function get_data() { $data = parent::get_data(); if ($data) { $editoroptions = $this->get_editor_options(); switch ($this->_customdata->assignment->assignmenttype) { case 'team': case 'upload': case 'uploadsingle': $data = file_postupdate_standard_filemanager($data, 'files', $editoroptions, $this->_customdata->context, 'mod_assignment', 'response', $this->_customdata->teamid); break; default: break; } $data = file_postupdate_standard_editor($data, 'submissioncomment', $editoroptions, $this->_customdata->context, $editoroptions['component'], $editoroptions['filearea'], $this->_customdata->teamid); } return $data; }