require_login($course, false, $cm); require_capability('mod/teamwork:editdimensions', $PAGE->context); $teamwork = $DB->get_record('teamwork', array('id' => $cm->instance), '*', MUST_EXIST); $teamwork = new teamwork($teamwork, $cm, $course); // todo: check if there already is some assessment done and do not allowed the change of the form // once somebody already used it to assess $PAGE->set_url($teamwork->editform_url()); $PAGE->set_title($teamwork->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('editingassessmentform', 'teamwork')); // load the grading strategy logic $strategy = $teamwork->grading_strategy_instance(); // load the form to edit the grading strategy dimensions $mform = $strategy->get_edit_strategy_form($PAGE->url); if ($mform->is_cancelled()) { redirect($teamwork->view_url()); } elseif ($data = $mform->get_data()) { if ($data->teamworkid != $teamwork->id or $data->strategy != $teamwork->strategy) { // this may happen if someone changes the teamwork setting while the user had the // editing form opened throw new invalid_parameter_exception('Invalid teamwork ID or the grading strategy has changed.'); } $strategy->save_edit_strategy_form($data); if (isset($data->saveandclose)) { redirect($teamwork->view_url()); } elseif (isset($data->saveandpreview)) { redirect($teamwork->previewform_url()); } else { // save and continue - redirect to self to prevent data being re-posted by pressing "Reload" redirect($PAGE->url); }
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()) { // ok you can go } else { print_error('nopermissions', 'error', $teamwork->view_url(), 'compare example assessment'); } $PAGE->set_title($teamwork->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('examplecomparing', 'teamwork')); // Output starts here $output = $PAGE->get_renderer('mod_teamwork'); echo $output->header(); echo $output->heading(format_string($teamwork->name)); echo $output->heading(get_string('assessedexample', 'teamwork'), 3); echo $output->render($teamwork->prepare_example_submission($example)); // if the reference assessment is available, display it if (!empty($mformreference)) { $options = array('showreviewer' => false, 'showauthor' => false, 'showform' => true); $reference = $teamwork->prepare_example_reference_assessment($reference, $mformreference, $options); $reference->title = get_string('assessmentreference', 'teamwork');
*/ require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_once dirname(__FILE__) . '/locallib.php'; $cmid = required_param('cmid', PARAM_INT); // course module $confirm = optional_param('confirm', false, PARAM_BOOL); // confirmation // the params to be re-passed to view.php $page = optional_param('page', 0, PARAM_INT); $sortby = optional_param('sortby', 'lastname', PARAM_ALPHA); $sorthow = optional_param('sorthow', 'ASC', PARAM_ALPHA); $cm = get_coursemodule_from_id('teamwork', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $teamwork = $DB->get_record('teamwork', array('id' => $cm->instance), '*', MUST_EXIST); $teamwork = new teamwork($teamwork, $cm, $course); $PAGE->set_url($teamwork->aggregate_url(), compact('confirm', 'page', 'sortby', 'sorthow')); require_login($course, false, $cm); require_capability('mod/teamwork:overridegrades', $PAGE->context); // load and init the grading evaluator $evaluator = $teamwork->grading_evaluation_instance(); $settingsform = $evaluator->get_settings_form($PAGE->url); if ($settingsdata = $settingsform->get_data()) { $teamwork->aggregate_submission_grades(); // updates 'grade' in {teamwork_submissions} $evaluator->update_grading_grades($settingsdata); // updates 'gradinggrade' in {teamwork_assessments} $teamwork->aggregate_grading_grades(); // updates 'gradinggrade' in {teamwork_aggregations} } redirect(new moodle_url($teamwork->view_url(), compact('page', 'sortby', 'sorthow')));
$teamworkrecord = $DB->get_record('teamwork', array('id' => $cm->instance), '*', MUST_EXIST); } else { $teamworkrecord = $DB->get_record('teamwork', array('id' => $w), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $teamworkrecord->course), '*', MUST_EXIST); $cm = get_coursemodule_from_instance('teamwork', $teamworkrecord->id, $course->id, false, MUST_EXIST); } require_login($course, true, $cm); require_capability('mod/teamwork:view', $PAGE->context); $teamwork = new teamwork($teamworkrecord, $cm, $course); // Mark viewed $completion = new completion_info($course); $completion->set_module_viewed($cm); $eventdata = array(); $eventdata['objectid'] = $teamwork->id; $eventdata['context'] = $teamwork->context; $PAGE->set_url($teamwork->view_url()); $event = \mod_teamwork\event\course_module_viewed::create($eventdata); $event->add_record_snapshot('course', $course); $event->add_record_snapshot('teamwork', $teamworkrecord); $event->add_record_snapshot('course_modules', $cm); $event->trigger(); if ($teamwork->applyover == 0 and $teamwork->applyend > 0 and $teamwork->applyend < time()) { generate_instanse_from_templet($teamwork->id); $DB->set_field('teamwork', 'applyover', 1, array('id' => $teamwork->id)); $teamwork->applyover = 1; } if (!is_null($editmode) && $PAGE->user_allowed_editing()) { $USER->editing = $editmode; } $PAGE->set_title($teamwork->name); $PAGE->set_heading($course->fullname);
// no example specified - create new one require_capability('mod/teamwork:manageexamples', $teamwork->context); $example = new stdclass(); $example->id = null; $example->authorid = $USER->id; $example->example = 1; } $canmanage = has_capability('mod/teamwork:manageexamples', $teamwork->context); $canassess = has_capability('mod/teamwork:peerassess', $teamwork->context); $refasid = $DB->get_field('teamwork_assessments', 'id', array('submissionid' => $example->id, 'weight' => 1)); if ($example->id and ($canmanage or $teamwork->assessing_examples_allowed() and $canassess)) { // ok you can go } elseif (is_null($example->id) and $canmanage) { // ok you can go } else { print_error('nopermissions', 'error', $teamwork->view_url(), 'view or manage example submission'); } if ($id and $delete and $confirm and $canmanage) { require_sesskey(); $teamwork->delete_submission($example); redirect($teamwork->view_url()); } if ($id and $assess and $canmanage) { // reference assessment of an example is the assessment with the weight = 1. There should be just one // such assessment require_sesskey(); if (!$refasid) { $refasid = $teamwork->add_allocation($example, $USER->id, 1); } redirect($teamwork->exassess_url($refasid)); }
// course module $phase = required_param('phase', PARAM_INT); // the code of the new phase $confirm = optional_param('confirm', false, PARAM_BOOL); // confirmation $cm = get_coursemodule_from_id('teamwork', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $teamwork = $DB->get_record('teamwork', array('id' => $cm->instance), '*', MUST_EXIST); $teamwork = new teamwork($teamwork, $cm, $course); $PAGE->set_url($teamwork->switchphase_url($phase), array('cmid' => $cmid, 'phase' => $phase)); require_login($course, false, $cm); require_capability('mod/teamwork:switchphase', $PAGE->context); if ($confirm) { if (!confirm_sesskey()) { throw new moodle_exception('confirmsesskeybad'); } if (!$teamwork->switch_phase($phase)) { print_error('errorswitchingphase', 'teamwork', $teamwork->view_url()); } redirect($teamwork->view_url()); } $PAGE->set_title($teamwork->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('switchingphase', 'teamwork')); // // Output starts here // echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($teamwork->name)); echo $OUTPUT->confirm(get_string('switchphase' . $phase . 'info', 'teamwork'), new moodle_url($PAGE->url, array('confirm' => 1)), $teamwork->view_url()); echo $OUTPUT->footer();
$teamworkid = required_param('teamworkid', PARAM_INT); $cm = get_coursemodule_from_instance('teamwork', $teamworkid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); $teamwork = $DB->get_record('teamwork', array('id' => $teamworkid), '*', MUST_EXIST); $teamwork = new teamwork($teamwork, $cm, $course); // todo: check if there already is some assessment done and do not allowed the change of the form // once somebody already used it to assess $jointeam_url = new moodle_url('/mod/teamwork/jointeam.php', array('teamworkid' => $teamworkid)); $PAGE->set_url($jointeam_url); $PAGE->set_title($teamwork->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('joininteam', 'teamwork')); $mform = new teamwork_jointeam_form($course->id, $teamworkid); if ($mform->is_cancelled()) { redirect($teamwork->view_url()); } elseif ($data = $mform->get_data()) { save_data($data); redirect($teamwork->view_url(), get_string('joinedsuccess', 'teamwork'), 1); } // Output starts here echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($teamwork->name)); $mform->display(); echo $OUTPUT->footer(); //////////////////////////////// function save_data($data) { global $DB, $USER; if (strlen($data->invitedkey) != 10) { redirect("jointeam.php?teamworkid={$data->teamworkid}", get_string('invalidinvitedkey', 'teamwork'), 1);
require_login($course, false, $cm); if (isguestuser()) { print_error('guestsarenotallowed'); } $teamwork = new teamwork($teamwork, $cm, $course); $PAGE->set_url($teamwork->exassess_url($assessment->id)); $PAGE->set_title($teamwork->name); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(get_string('assessingexample', 'teamwork')); $currenttab = 'assessment'; $canmanage = has_capability('mod/teamwork:manageexamples', $teamwork->context); $isreviewer = $USER->id == $assessment->reviewerid; if ($isreviewer or $canmanage) { // such a user can continue } else { print_error('nopermissions', 'error', $teamwork->view_url(), 'assess example submission'); } // only the reviewer is allowed to modify the assessment if ($canmanage and $assessment->weight == 1 or $isreviewer and $teamwork->assessing_examples_allowed()) { $assessmenteditable = true; } else { $assessmenteditable = false; } // load the grading strategy logic $strategy = $teamwork->grading_strategy_instance(); // load the assessment form and process the submitted data eventually $mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable); // Set data managed by the teamwork core, subplugins set their own data themselves. $currentdata = (object) array('feedbackauthor' => $assessment->feedbackauthor, 'feedbackauthorformat' => $assessment->feedbackauthorformat); if ($assessmenteditable and $teamwork->overallfeedbackmode) { $currentdata = file_prepare_standard_editor($currentdata, 'feedbackauthor', $teamwork->overall_feedback_content_options(), $teamwork->context, 'mod_teamwork', 'overallfeedback_content', $assessment->id);
if (groups_get_activity_groupmode($teamwork->cm) == SEPARATEGROUPS) { // user must have accessallgroups or share at least one group with the submission author if (!has_capability('moodle/site:accessallgroups', $teamwork->context)) { $usersgroups = groups_get_activity_allowed_groups($teamwork->cm); $authorsgroups = groups_get_all_groups($teamwork->course->id, $submission->authorid, $teamwork->cm->groupingid, 'g.id'); $sharedgroups = array_intersect_key($usersgroups, $authorsgroups); if (empty($sharedgroups)) { $canviewallsubmissions = false; } } } } if ($isreviewer or $isauthor or $canviewallassessments and $canviewallsubmissions) { // such a user can continue } else { print_error('nopermissions', 'error', $teamwork->view_url(), 'view this assessment'); } if ($isauthor and !$isreviewer and !$canviewallassessments and $teamwork->phase != teamwork::PHASE_CLOSED) { // authors can see assessments of their work at the end of teamwork only print_error('nopermissions', 'error', $teamwork->view_url(), 'view assessment of own work before teamwork is closed'); } // only the reviewer is allowed to modify the assessment if ($isreviewer and $teamwork->assessing_allowed($USER->id)) { $assessmenteditable = true; } else { $assessmenteditable = false; } // check that all required examples have been assessed by the user if ($assessmenteditable and $teamwork->useexamples and $teamwork->examplesmode == teamwork::EXAMPLES_BEFORE_ASSESSMENT and !has_capability('mod/teamwork:manageexamples', $teamwork->context)) { // the reviewer must have submitted their own submission $reviewersubmission = $teamwork->get_submission_by_author($assessment->reviewerid);