Workshop: submissions can be marked as published

This commit is contained in:
David Mudrak 2010-06-14 10:28:03 +00:00
parent e818c6fcc7
commit 232175e43a
6 changed files with 50 additions and 11 deletions

View File

@ -34,10 +34,17 @@ class workshop_feedbackauthor_form extends moodleform {
$current = $this->_customdata['current'];
$workshop = $this->_customdata['workshop'];
$opts = $this->_customdata['feedbackopts'];
$editoropts = $this->_customdata['editoropts'];
$options = $this->_customdata['options'];
$mform->addElement('header', 'feedbackauthorform', get_string('feedbackauthor', 'workshop'));
if (!empty($options['editablepublished'])) {
$mform->addElement('checkbox', 'published', get_string('publishsubmission', 'workshop'));
$mform->addHelpButton('published', 'publishsubmission', 'workshop');
$mform->setDefault('published', false);
}
$mform->addElement('static', 'grade', get_string('gradecalculated', 'workshop'));
$grades = array('' => get_string('notoverridden', 'workshop'));
@ -46,7 +53,7 @@ class workshop_feedbackauthor_form extends moodleform {
}
$mform->addElement('select', 'gradeover', get_string('gradeover', 'workshop'), $grades);
$mform->addElement('editor', 'feedbackauthor_editor', get_string('feedbackauthor', 'workshop'), null, $opts);
$mform->addElement('editor', 'feedbackauthor_editor', get_string('feedbackauthor', 'workshop'), null, $editoropts);
$mform->setType('feedbackauthor_editor', PARAM_RAW);
$mform->addElement('hidden', 'submissionid');

View File

@ -161,6 +161,8 @@ $string['phasesetup'] = 'Setup phase';
$string['phasesubmission'] = 'Submission phase';
$string['prepareexamples'] = 'Prepare example submissions';
$string['previewassessmentform'] = 'Preview';
$string['publishsubmission'] = 'Publish submission';
$string['publishsubmission_help'] = 'Published submissions are available to the others when the workshop is closed.';
$string['reassess'] = 'Re-assess';
$string['receivedgrades'] = 'Grades received';
$string['saveandclose'] = 'Save and close';

View File

@ -487,7 +487,7 @@ class workshop {
global $DB;
$sql = 'SELECT s.id, s.workshopid, s.example, s.authorid, s.timecreated, s.timemodified,
s.title, s.grade, s.gradeover, s.gradeoverby,
s.title, s.grade, s.gradeover, s.gradeoverby, s.published,
u.lastname AS authorlastname, u.firstname AS authorfirstname,
u.picture AS authorpicture, u.imagealt AS authorimagealt,
t.lastname AS overlastname, t.firstname AS overfirstname,
@ -1273,6 +1273,7 @@ class workshop {
$grades[$participant->userid]->submissiongrade = null;
$grades[$participant->userid]->submissiongradeover = null;
$grades[$participant->userid]->submissiongradeoverby = null;
$grades[$participant->userid]->submissionpublished = null;
$grades[$participant->userid]->reviewedby = array();
$grades[$participant->userid]->reviewerof = array();
}
@ -1285,6 +1286,7 @@ class workshop {
$grades[$submission->authorid]->submissiongrade = $this->real_grade($submission->grade);
$grades[$submission->authorid]->submissiongradeover = $this->real_grade($submission->gradeover);
$grades[$submission->authorid]->submissiongradeoverby = $submission->gradeoverby;
$grades[$submission->authorid]->submissionpublished = $submission->published;
}
unset($submissions);
unset($submission);
@ -1553,6 +1555,7 @@ class workshop {
$current = new stdclass();
$current->submissionid = $submission->id;
$current->published = $submission->published;
$current->grade = $this->real_grade($submission->grade);
$current->gradeover = $this->real_grade($submission->gradeover);
$current->feedbackauthor = $submission->feedbackauthor;
@ -1570,7 +1573,7 @@ class workshop {
$current = file_prepare_standard_editor($current, 'feedbackauthor', array());
return new workshop_feedbackauthor_form($actionurl,
array('workshop' => $this, 'current' => $current, 'feedbackopts' => array(), 'options' => $options),
array('workshop' => $this, 'current' => $current, 'editoropts' => array(), 'options' => $options),
'post', '', null, $editable);
}

View File

@ -478,6 +478,7 @@ class mod_workshop_renderer extends plugin_renderer_base {
foreach ($grades as $participant) {
$numofreceived = count($participant->reviewedby);
$numofgiven = count($participant->reviewerof);
$published = $participant->submissionpublished;
// compute the number of <tr> table rows needed to display this participant
if ($numofreceived > 0 and $numofgiven > 0) {
@ -500,6 +501,9 @@ class mod_workshop_renderer extends plugin_renderer_base {
for ($tr = 0; $tr < $numoftrs; $tr++) {
$row = new html_table_row();
if ($published) {
$row->attributes['class'] = 'published';
}
// column #1 - participant - spans over all rows
if ($tr == 0) {
$cell = new html_table_cell();

View File

@ -390,6 +390,11 @@
border: 1px solid #ddd;
}
.path-mod-workshop .grading-report .userpicture {
margin: 0px 3px;
vertical-align: middle;
}
.path-mod-workshop .grading-report del {
color: red;
font-size: 90%
@ -411,6 +416,14 @@
border: 1px solid #ddd;
}
.path-mod-workshop .grading-report tr.published td.submission {
background-color: #d2ebff;
}
.path-mod-workshop .grading-report tr.published td.submission a {
font-weight: bold;
}
.path-mod-workshop .grading-report .assessmentdetails {
white-space: nowrap;
}

View File

@ -62,6 +62,7 @@ $ownsubmission = $submission->authorid == $USER->id;
$canviewall = has_capability('mod/workshop:viewallsubmissions', $workshop->context);
$cansubmit = has_capability('mod/workshop:submit', $workshop->context);
$canallocate = has_capability('mod/workshop:allocate', $workshop->context);
$canpublish = has_capability('mod/workshop:publishsubmissions', $workshop->context);
$canoverride = (($workshop->phase == workshop::PHASE_EVALUATION) and has_capability('mod/workshop:overridegrades', $workshop->context));
$isreviewer = $DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $USER->id));
$editable = ($cansubmit and $ownsubmission and $workshop->submitting_allowed());
@ -143,17 +144,26 @@ if ($edit) {
}
}
// load the form to override gradinggrade and process the submitted data eventually
if (!$edit and $canoverride) {
$feedbackform = $workshop->get_feedbackauthor_form($PAGE->url, $submission);
// load the form to override grade and/or publish the submission and process the submitted data eventually
if (!$edit and ($canoverride or $canpublish)) {
$options = array(
'editable' => true,
'editablepublished' => $canpublish,
'overridablegrade' => $canoverride);
$feedbackform = $workshop->get_feedbackauthor_form($PAGE->url, $submission, $options);
if ($data = $feedbackform->get_data()) {
$data = file_postupdate_standard_editor($data, 'feedbackauthor', array(), $workshop->context);
$record = new stdclass();
$record->id = $submission->id;
$record->gradeover = $workshop->raw_grade_value($data->gradeover, $workshop->grade);
$record->gradeoverby = $USER->id;
$record->feedbackauthor = $data->feedbackauthor;
$record->feedbackauthorformat = $data->feedbackauthorformat;
if ($canoverride) {
$record->gradeover = $workshop->raw_grade_value($data->gradeover, $workshop->grade);
$record->gradeoverby = $USER->id;
$record->feedbackauthor = $data->feedbackauthor;
$record->feedbackauthorformat = $data->feedbackauthorformat;
}
if ($canpublish) {
$record->published = !empty($data->published);
}
$DB->update_record('workshop_submissions', $record);
redirect($workshop->view_url());
}