*/
$commentid = required_param('commentid', PARAM_INT);
$rownum = optional_param('rownum', 1, PARAM_INT);
if ($rownum < 1) {
    $rownum = 1;
}
if (!($comment = $DB->get_record('emarking_comment', array('id' => $commentid)))) {
    emarking_json_error('Invalid comment id for searching.');
}
$params = array($submission->emarkingid, $submission->id, $comment->levelid);
$similaranswers = $DB->get_records_sql("SELECT c.id, c.rawtext as text, c.pageno, c.pagesid\n\t\tFROM {emarking_comment} as c\n\t\tWHERE pagesid in (\n\t\tSELECT id FROM {emarking_page}\n\t\tWHERE assignment in (SELECT emarking FROM {emarking_page} WHERE id = ?))\n\t\tAND pagesid <> ? AND c.levelid = ?\n\t\tORDER BY c.id", $params);
$count = 0;
foreach ($similaranswers as $answer) {
    $count++;
    if ($count == $rownum) {
        if (!($submission = $DB->get_record('emarking_draft', array('id' => $answer->pagesid)))) {
            emarking_json_error('Invalid submission');
        }
        if (!($emarking = $DB->get_record("emarking", array("id" => $submission->emarkingid)))) {
            emarking_json_error('Invalid assignment');
        }
        if (!($course = $DB->get_record("course", array("id" => $emarking->course)))) {
            emarking_json_error('Invalid course');
        }
        if (!($cm = get_coursemodule_from_instance("emarking", $emarking->id, $course->id))) {
            emarking_json_error('Invalid course module');
        }
        list($imageurl, $imgwidth, $imgheight, $numfiles) = emarking_get_page_image($pageno, $submission, $context->id);
        emarking_json_array(array('error' => '', 'url' => $imageurl, 'width' => $imgwidth, 'height' => $imgheight, 'pagecount' => $numfiles));
    }
}
Beispiel #2
0
     break;
 case 'getsubmission':
     include "qry/getSubmissionGrade.php";
     $output = $results;
     emarking_json_array($output);
     break;
 case 'getcomments':
     include "qry/getCommentsSubmission.php";
     emarking_json_resultset($results);
     break;
 case 'getstudents':
     include "qry/getStudentsInMarking.php";
     emarking_json_resultset($results);
     break;
 case 'gettab':
     list($imageurl, $imgwidth, $imgheight, $pagecount) = emarking_get_page_image($pageno, $submission, $anonymous, $context->id);
     if (strlen($imageurl) == 0) {
         emarking_json_error('Image is empty');
     }
     $r = random_string(5);
     $output = array('tabsNumber' => $pagecount, 'imageurl' => $imageurl . '?r=' . $r, 'width' => $imgwidth, 'height' => $imgheight);
     emarking_json_array($output);
     break;
 case 'rotatepage':
     if (!$issupervisor) {
         emarking_json_error('Invalid access');
     }
     // Add to Moodle log so some auditing can be done
     $item = array('context' => context_module::instance($cm->id), 'objectid' => $cm->id);
     \mod_emarking\event\rotatepage_switched::create($item)->trigger();
     list($imageurl, $anonymousurl, $imgwidth, $imgheight) = emarking_rotate_image($pageno, $submission, $context);