コード例 #1
0
 public function test_document_services()
 {
     $setask = $this->create_setask_and_submit_pdf();
     $this->setUser($this->teachers[0]);
     $grade = $setask->get_user_grade($this->students[0]->id, true);
     $notempty = page_editor::has_annotations_or_comments($grade->id, false);
     $this->assertFalse($notempty);
     $comment = new comment();
     $comment->rawtext = 'Comment text';
     $comment->width = 100;
     $comment->x = 100;
     $comment->y = 100;
     $comment->colour = 'red';
     page_editor::set_comments($grade->id, 0, array($comment));
     $annotations = array();
     $annotation = new annotation();
     $annotation->path = '';
     $annotation->x = 100;
     $annotation->y = 100;
     $annotation->endx = 200;
     $annotation->endy = 200;
     $annotation->type = 'line';
     $annotation->colour = 'red';
     array_push($annotations, $annotation);
     $annotation = new annotation();
     $annotation->path = '';
     $annotation->x = 100;
     $annotation->y = 100;
     $annotation->endx = 200;
     $annotation->endy = 200;
     $annotation->type = 'rectangle';
     $annotation->colour = 'yellow';
     array_push($annotations, $annotation);
     $annotation = new annotation();
     $annotation->path = '';
     $annotation->x = 100;
     $annotation->y = 100;
     $annotation->endx = 200;
     $annotation->endy = 200;
     $annotation->type = 'oval';
     $annotation->colour = 'green';
     array_push($annotations, $annotation);
     $annotation = new annotation();
     $annotation->path = '';
     $annotation->x = 100;
     $annotation->y = 100;
     $annotation->endx = 200;
     $annotation->endy = 116;
     $annotation->type = 'highlight';
     $annotation->colour = 'blue';
     array_push($annotations, $annotation);
     $annotation = new annotation();
     $annotation->path = '100,100:105,105:110,100';
     $annotation->x = 100;
     $annotation->y = 100;
     $annotation->endx = 110;
     $annotation->endy = 105;
     $annotation->type = 'pen';
     $annotation->colour = 'black';
     array_push($annotations, $annotation);
     page_editor::set_annotations($grade->id, 0, $annotations);
     page_editor::release_drafts($grade->id);
     $notempty = page_editor::has_annotations_or_comments($grade->id, false);
     $this->assertTrue($notempty);
     $file = document_services::generate_feedback_document($setask->get_instance()->id, $grade->userid, $grade->attemptnumber);
     $this->assertNotEmpty($file);
     $file2 = document_services::get_feedback_document($setask->get_instance()->id, $grade->userid, $grade->attemptnumber);
     $this->assertEquals($file, $file2);
     document_services::delete_feedback_document($setask->get_instance()->id, $grade->userid, $grade->attemptnumber);
     $file3 = document_services::get_feedback_document($setask->get_instance()->id, $grade->userid, $grade->attemptnumber);
     $this->assertEmpty($file3);
 }
コード例 #2
0
ファイル: locallib.php プロジェクト: krzpassrl/SRL_Moodle_db
 /**
  * Display the list of files in the feedback status table.
  *
  * @param stdClass $grade
  * @return string
  */
 public function view(stdClass $grade)
 {
     global $PAGE;
     $html = '';
     // Show a link to download the pdf.
     if (page_editor::has_annotations_or_comments($grade->id, false)) {
         $html = $this->setaskment->render_area_files('setaskfeedback_editpdf', document_services::FINAL_PDF_FILEAREA, $grade->id);
         // Also show the link to the read-only interface.
         $renderer = $PAGE->get_renderer('setaskfeedback_editpdf');
         $widget = $this->get_widget($grade->userid, $grade, true);
         $html .= $renderer->render($widget);
     }
     return $html;
 }
コード例 #3
0
ファイル: ajax.php プロジェクト: krzpassrl/SRL_Moodle_db
                    die;
                } else {
                    if ($action == 'revertchanges') {
                        require_capability('mod/setask:grade', $context);
                        $grade = $setaskment->get_user_grade($userid, true);
                        $result = page_editor::revert_drafts($gradeid);
                        echo json_encode($result);
                        die;
                    } else {
                        if ($action == 'removefromquicklist') {
                            require_capability('mod/setask:grade', $context);
                            $commentid = required_param('commentid', PARAM_INT);
                            $result = comments_quick_list::remove_comment($commentid);
                            echo json_encode($result);
                            die;
                        } else {
                            if ($action == 'deletefeedbackdocument') {
                                require_capability('mod/setask:grade', $context);
                                $grade = $setaskment->get_user_grade($userid, true);
                                $result = document_services::delete_feedback_document($setaskment, $userid, $attemptnumber);
                                $result = $result && page_editor::unrelease_drafts($grade->id);
                                echo json_encode($result);
                                die;
                            }
                        }
                    }
                }
            }
        }
    }
}