mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
VIP Assessment review
This commit is contained in:
parent
1696f36cf2
commit
407b1e9177
6 changed files with 74 additions and 91 deletions
|
@ -16,10 +16,18 @@
|
|||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Assess a submission or preview the assessment form
|
||||
* Assess a submission or view the single assessment
|
||||
*
|
||||
* Displays an assessment form and saves the grades given by current user (reviewer)
|
||||
* for the dimensions.
|
||||
* Assessment id parameter must be passed. The script displays the submission and
|
||||
* the assessment form. If the current user is the reviewer and the assessing is
|
||||
* allowed, new assessment can be saved.
|
||||
* If the assessing is not allowed (for example, the assessment period is over
|
||||
* or the current user is eg a teacher), the assessment form is opened
|
||||
* in a non-editable mode.
|
||||
* The capability 'mod/workshop:peerassess' is intentionally not checked here.
|
||||
* The user is considered as a reviewer if the corresponding assessment record
|
||||
* has been prepared for him/her (during the allocation). So even a user without the
|
||||
* peerassess capability (like a 'teacher', for example) can become a reviewer.
|
||||
*
|
||||
* @package mod-workshop
|
||||
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
|
||||
|
@ -29,23 +37,12 @@
|
|||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once(dirname(__FILE__).'/locallib.php');
|
||||
|
||||
if ($preview = optional_param('preview', 0, PARAM_INT)) {
|
||||
$mode = 'preview';
|
||||
$cm = get_coursemodule_from_id('workshop', $preview, 0, false, MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
$workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
|
||||
$submission = new stdClass();
|
||||
$assessment = new stdClass();
|
||||
|
||||
} else {
|
||||
$mode = 'assessment';
|
||||
$asid = required_param('asid', PARAM_INT); // assessment id
|
||||
$assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST);
|
||||
$submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid), '*', MUST_EXIST);
|
||||
$workshop = $DB->get_record('workshop', array('id' => $submission->workshopid), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST);
|
||||
}
|
||||
$asid = required_param('asid', PARAM_INT); // assessment id
|
||||
$assessment = $DB->get_record('workshop_assessments', array('id' => $asid), '*', MUST_EXIST);
|
||||
$submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid), '*', MUST_EXIST);
|
||||
$workshop = $DB->get_record('workshop', array('id' => $submission->workshopid), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $workshop->course), '*', MUST_EXIST);
|
||||
$cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id, false, MUST_EXIST);
|
||||
|
||||
require_login($course, false, $cm);
|
||||
if (isguestuser()) {
|
||||
|
@ -53,75 +50,57 @@ if (isguestuser()) {
|
|||
}
|
||||
$workshop = new workshop($workshop, $cm, $course);
|
||||
|
||||
if ('preview' == $mode) {
|
||||
require_capability('mod/workshop:editdimensions', $PAGE->context);
|
||||
$PAGE->set_url($workshop->previewform_url());
|
||||
$PAGE->set_title($workshop->name);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->navbar->add(get_string('editingassessmentform', 'workshop'), $workshop->editform_url(), navigation_node::TYPE_CUSTOM);
|
||||
$PAGE->navbar->add(get_string('previewassessmentform', 'workshop'));
|
||||
$currenttab = 'editform';
|
||||
$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';
|
||||
|
||||
} elseif ('assessment' == $mode) {
|
||||
// we do not require 'mod/workshop:peerassess' here, we just check that the assessment record
|
||||
// has been prepared for the current user. So even a user without the peerassess capability
|
||||
// (like a 'teacher', for example) can become a reviewer
|
||||
if ($USER->id !== $assessment->reviewerid) {
|
||||
print_error('nopermissions', '', $workshop->view_url());
|
||||
}
|
||||
$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);
|
||||
$isreviewer = ($USER->id == $assessment->reviewerid);
|
||||
$isauthor = ($USER->id == $submission->authorid);
|
||||
|
||||
if ($isreviewer or $isauthor or ($canviewallassessments and $canviewallsubmissions)) {
|
||||
// such a user can continue
|
||||
} else {
|
||||
print_error('nopermissions', '', $workshop->view_url());
|
||||
}
|
||||
|
||||
// only the reviewer is allowed to modify the assessment
|
||||
if ($isreviewer and $workshop->assessing_allowed()) {
|
||||
$editable = true;
|
||||
} else {
|
||||
$editable = false;
|
||||
}
|
||||
|
||||
// load the grading strategy logic
|
||||
$strategy = $workshop->grading_strategy_instance();
|
||||
|
||||
// load the form to edit the grading strategy dimensions
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, $mode, $assessment);
|
||||
// load the assessment form
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $editable);
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($workshop->view_url());
|
||||
|
||||
} elseif ($data = $mform->get_data()) {
|
||||
if (isset($data->backtoeditform)) {
|
||||
// user wants to return from preview to form editing
|
||||
redirect($workshop->editform_url());
|
||||
}
|
||||
} elseif ($editable and ($data = $mform->get_data())) {
|
||||
$rawgrade = $strategy->save_assessment($assessment, $data);
|
||||
if (!is_null($rawgrade) and isset($data->saveandclose)) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('assessmentresult', 'workshop'), 2);
|
||||
echo $OUTPUT->box('Given grade: ' . $rawgrade . ' %'); // todo more detailed info using own renderer, format grade
|
||||
echo $OUTPUT->continue_button($workshop->view_url());
|
||||
echo $OUTPUT->footer();
|
||||
die(); // bye-bye
|
||||
redirect($workshop->view_url());
|
||||
} else {
|
||||
// either it is not possible to calculate the $rawgrade or the reviewer has chosen "Save and continue"
|
||||
// redirect to self to prevent data being re-posted by pressing "Reload"
|
||||
// either it is not possible to calculate the $rawgrade
|
||||
// or the reviewer has chosen "Save and continue"
|
||||
redirect($PAGE->url);
|
||||
}
|
||||
}
|
||||
|
||||
// Output starts here
|
||||
|
||||
// output starts here
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('assessmentform', 'workshop'), 2);
|
||||
|
||||
if ('assessment' === $mode) {
|
||||
if (has_capability('mod/workshop:viewauthornames', $PAGE->context)) {
|
||||
$showname = true;
|
||||
$author = $workshop->user_info($submission->authorid);
|
||||
} else {
|
||||
$showname = false;
|
||||
$author = null;
|
||||
}
|
||||
$wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE); // workshop renderer
|
||||
$submission = $workshop->get_submission_by_id($submission->id); // reload so can be passed to the renderer
|
||||
echo $wsoutput->submission_full($submission, $showname);
|
||||
}
|
||||
$wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE); // workshop renderer
|
||||
$submission = $workshop->get_submission_by_id($submission->id); // reload so can be passed to the renderer
|
||||
echo $wsoutput->submission_full($submission, has_capability('mod/workshop:viewauthornames', $workshop->context));
|
||||
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
|
|
|
@ -56,7 +56,6 @@ $string['assessmentcomps'] = 'Required level of assessments similarity';
|
|||
$string['assessmentdeleted'] = 'Assessment deallocated';
|
||||
$string['assessmentend'] = 'End of assessment phase';
|
||||
$string['assessmentform'] = 'Assessment form';
|
||||
$string['assessmentresult'] = 'Assessment result';
|
||||
$string['assessmentsettings'] = 'Assessment settings';
|
||||
$string['assessmentstart'] = 'Start of assessment phase';
|
||||
$string['assignedassessments'] = 'Assigned submissions to assess';
|
||||
|
|
|
@ -599,22 +599,6 @@ class workshop {
|
|||
return new moodle_url($CFG->wwwroot . '/mod/workshop/aggregate.php', array('cmid' => $this->cm->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object containing all data to display the user's full name and picture
|
||||
*
|
||||
* @param int $id optional user id, defaults to the current user
|
||||
* @return stdClass containing properties lastname, firstname, picture and imagealt
|
||||
*/
|
||||
public function user_info($id=null) {
|
||||
global $USER, $DB;
|
||||
|
||||
if (is_null($id) || ($id == $USER->id)) {
|
||||
return $USER;
|
||||
} else {
|
||||
return $DB->get_record('user', array('id' => $id), 'id,lastname,firstname,picture,imagealt', MUST_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Are users allowed to create/edit their submissions?
|
||||
*
|
||||
|
@ -626,6 +610,18 @@ class workshop {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Are reviewers allowed to create/edit their assessments?
|
||||
*
|
||||
* TODO: this depends on the workshop phase, phase deadlines
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function assessing_allowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Are the peer-reviews available to the authors?
|
||||
*
|
||||
|
|
|
@ -623,6 +623,8 @@ class moodle_mod_workshop_renderer extends moodle_renderer_base {
|
|||
* @return string
|
||||
*/
|
||||
protected function grading_report_assessment(stdClass $assessment, $shownames, array $userinfo, $separator) {
|
||||
global $CFG;
|
||||
|
||||
if (is_null($assessment)) {
|
||||
return get_string('nullgrade', 'workshop');
|
||||
}
|
||||
|
@ -635,7 +637,12 @@ class moodle_mod_workshop_renderer extends moodle_renderer_base {
|
|||
$a->gradinggradeover = $assessment->gradinggradeover;
|
||||
$grade = get_string('formatpeergradeover', 'workshop', $a);
|
||||
}
|
||||
$grade = $this->output->output_tag('span', array('class' => 'grade'), $grade);
|
||||
$link = new html_link();
|
||||
$link->text = $grade;
|
||||
$link->url = new moodle_url($CFG->wwwroot . '/mod/workshop/assessment.php',
|
||||
array('asid' => $assessment->assessmentid));
|
||||
$link->set_classes('grade');
|
||||
$grade = $this->output->link($link);
|
||||
|
||||
if ($shownames) {
|
||||
$userid = $assessment->userid;
|
||||
|
|
|
@ -328,12 +328,15 @@
|
|||
|
||||
/* Rubric - list layout */
|
||||
|
||||
.mod-workshop .mform.frozen .fitem.description.rubric + .fitem .fitemtitle,
|
||||
.mod-workshop .assessmentform.rubric.list .fitem .fitemtitle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mod-workshop .mform.frozen .fitem.description.rubric + .fitem .fitemtitle + .felement,
|
||||
.mod-workshop .assessmentform.rubric.list .fitem .felement {
|
||||
width: auto;
|
||||
width: auto%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.mod-workshop .assessmentform.rubric.list .fitem .felement span {
|
||||
|
|
|
@ -173,13 +173,12 @@ if ($isreviewer) {
|
|||
}
|
||||
|
||||
if ($isreviewer) {
|
||||
// display own assessment
|
||||
$assessment =
|
||||
// display own assessment - todo
|
||||
$strategy = $workshop->grading_strategy_instance();
|
||||
}
|
||||
|
||||
if ($canviewallassessments) {
|
||||
// display all assessments (except the eventual own one - that has been already displayed
|
||||
// display all assessments (except the eventual own one - that has been already displayed) - todo
|
||||
$strategy = $workshop->grading_strategy_instance();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue