示例#1
0
require_once dirname(__FILE__) . '/locallib.php';
$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