- uploadsingle response now uses file manager instead of file picker.
- both uploadsingle and advancedupload assignment types have their grading pages with response file management in line (not a separate page).
- bit of a css issue YUI's tree view rendering (a table) within a table that had borders is fixed.
$string['optionalsettings'] = 'Optional settings';
$string['overwritewarning'] = 'Warning: uploading again will REPLACE your current submission';
$string['pagesize'] = 'Submissions shown per page';
+$string['popupinnewwindow'] = 'Open in a popup window';
$string['pluginadministration'] = 'Assignment administration';
$string['pluginname'] = 'Assignment';
$string['preventlate'] = 'Prevent late submissions';
* @global object
* @param string $extra_javascript
*/
- function display_submission($offset=-1,$userid =-1) {
+ 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);
}
$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);
}
$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') );
+ $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));
* @global object
* @return object|bool The updated submission object or false
*/
- function process_feedback() {
+ function process_feedback($formdata=null) {
global $CFG, $USER, $DB;
require_once($CFG->libdir.'/gradelib.php');
add_to_log($this->course->id, 'assignment', 'update grades',
'submissions.php?id='.$this->assignment->id.'&user='.$feedback->userid, $feedback->userid, $this->cm->id);
+ if (!is_null($formdata)) {
+ if ($this->type == 'upload' || $this->type == 'uploadsingle') {
+ $mformdata = $formdata->mform->get_data();
+ $mformdata = file_postupdate_standard_filemanager($mformdata, 'files', $formdata->fileui_options, $this->context, 'mod_assignment', 'response', $submission->id);
+ }
+ }
}
return $submission;
userdate($this->_customdata->submission->timemodified) .
$this->_customdata->lateness );
+ $this->add_submission_content();
$this->add_grades_section();
$this->add_feedback_section();
if ($this->_customdata->submission->timemarked) {
+ $datestring = userdate($this->_customdata->submission->timemarked)." (".format_time(time() - $this->_customdata->submission->timemarked).")";
$mform->addElement('header', 'Last Grade', get_string('lastgrade', 'assignment'));
$mform->addElement('static', 'picture', $OUTPUT->user_picture($this->_customdata->teacher) ,
fullname($this->_customdata->teacher,true).
- '<br/>'.
- userdate($this->_customdata->submission->timemarked));
+ '<br/>'.$datestring);
}
// buttons
$this->add_action_buttons();
- $this->add_submission_content();
}
function add_grades_section() {
$mform->setType('submissioncomment_editor', PARAM_RAW); // to be cleaned before display
$mform->setDefault('submissioncomment_editor', $this->_customdata->submission->submissioncomment);
//$mform->addRule('submissioncomment', get_string('required'), 'required', null, 'client');
-
+ switch ($this->_customdata->assignment->assignmenttype) {
+ case 'upload' :
+ case 'uploadsingle' :
+ $mform->addElement('filemanager', 'files_filemanager', get_string('responsefiles', 'assignment'). ':', null, $this->_customdata->fileui_options);
+ break;
+ default :
+ break;
+ }
$lastmailinfo = get_user_preferences('assignment_mailinfo', 1) ? array('checked'=>'checked') : array();
$mform->addElement('hidden', 'mailinfo_h', "0");
$mform->setType('mailinfo_h', PARAM_INT);
function add_action_buttons() {
$mform =& $this->_form;
- $mform->addElement('header', 'Operation', get_string('operation', 'assignment'));
//if there are more to be graded.
if ($this->_customdata->nextid>0) {
$buttonarray=array();
$buttonarray[] = &$mform->createElement('cancel');
}
$mform->addGroup($buttonarray, 'grading_buttonar', '', array(' '), false);
+ $mform->closeHeaderBefore('grading_buttonar');
$mform->setType('grading_buttonar', PARAM_RAW);
}
$itemid = null;
}
+ switch ($this->_customdata->assignment->assignmenttype) {
+ case 'upload' :
+ case 'uploadsingle' :
+ $data = file_prepare_standard_filemanager($data, 'files', $editoroptions, $this->_customdata->context, 'mod_assignment', 'response', $itemid);
+ break;
+ default :
+ break;
+ }
+
$data = file_prepare_standard_editor($data, 'submissioncomment', $editoroptions, $this->_customdata->context, $editoroptions['component'], $editoroptions['filearea'], $itemid);
return parent::set_data($data);
}
if ($data) {
$editoroptions = $this->get_editor_options();
+ switch ($this->_customdata->assignment->assignmenttype) {
+ case 'upload' :
+ case 'uploadsingle' :
+ $data = file_postupdate_standard_filemanager($data, 'files', $editoroptions, $this->_customdata->context, 'mod_assignment', 'response', $itemid);
+ break;
+ default :
+ break;
+ }
$data = file_postupdate_standard_editor($data, 'submissioncomment', $editoroptions, $this->_customdata->context, $editoroptions['component'], $editoroptions['filearea'], $itemid);
- $data->format = $data->textformat;
}
return $data;
}
.path-mod-assignment .late {color: red;}
/** Styles for submissions.php **/
+#page-mod-assignment-submissions fieldset.felement {margin-left: 16%;}
#page-mod-assignment-submissions form#options div {text-align:right;margin-left:auto;margin-right:20px;}
#page-mod-assignment-submissions .header .commands {display: inline;}
#page-mod-assignment-submissions .picture {width: 35px;}
$link = new moodle_url("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}");
$action = new popup_action('click', $link, 'file'.$userid, array('height' => 450, 'width' => 580));
- $popup = $OUTPUT->action_link($link, shorten_text(trim(strip_tags(format_text($submission->data1,$submission->data2))), 15), $action, array('title'=>get_string('submission', 'assignment')));
+ $popup = $OUTPUT->action_link($link, get_string('popupinnewwindow','assignment'), $action, array('title'=>get_string('submission', 'assignment')));
$output = '<div class="files">'.
'<img align="middle" src="'.$OUTPUT->pix_url('f/html') . '" height="16" width="16" alt="html" />'.
$popup .
'</div>';
- $wordcount = '<p id="wordcount">';
+ $wordcount = '<p id="wordcount">'. $popup . ' ';
/// Decide what to count
if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
- $wordcount .= ' ('.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) {
- $wordcount .= ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')';
+ $wordcount .= '('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')';
}
$wordcount .= '</p>';
return ($this->assignment->var3 && (time() <= $this->assignment->timeavailable));
}
- function custom_feedbackform($submission, $return=false) {
- global $CFG, $OUTPUT;
-
- $mode = optional_param('mode', '', PARAM_ALPHA);
- $offset = optional_param('offset', 0, PARAM_INT);
- $forcerefresh = optional_param('forcerefresh', 0, PARAM_BOOL);
-
- if ($this->count_responsefiles($submission->userid) > 0) {
- $str = get_string('editthesefiles', 'assignment');
- } else {
- $str = get_string('uploadfiles', 'assignment');
- }
-
- $output = get_string('responsefiles', 'assignment').': ';
-
- $output .= $OUTPUT->single_button(new moodle_url('/mod/assignment/type/upload/upload.php',
- array('contextid'=>$this->context->id,'id'=>$this->cm->id, 'offset'=>$offset,
- 'forcerefresh'=>$forcerefresh, 'userid'=>$submission->userid, 'mode'=>$mode)), $str, 'get');
-
- if ($forcerefresh) {
- $output .= $this->update_main_listing($submission);
- }
-
- $responsefiles = $this->print_responsefiles($submission->userid, true);
- if (!empty($responsefiles)) {
- $output .= $responsefiles;
- }
-
- if ($return) {
- return $output;
- }
- echo $output;
- return;
- }
-
-
function print_student_answer($userid, $return=false){
global $CFG, $OUTPUT, $PAGE;
parent::submissions($mode);
}
+ function process_feedback() {
+ if (!$feedback = data_submitted() or !confirm_sesskey()) { // No incoming data?
+ return false;
+ }
+ $userid = required_param('userid', PARAM_INT);
+ $offset = required_param('offset', PARAM_INT);
+ $mform = $this->display_submission($offset, $userid, false);
+ parent::process_feedback($mform);
+ }
+
function print_responsefiles($userid, $return=false) {
global $CFG, $USER, $OUTPUT, $PAGE;
$filemanager_options = array('subdirs'=>1, 'maxbytes'=>$assignment->maxbytes, 'maxfiles'=>$assignment->var1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
-if ($id==null) {
$mform = new mod_assignment_upload_form(null, array('contextid'=>$contextid, 'userid'=>$formdata->userid, 'options'=>$filemanager_options));
-} else {
- $formdata->cm->id = $id;
- $formdata->contextid = $contextid;
- $formdata->options = $filemanager_options;
- $mform = new mod_assignment_upload_response_form(null, $formdata);
-}
if ($mform->is_cancelled()) {
- if ($id==null) {
redirect(new moodle_url('/mod/assignment/view.php', array('id'=>$cm->id)));
- } else {
- $instance->display_submission($formdata->offset, $formdata->userid);
- die();
- }
} else if ($formdata = $mform->get_data()) {
$instance->upload($mform, $filemanager_options);
die;
// set file manager itemid, so it will find the files in draft area
$mform->set_data($data);
$mform->display();
-} else if ($instance->can_manage_responsefiles() && !($id==null)) { //a 'response' files upload
- // move submission files to user draft area
- $formdata = file_prepare_standard_filemanager($formdata, 'files', $filemanager_options, $context, 'mod_assignment', 'response', $submission->id);
- // set file manager itemid, so it will find the files in draft area
- $mform->set_data($formdata);
- $mform->display();
-} else {
+}else {
echo $OUTPUT->notification(get_string('uploaderror', 'assignment'));
echo $OUTPUT->continue_button(new moodle_url('/mod/assignment/view.php', array('id'=>$cm->id)));
}
$this->view_footer();
}
- function custom_feedbackform($submission, $return=false) {
- global $CFG, $OUTPUT;
- $mode = optional_param('mode', '', PARAM_ALPHA);
- $offset = optional_param('offset', 0, PARAM_INT);
-
- $fs = get_file_storage();
- if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', 'response', $submission->id, "timemodified", false)) {
- $str = get_string('editthisfile', 'assignment');
- } else {
- $str = get_string('uploadafile', 'assignment');
- }
-
- $output = get_string('responsefiles', 'assignment').': ';
-
- $output .= $OUTPUT->single_button(new moodle_url('/mod/assignment/type/uploadsingle/upload.php',
- array('contextid'=>$this->context->id,'id'=>$this->cm->id, 'offset'=>$offset,
- 'userid'=>$submission->userid, 'mode'=>$mode)), $str, 'get');
-
- $responsefiles = $this->print_responsefiles($submission->userid, true);
- if (!empty($responsefiles)) {
- $output .= $responsefiles;
+ function process_feedback() {
+ if (!$feedback = data_submitted() or !confirm_sesskey()) { // No incoming data?
+ return false;
}
-
- if ($return) {
- return $output;
+ $userid = required_param('userid', PARAM_INT);
+ $offset = required_param('offset', PARAM_INT);
+ $mform = $this->display_submission($offset, $userid, false);
+ parent::process_feedback($mform);
}
- echo $output;
- return;
- }
function print_responsefiles($userid, $return=false) {
global $CFG, $USER, $OUTPUT, $PAGE;
$options = array('subdirs'=>0, 'maxbytes'=>$CFG->userquota, 'maxfiles'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL);
-if ($id==null) {
$mform = new mod_assignment_uploadsingle_form(null, array('contextid'=>$contextid, 'userid'=>$formdata->userid, 'options'=>$options));
-} else {
- $formdata->cm->id = $id;
- $formdata->contextid = $contextid;
- $formdata->options = $options;
- $mform = new mod_assignment_uploadsingle_response_form(null, $formdata);
-}
if ($mform->is_cancelled()) {
- if ($id==null) {
redirect(new moodle_url('/mod/assignment/view.php', array('id'=>$cm->id)));
- } else {
- $instance->display_submission($formdata->offset, $formdata->userid);
- die();
- }
} else if ($mform->get_data()) {
$instance->upload($mform);
die();