print_error(get_string('invalidaccess', 'mod_emarking')); } echo $OUTPUT->header(); // Heading and tabs if we are within a course module. echo $OUTPUT->heading($emarking->name); echo $OUTPUT->tabtree(emarking_tabs($context, $cm, $emarking), "pages"); // Get rubric instance. list($gradingmanager, $gradingmethod, $definition) = emarking_validate_rubric($context, false, false); $maxpages = $DB->get_record_sql("\nSELECT MAX(p.page) AS maxpages\nFROM {emarking_page} p\nINNER JOIN {emarking_submission} s ON (p.submission = s.id AND s.emarking=:emarking)\nGROUP BY s.emarking", array("emarking" => $emarking->id)); $totalpages = $exam->totalpages; if ($maxpages) { $totalpages = max($exam->totalpages, $maxpages->maxpages); } $mformpages = new emarking_pages_form(null, array('context' => $context, 'criteria' => $definition->rubric_criteria, 'id' => $cm->id, 'emarking' => $emarking, "totalpages" => $totalpages, "action" => "addpages")); if ($mformpages->get_data()) { $newpages = process_mform($mformpages, "addpages", $emarking); } if ($action === 'deletepages') { $DB->delete_records('emarking_page_criterion', array('emarking' => $emarking->id, 'criterion' => $criterion->id)); echo $OUTPUT->notification(get_string("transactionsuccessfull", "mod_emarking"), 'notifysuccess'); } else { if ($action === 'deletepagesingle') { $DB->delete_records('emarking_page_criterion', array('emarking' => $emarking->id, 'criterion' => $criterion->id, 'page' => $pageid)); echo $OUTPUT->notification(get_string("transactionsuccessfull", "mod_emarking"), 'notifysuccess'); } } $numpagescriteria = $DB->count_records("emarking_page_criterion", array("emarking" => $emarking->id)); $pagecriteria = $DB->get_recordset_sql("\n SELECT\n id,\n description,\n GROUP_CONCAT(page) AS pages,\n sortorder\n FROM (\n SELECT c.id, c.description, c.sortorder, mc.page\n FROM {gradingform_rubric_criteria} c\n LEFT JOIN {emarking_page_criterion} mc ON (c.definitionid = :definition AND mc.emarking = :emarking AND c.id = mc.criterion)\n WHERE c.definitionid = :definition2\n ORDER BY c.id ASC, mc.page ASC) as T\n GROUP BY id\n ORDER BY sortorder", array("definition" => $definition->id, "definition2" => $definition->id, "emarking" => $emarking->id)); $data = array(); foreach ($pagecriteria as $d) { $urldelete = new moodle_url('/mod/emarking/marking/pages.php', array('id' => $cm->id, 'criterion' => $d->id, 'action' => 'deletepages'));
// Verify capability for security issues. if (!has_capability('mod/emarking:assignmarkers', $context)) { $item = array('context' => $context, 'objectid' => $emarking->id); // Add to Moodle log so some auditing can be done. \mod_emarking\event\unauthorizedaccess_attempted::create($item)->trigger(); print_error(get_string('invalidaccess', 'mod_emarking')); } echo $OUTPUT->header(); // Heading and tabs if we are within a course module. echo $OUTPUT->heading($emarking->name); echo $OUTPUT->tabtree(emarking_tabs($context, $cm, $emarking), "markers"); // Get rubric instance. list($gradingmanager, $gradingmethod, $definition) = emarking_validate_rubric($context, false, false); $mformmarkers = new emarking_markers_form(null, array('context' => $context, 'criteria' => $definition->rubric_criteria, 'id' => $cm->id, 'totalpages' => $exam->totalpages, 'emarking' => $emarking, "action" => "addmarkers")); if ($mformmarkers->get_data()) { $newmarkers = process_mform($mformmarkers, "addmarkers", $emarking); } if ($action === 'deletemarkers') { $DB->delete_records('emarking_marker_criterion', array('emarking' => $emarking->id, 'criterion' => $criterion->id)); echo $OUTPUT->notification(get_string("transactionsuccessfull", "mod_emarking"), 'notifysuccess'); } else { if ($action === 'deletesinglemarker') { $DB->delete_records('emarking_marker_criterion', array('emarking' => $emarking->id, 'marker' => $markerid, 'criterion' => $criterion->id)); echo $OUTPUT->notification(get_string("transactionsuccessfull", "mod_emarking"), 'notifysuccess'); } } $nummarkerscriteria = $DB->count_records("emarking_marker_criterion", array("emarking" => $emarking->id)); $markercriteria = $DB->get_recordset_sql("\n SELECT\n id,\n description,\n GROUP_CONCAT(uid) AS markers,\n sortorder\n FROM (\n SELECT\n c.id,\n c.description,\n c.sortorder,\n u.id as uid\n FROM {gradingform_rubric_criteria} c\n LEFT JOIN {emarking_marker_criterion} mc ON (c.definitionid = :definition AND mc.emarking = :emarking AND c.id = mc.criterion)\n LEFT JOIN {user} u ON (mc.marker = u.id)\n WHERE c.definitionid = :definition2\n ORDER BY c.id ASC, u.lastname ASC) T\n GROUP BY id", array("definition" => $definition->id, "definition2" => $definition->id, "emarking" => $emarking->id)); $data = array(); foreach ($markercriteria as $d) { $urldelete = new moodle_url('/mod/emarking/marking/markers.php', array('id' => $cm->id, 'criterion' => $d->id, 'action' => 'deletemarkers'));
die; } $sqloutcomes = "\n SELECT o.*,\n s.name as scalename,\n s.scale as scalelevels,\n s.description as scaledescription\n FROM {grade_outcomes} o\n INNER JOIN {grade_items} gi ON (gi.courseid = :courseid\n AND gi.itemtype = 'mod' AND gi.itemmodule = 'emarking' AND gi.iteminstance = :emarkingid\n AND gi.gradetype = 2 AND gi.outcomeid = o.id)\n INNER JOIN {grade_outcomes_courses} oc ON (oc.courseid = gi.courseid AND o.id = oc.outcomeid)\n INNER JOIN {scale} s ON (o.scaleid = s.id)"; $emarkingoutcomes = $DB->get_records_sql($sqloutcomes, array('courseid' => $course->id, 'emarkingid' => $emarking->id)); if (count($emarkingoutcomes) == 0) { echo $OUTPUT->notification(get_string("emarkinghasnooutcomes", "mod_emarking"), 'notifyproblem'); $outcomesurl = new moodle_url("/course/modedit.php", array("update" => $cm->id, "return" => 1)); echo $OUTPUT->single_button($outcomesurl, get_string("gotoemarkingsettings", "mod_emarking"), 'get'); echo $OUTPUT->footer(); die; } // Get rubric instance. list($gradingmanager, $gradingmethod, $definition) = emarking_validate_rubric($context, true, false); $mformoutcomes = new emarking_outcomes_form(null, array('context' => $context, 'criteria' => $definition->rubric_criteria, 'id' => $cm->id, 'emarking' => $emarking, 'action' => 'addoutcomes', 'outcomes' => $emarkingoutcomes)); if ($mformoutcomes->get_data()) { $newmarkers = process_mform($mformoutcomes, "addoutcomes", $emarking); } if ($action === 'deleteoutcomes') { $DB->delete_records('emarking_outcomes_criteria', array('emarking' => $emarking->id, 'criterion' => $criterion->id)); echo $OUTPUT->notification(get_string("transactionsuccessfull", "mod_emarking"), 'notifysuccess'); } else { if ($action === 'deletesingleoutcome') { $DB->delete_records('emarking_outcomes_criteria', array('emarking' => $emarking->id, 'criterion' => $criterion->id, 'outcome' => $outcome)); echo $OUTPUT->notification(get_string("transactionsuccessfull", "mod_emarking"), 'notifysuccess'); } } $numoutcomescriteria = $DB->count_records("emarking_outcomes_criteria", array("emarking" => $emarking->id)); $outcomescriteria = $DB->get_recordset_sql("\n SELECT\n id,\n description,\n GROUP_CONCAT(oid) AS outcomes,\n sortorder\n FROM (\n SELECT\n c.id,\n c.description,\n c.sortorder,\n o.id as oid\n FROM {gradingform_rubric_criteria} c\n LEFT JOIN {emarking_outcomes_criteria} mc ON (c.definitionid = :definition AND mc.emarking = :emarking AND c.id = mc.criterion)\n LEFT JOIN {grade_outcomes} o ON (mc.outcome = o.id)\n WHERE c.definitionid = :definition2\n ORDER BY c.id ASC, o.fullname ASC) as T\n GROUP BY id", array("definition" => $definition->id, "definition2" => $definition->id, "emarking" => $emarking->id)); $data = array(); foreach ($outcomescriteria as $d) { $urldelete = new moodle_url('/mod/emarking/marking/outcomes.php', array('id' => $cm->id, 'criterion' => $d->id, 'action' => 'deleteoutcomes'));