Пример #1
0
$cmid = required_param('cmid', PARAM_INT);
// course module id
$sid = required_param('sid', PARAM_INT);
// example submission id
$aid = required_param('aid', PARAM_INT);
// the user's assessment id
$cm = get_coursemodule_from_id('teamwork', $cmid, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_login($course, false, $cm);
if (isguestuser()) {
    print_error('guestsarenotallowed');
}
$teamwork = $DB->get_record('teamwork', array('id' => $cm->instance), '*', MUST_EXIST);
$teamwork = new teamwork($teamwork, $cm, $course);
$strategy = $teamwork->grading_strategy_instance();
$PAGE->set_url($teamwork->excompare_url($sid, $aid));
$example = $teamwork->get_example_by_id($sid);
$assessment = $teamwork->get_assessment_by_id($aid);
if ($assessment->submissionid != $example->id) {
    print_error('invalidarguments');
}
$mformassessment = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, false);
if ($refasid = $DB->get_field('teamwork_assessments', 'id', array('submissionid' => $example->id, 'weight' => 1))) {
    $reference = $teamwork->get_assessment_by_id($refasid);
    $mformreference = $strategy->get_assessment_form($PAGE->url, 'assessment', $reference, false);
}
$canmanage = has_capability('mod/teamwork:manageexamples', $teamwork->context);
$isreviewer = $USER->id == $assessment->reviewerid;
if ($canmanage) {
    // ok you can go
} elseif ($isreviewer and $teamwork->assessing_examples_allowed()) {
Пример #2
0
            $coredata->feedbackauthorattachment = 0;
        }
    }
    if ($canmanage) {
        // Remember the last one who edited the reference assessment.
        $coredata->reviewerid = $USER->id;
    }
    // Update the assessment data if there is something other than just the 'id'.
    if (count((array) $coredata) > 1) {
        $DB->update_record('teamwork_assessments', $coredata);
    }
    if (!is_null($rawgrade) and isset($data->saveandclose)) {
        if ($canmanage) {
            redirect($teamwork->view_url());
        } else {
            redirect($teamwork->excompare_url($example->id, $assessment->id));
        }
    } else {
        // either it is not possible to calculate the $rawgrade
        // or the reviewer has chosen "Save and continue"
        redirect($PAGE->url);
    }
}
// output starts here
$output = $PAGE->get_renderer('mod_teamwork');
// teamwork renderer
echo $output->header();
echo $output->heading(format_string($teamwork->name));
echo $output->heading(get_string('assessedexample', 'teamwork'), 3);
$example = $teamwork->get_example_by_id($example->id);
// reload so can be passed to the renderer