MDL-23459 workshop: fixed support for late submissions
This commit is contained in:
@@ -75,6 +75,7 @@ $string['configgradedecimals'] = 'Default number of digits that should be shown
|
||||
$string['configgradinggrade'] = 'Default maximum grade for assessment in workshops';
|
||||
$string['configmaxbytes'] = 'Default maximum submission file size for all workshops on the site (subject to course limits and other local settings)';
|
||||
$string['configstrategy'] = 'Default grading strategy for workshops';
|
||||
$string['createsubmission'] = 'Submit';
|
||||
$string['daysago'] = '{$a} days ago';
|
||||
$string['daysleft'] = '{$a} days left';
|
||||
$string['daystoday'] = 'today';
|
||||
@@ -141,6 +142,7 @@ $string['introduction'] = 'Introduction';
|
||||
$string['latesubmissions'] = 'Late submissions';
|
||||
$string['latesubmissions_desc'] = 'Allow submissions after the deadline';
|
||||
$string['latesubmissions_help'] = 'If enabled, a student may submit their work after the submissions deadline or during the assessment phase. Late submissions cannot be edited though.';
|
||||
$string['latesubmissionsallowed'] = 'Late submissions are allowed';
|
||||
$string['maxbytes'] = 'Maximum file size';
|
||||
$string['messageclose'] = '(X)';
|
||||
$string['modulename'] = 'Workshop';
|
||||
|
||||
@@ -1047,25 +1047,61 @@ class workshop {
|
||||
}
|
||||
|
||||
/**
|
||||
* Are users allowed to create/edit their submissions?
|
||||
* Are users allowed to create their submissions?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function submitting_allowed() {
|
||||
public function creating_submission_allowed() {
|
||||
$now = time();
|
||||
|
||||
if ($this->latesubmissions) {
|
||||
if ($this->phase != self::PHASE_SUBMISSION and $this->phase != self::PHASE_ASSESSMENT) {
|
||||
// late submissions are allowed in the submission and assessment phase only
|
||||
return false;
|
||||
}
|
||||
if (!empty($this->submissionstart) and $this->submissionstart > $now) {
|
||||
// late submissions are not allowed before the submission start
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
if ($this->phase != self::PHASE_SUBMISSION) {
|
||||
// submissions are allowed during the submission phase only
|
||||
return false;
|
||||
}
|
||||
if (!empty($this->submissionstart) and $this->submissionstart > $now) {
|
||||
// if enabled, submitting is not allowed before the date/time defined in the mod_form
|
||||
return false;
|
||||
}
|
||||
if (!empty($this->submissionend) and $now > $this->submissionend ) {
|
||||
// if enabled, submitting is not allowed after the date/time defined in the mod_form unless late submission is allowed
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Are users allowed to modify their existing submission?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function modifying_submission_allowed() {
|
||||
$now = time();
|
||||
|
||||
if ($this->phase != self::PHASE_SUBMISSION) {
|
||||
// submitting is not allowed but in the submission phase
|
||||
// submissions can be edited during the submission phase only
|
||||
return false;
|
||||
}
|
||||
$now = time();
|
||||
if (!empty($this->submissionstart) and $this->submissionstart > $now) {
|
||||
// if enabled, submitting is not allowed before the date/time defined in the mod_form
|
||||
return false;
|
||||
}
|
||||
if (!empty($this->submissionend) and empty($this->latesubmissions) and $now > $this->submissionend ) {
|
||||
if (!empty($this->submissionend) and $now > $this->submissionend) {
|
||||
// if enabled, submitting is not allowed after the date/time defined in the mod_form unless late submission is allowed
|
||||
return false;
|
||||
}
|
||||
// here we go, submission is allowed
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2062,6 +2098,12 @@ class workshop_user_plan implements renderable {
|
||||
$task->completed = 'info';
|
||||
$phase->tasks['submissionenddatetime'] = $task;
|
||||
}
|
||||
if (($workshop->submissionstart < time()) and $workshop->latesubmissions) {
|
||||
$task = new stdclass();
|
||||
$task->title = get_string('latesubmissionsallowed', 'workshop');
|
||||
$task->completed = 'info';
|
||||
$phase->tasks['latesubmissionsallowed'] = $task;
|
||||
}
|
||||
$this->phases[workshop::PHASE_SUBMISSION] = $phase;
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
||||
@@ -67,7 +67,15 @@ $canpublish = has_capability('mod/workshop:publishsubmissions', $workshop->c
|
||||
$canoverride = (($workshop->phase == workshop::PHASE_EVALUATION) and has_capability('mod/workshop:overridegrades', $workshop->context));
|
||||
$userassessment = $workshop->get_assessment_of_submission_by_user($submission->id, $USER->id);
|
||||
$isreviewer = !empty($userassessment);
|
||||
$editable = ($cansubmit and $ownsubmission and $workshop->submitting_allowed());
|
||||
$editable = ($cansubmit and $ownsubmission);
|
||||
|
||||
if (empty($submission->id) and !$workshop->creating_submission_allowed()) {
|
||||
$editable = false;
|
||||
}
|
||||
if ($submission->id and !$workshop->modifying_submission_allowed()) {
|
||||
$editable = false;
|
||||
}
|
||||
|
||||
if ($editable and $workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION
|
||||
and !has_capability('mod/workshop:manageexamples', $workshop->context)) {
|
||||
// check that all required examples have been assessed by the user
|
||||
@@ -127,6 +135,13 @@ if ($edit) {
|
||||
$formdata->content = ''; // updated later
|
||||
$formdata->contentformat = FORMAT_HTML; // updated later
|
||||
$formdata->contenttrust = 0; // updated later
|
||||
$formdata->late = 0x0; // bit mask
|
||||
if (!empty($workshop->submissionend) and ($workshop->submissionend < time())) {
|
||||
$formdata->late = $formdata->late | 0x1;
|
||||
}
|
||||
if ($workshop->phase == workshop::PHASE_ASSESSMENT) {
|
||||
$formdata->late = $formdata->late | 0x2;
|
||||
}
|
||||
if (empty($formdata->id)) {
|
||||
$formdata->id = $DB->insert_record('workshop_submissions', $formdata);
|
||||
// todo add to log
|
||||
@@ -214,8 +229,14 @@ if ($submission->id) {
|
||||
}
|
||||
|
||||
if ($editable) {
|
||||
$url = new moodle_url($PAGE->url, array('edit' => 'on', 'id' => $submission->id));
|
||||
echo $OUTPUT->single_button($url, get_string('editsubmission', 'workshop'), 'get');
|
||||
if ($submission->id) {
|
||||
$btnurl = new moodle_url($PAGE->url, array('edit' => 'on', 'id' => $submission->id));
|
||||
$btntxt = get_string('editsubmission', 'workshop');
|
||||
} else {
|
||||
$btnurl = new moodle_url($PAGE->url, array('edit' => 'on'));
|
||||
$btntxt = get_string('createsubmission', 'workshop');
|
||||
}
|
||||
echo $OUTPUT->single_button($btnurl, $btntxt, 'get');
|
||||
}
|
||||
|
||||
if ($submission->id and !$edit and !$isreviewer and $canallocate and $workshop->assessing_allowed()) {
|
||||
|
||||
+61
-8
@@ -102,7 +102,11 @@ case workshop::PHASE_SUBMISSION:
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
|
||||
$examplesdone = (!$workshop->useexamples or has_capability('mod/workshop:manageexamples', $workshop->context));
|
||||
// does the user have to assess examples before submitting their own work?
|
||||
$examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION);
|
||||
|
||||
// is the assessment of example submissions considered finished?
|
||||
$examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context);
|
||||
if ($workshop->assessing_examples_allowed()
|
||||
and has_capability('mod/workshop:submit', $workshop->context)
|
||||
and ! has_capability('mod/workshop:manageexamples', $workshop->context)) {
|
||||
@@ -137,17 +141,24 @@ case workshop::PHASE_SUBMISSION:
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
|
||||
if (has_capability('mod/workshop:submit', $PAGE->context) and $examplesdone) {
|
||||
if (has_capability('mod/workshop:submit', $PAGE->context) and (!$examplesmust or $examplesdone)) {
|
||||
print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'));
|
||||
echo $output->box_start('generalbox ownsubmission');
|
||||
if ($submission = $workshop->get_submission_by_author($USER->id)) {
|
||||
echo $output->submission_summary($submission, true);
|
||||
if ($workshop->modifying_submission_allowed()) {
|
||||
$btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
|
||||
$btntxt = get_string('editsubmission', 'workshop');
|
||||
}
|
||||
} else {
|
||||
echo $output->container(get_string('noyoursubmission', 'workshop'));
|
||||
if ($workshop->creating_submission_allowed()) {
|
||||
$btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
|
||||
$btntxt = get_string('createsubmission', 'workshop');
|
||||
}
|
||||
}
|
||||
if ($workshop->submitting_allowed()) {
|
||||
$aurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
|
||||
echo $output->single_button($aurl, get_string('editsubmission', 'workshop'), 'get');
|
||||
if (!empty($btnurl)) {
|
||||
echo $output->single_button($btnurl, $btntxt, 'get');
|
||||
}
|
||||
echo $output->box_end();
|
||||
print_collapsible_region_end();
|
||||
@@ -170,6 +181,31 @@ case workshop::PHASE_SUBMISSION:
|
||||
break;
|
||||
|
||||
case workshop::PHASE_ASSESSMENT:
|
||||
|
||||
$ownsubmissionexists = null;
|
||||
if (has_capability('mod/workshop:submit', $PAGE->context)) {
|
||||
if ($ownsubmission = $workshop->get_submission_by_author($USER->id)) {
|
||||
print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'), false, true);
|
||||
echo $output->box_start('generalbox ownsubmission');
|
||||
echo $output->submission_summary($ownsubmission, true);
|
||||
$ownsubmissionexists = true;
|
||||
} else {
|
||||
print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop'));
|
||||
echo $output->box_start('generalbox ownsubmission');
|
||||
echo $output->container(get_string('noyoursubmission', 'workshop'));
|
||||
$ownsubmissionexists = false;
|
||||
if ($workshop->creating_submission_allowed()) {
|
||||
$btnurl = new moodle_url($workshop->submission_url(), array('edit' => 'on'));
|
||||
$btntxt = get_string('createsubmission', 'workshop');
|
||||
}
|
||||
}
|
||||
if (!empty($btnurl)) {
|
||||
echo $output->single_button($btnurl, $btntxt, 'get');
|
||||
}
|
||||
echo $output->box_end();
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
|
||||
if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$sortby = optional_param('sortby', 'lastname', PARAM_ALPHA);
|
||||
@@ -206,10 +242,27 @@ case workshop::PHASE_ASSESSMENT:
|
||||
echo $output->box(format_text($instructions, $workshop->instructreviewersformat), array('generalbox', 'instructions'));
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
$examplesdone = (!$workshop->useexamples or has_capability('mod/workshop:manageexamples', $workshop->context));
|
||||
|
||||
// does the user have to assess examples before assessing other's work?
|
||||
$examplesmust = ($workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_ASSESSMENT);
|
||||
|
||||
// is the assessment of example submissions considered finished?
|
||||
$examplesdone = has_capability('mod/workshop:manageexamples', $workshop->context);
|
||||
|
||||
// can the examples be assessed?
|
||||
$examplesavailable = true;
|
||||
|
||||
if (!$examplesdone and $examplesmust and ($ownsubmissionexists === false)) {
|
||||
print_collapsible_region_start('', 'workshop-viewlet-examplesfail', get_string('exampleassessments', 'workshop'));
|
||||
echo $output->box(get_string('exampleneedsubmission', 'workshop'));
|
||||
print_collapsible_region_end();
|
||||
$examplesavailable = false;
|
||||
}
|
||||
|
||||
if ($workshop->assessing_examples_allowed()
|
||||
and has_capability('mod/workshop:submit', $workshop->context)
|
||||
and ! has_capability('mod/workshop:manageexamples', $workshop->context)) {
|
||||
and ! has_capability('mod/workshop:manageexamples', $workshop->context)
|
||||
and $examplesavailable) {
|
||||
$examples = $userplan->get_examples();
|
||||
$total = count($examples);
|
||||
$left = 0;
|
||||
@@ -240,7 +293,7 @@ case workshop::PHASE_ASSESSMENT:
|
||||
echo $output->box_end();
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
if ($examplesdone) {
|
||||
if (!$examplesmust or $examplesdone) {
|
||||
print_collapsible_region_start('', 'workshop-viewlet-assignedassessments', get_string('assignedassessments', 'workshop'));
|
||||
if (! $assessments = $workshop->get_assessments_by_reviewer($USER->id)) {
|
||||
echo $output->box_start('generalbox assessment-none');
|
||||
|
||||
Reference in New Issue
Block a user