NOBUG workshop: allows instant assessment for the teachers

If a user is allowed to allocate a submission to herself for assessment,
there is now a button that she can press to immediately allocate and
assess the submission.
This patch also contains various cleanups spotted during the work.
This commit is contained in:
David Mudrak
2010-06-08 23:10:43 +00:00
parent 5bab64a38b
commit ac239eba05
4 changed files with 20 additions and 8 deletions
-1
View File
@@ -54,7 +54,6 @@ $PAGE->set_url($workshop->assess_url($assessment->id));
$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(get_string('assessingsubmission', 'workshop'));
$currenttab = 'assessment';
$canviewallassessments = has_capability('mod/workshop:viewallassessments', $workshop->context);
$canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $workshop->context);
+2 -2
View File
@@ -106,7 +106,7 @@ $string['formatpeergrade'] = '<span class="grade">{$a->grade}</span> <span class
$string['formatpeergradeover'] = '<span class="grade">{$a->grade}</span> <span class="gradinggrade">(<del>{$a->gradinggrade}</del> / <ins>{$a->gradinggradeover}</ins>)</span>';
$string['formatpeergradeoverweighted'] = '<span class="grade">{$a->grade}</span> <span class="gradinggrade">(<del>{$a->gradinggrade}</del> / <ins>{$a->gradinggradeover}</ins>)</span> @ <span class="weight">{$a->weight}</span>';
$string['formatpeergradeweighted'] = '<span class="grade">{$a->grade}</span> <span class="gradinggrade">({$a->gradinggrade})</span> @ <span class="weight">{$a->weight}</span>';
$string['givengrades'] = 'Given grades';
$string['givengrades'] = 'Grades given';
$string['gradecalculated'] = 'Calculated grade for submission';
$string['gradedecimals'] = 'Decimal places in grades';
$string['gradegivento'] = '&gt;';
@@ -156,7 +156,7 @@ $string['phasesubmission'] = 'Submission phase';
$string['prepareexamples'] = 'Prepare example submissions';
$string['previewassessmentform'] = 'Preview';
$string['reassess'] = 'Re-assess';
$string['receivedgrades'] = 'Received grades';
$string['receivedgrades'] = 'Grades received';
$string['saveandclose'] = 'Save and close';
$string['saveandcontinue'] = 'Save and continue editing';
$string['saveandpreview'] = 'Save and preview';
+4 -4
View File
@@ -170,12 +170,12 @@ class workshop {
*/
public function __construct(stdclass $dbrecord, stdclass $cm, stdclass $course, stdclass $context=null) {
foreach ($dbrecord as $field => $value) {
$this->{$field} = $value;
if (property_exists('workshop', $field)) {
$this->{$field} = $value;
}
}
$this->cm = $cm;
$this->course = $course; // beware - this replaces the standard course field in the instance table
// this is intentional - IMO there should be no such field as it violates
// 3rd normal form with no real performance gain
$this->course = $course;
if (is_null($context)) {
$this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
} else {
+14 -1
View File
@@ -29,6 +29,7 @@ require_once(dirname(__FILE__).'/locallib.php');
$cmid = required_param('cmid', PARAM_INT); // course module id
$id = optional_param('id', 0, PARAM_INT); // submission id
$edit = optional_param('edit', false, PARAM_BOOL); // open for editing?
$assess = optional_param('assess', false, PARAM_BOOL); // instant assessment required
$cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
@@ -56,6 +57,7 @@ if ($id) { // submission is specified
$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);
$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 = $workshop->submitting_allowed();
@@ -69,6 +71,12 @@ if ($submission->id and ($ownsubmission or $canviewall or $isreviewer)) {
print_error('nopermissions');
}
if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop->assessing_allowed()) {
require_sesskey();
$assessmentid = $workshop->add_allocation($submission, $USER->id);
redirect($workshop->assess_url($assessmentid));
}
if ($edit and $ownsubmission) {
require_once(dirname(__FILE__).'/submission_form.php');
@@ -111,7 +119,7 @@ if ($edit and $ownsubmission) {
$formdata = file_postupdate_standard_filemanager($formdata, 'attachment', $attachmentopts, $workshop->context,
'workshop_submission_attachment', $formdata->id);
if (empty($formdata->attachment)) {
// explicit cas to zero integer
// explicit cast to zero integer
$formdata->attachment = 0;
}
// store the updated values or re-save the new submission (re-saving needed because URLs are now rewritten)
@@ -173,6 +181,11 @@ if ($ownsubmission and $editable) {
echo $OUTPUT->single_button($url, get_string('editsubmission', 'workshop'), 'get');
}
if ($submission->id and !$edit and !$isreviewer and $canallocate and $workshop->assessing_allowed()) {
$url = new moodle_url($PAGE->url, array('assess' => 1));
echo $OUTPUT->single_button($url, get_string('assess', 'workshop'), 'post');
}
// and possibly display the submission's review(s)
$canviewallassessments = false;