diff --git a/mod/README.txt b/mod/README.txt deleted file mode 100644 index c9c4152..0000000 --- a/mod/README.txt +++ /dev/null @@ -1,42 +0,0 @@ -ACTIVITY MODULES ----------------- - -These are main modules in Moodle, allowing various activities. - - -Each of these modules contains a number of expected components: - - mod_form.php: a form to setup/update a module instance - - version.php: defines some meta-info and provides upgrading code - - pix/icon.gif: a 16x16 icon for the module - - db/install.xml: an SQL dump of all the required db tables and data - - index.php: a page to list all instances in a course - - view.php: a page to view a particular instance - - lib.php: any/all functions defined by the module should be in here. - constants should be defined using MODULENAME_xxxxxx - functions should be defined using modulename_xxxxxx - - There are a number of standard functions: - - modulename_add_instance() - modulename_update_instance() - modulename_delete_instance() - - modulename_user_complete() - modulename_user_outline() - - modulename_cron() - - modulename_print_recent_activity() - - -If you are a developer and interested in developing new Modules see: - - Moodle Documentation: http://moodle.org/doc - Moodle Community: http://moodle.org/community diff --git a/mod/assign/feedback/editpdf/ajax.php b/mod/assign/feedback/editpdf/ajax.php deleted file mode 100644 index 8baf3ff..0000000 --- a/mod/assign/feedback/editpdf/ajax.php +++ /dev/null @@ -1,193 +0,0 @@ -. - -/** - * Process ajax requests - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -use \assignfeedback_editpdf\document_services; -use \assignfeedback_editpdf\page_editor; -use \assignfeedback_editpdf\comments_quick_list; - -define('AJAX_SCRIPT', true); - -require('../../../../config.php'); -require_once($CFG->dirroot . '/mod/assign/locallib.php'); - -require_sesskey(); - -$action = optional_param('action', '', PARAM_ALPHANUM); -$assignmentid = required_param('assignmentid', PARAM_INT); -$userid = required_param('userid', PARAM_INT); -$attemptnumber = required_param('attemptnumber', PARAM_INT); -$readonly = optional_param('readonly', false, PARAM_BOOL); - -$cm = \get_coursemodule_from_instance('assign', $assignmentid, 0, false, MUST_EXIST); -$context = \context_module::instance($cm->id); - -$assignment = new \assign($context, null, null); - -require_login($assignment->get_course(), false, $cm); - -if (!$assignment->can_view_submission($userid)) { - print_error('nopermission'); -} - -if ($action == 'loadallpages') { - $draft = true; - if (!has_capability('mod/assign:grade', $context)) { - $draft = false; - $readonly = true; // A student always sees the readonly version. - require_capability('mod/assign:submit', $context); - } - - // Whoever is viewing the readonly version should not use the drafts, but the actual annotations. - if ($readonly) { - $draft = false; - } - - $pages = document_services::get_page_images_for_attempt($assignment, - $userid, - $attemptnumber, - $readonly); - - $response = new stdClass(); - $response->pagecount = count($pages); - $response->pages = array(); - - $grade = $assignment->get_user_grade($userid, true); - - // The readonly files are stored in a different file area. - $filearea = document_services::PAGE_IMAGE_FILEAREA; - if ($readonly) { - $filearea = document_services::PAGE_IMAGE_READONLY_FILEAREA; - } - - foreach ($pages as $id => $pagefile) { - $index = count($response->pages); - $page = new stdClass(); - $comments = page_editor::get_comments($grade->id, $index, $draft); - $page->url = moodle_url::make_pluginfile_url($context->id, - 'assignfeedback_editpdf', - $filearea, - $grade->id, - '/', - $pagefile->get_filename())->out(); - $page->comments = $comments; - $annotations = page_editor::get_annotations($grade->id, $index, $draft); - $page->annotations = $annotations; - array_push($response->pages, $page); - } - - echo json_encode($response); - die(); -} else if ($action == 'savepage') { - require_capability('mod/assign:grade', $context); - - $response = new stdClass(); - $response->errors = array(); - - $grade = $assignment->get_user_grade($userid, true); - - $pagejson = required_param('page', PARAM_RAW); - $page = json_decode($pagejson); - $index = required_param('index', PARAM_INT); - - $added = page_editor::set_comments($grade->id, $index, $page->comments); - if ($added != count($page->comments)) { - array_push($response->errors, get_string('couldnotsavepage', 'assignfeedback_editpdf', $index+1)); - } - $added = page_editor::set_annotations($grade->id, $index, $page->annotations); - if ($added != count($page->annotations)) { - array_push($response->errors, get_string('couldnotsavepage', 'assignfeedback_editpdf', $index+1)); - } - echo json_encode($response); - die(); - -} else if ($action == 'generatepdf') { - - require_capability('mod/assign:grade', $context); - $response = new stdClass(); - $grade = $assignment->get_user_grade($userid, true); - $file = document_services::generate_feedback_document($assignment, $userid, $attemptnumber); - - $response->url = ''; - if ($file) { - $url = moodle_url::make_pluginfile_url($assignment->get_context()->id, - 'assignfeedback_editpdf', - document_services::FINAL_PDF_FILEAREA, - $grade->id, - '/', - $file->get_filename(), - false); - $response->url = $url->out(true); - $response->filename = $file->get_filename(); - } - - echo json_encode($response); - die(); -} else if ($action == 'loadquicklist') { - require_capability('mod/assign:grade', $context); - - $result = comments_quick_list::get_comments(); - - echo json_encode($result); - die(); - -} else if ($action == 'addtoquicklist') { - require_capability('mod/assign:grade', $context); - - $comment = required_param('commenttext', PARAM_RAW); - $width = required_param('width', PARAM_INT); - $colour = required_param('colour', PARAM_ALPHA); - - $result = comments_quick_list::add_comment($comment, $width, $colour); - - echo json_encode($result); - die(); -} else if ($action == 'revertchanges') { - require_capability('mod/assign:grade', $context); - - $grade = $assignment->get_user_grade($userid, true); - - $result = page_editor::revert_drafts($gradeid); - - echo json_encode($result); - die(); -} else if ($action == 'removefromquicklist') { - require_capability('mod/assign: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/assign:grade', $context); - - $grade = $assignment->get_user_grade($userid, true); - $result = document_services::delete_feedback_document($assignment, $userid, $attemptnumber); - - $result = $result && page_editor::unrelease_drafts($grade->id); - echo json_encode($result); - die(); -} - diff --git a/mod/assign/feedback/editpdf/ajax_progress.php b/mod/assign/feedback/editpdf/ajax_progress.php deleted file mode 100644 index 8154848..0000000 --- a/mod/assign/feedback/editpdf/ajax_progress.php +++ /dev/null @@ -1,73 +0,0 @@ -. - -/** - * Process concurrent ajax request. - * ALL RETURNED INFO IS PUBLIC. - * - * @package assignfeedback_editpdf - * @copyright 2013 Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -define('AJAX_SCRIPT', true); -// To be able to process concurrent ajax request with the generate pdf ajax request we can not use cookie. -define('NO_MOODLE_COOKIES', true); - -use \assignfeedback_editpdf\document_services; -require_once('../../../../config.php'); - -try { - $assignmentid = required_param('assignmentid', PARAM_INT); - $userid = required_param('userid', PARAM_INT); - $attemptnumber = required_param('attemptnumber', PARAM_INT); - - // Retrieve the assignments. - require_once($CFG->dirroot . '/mod/assign/locallib.php'); - $cm = get_coursemodule_from_instance('assign', $assignmentid, 0, false, MUST_EXIST); - $context = context_module::instance($cm->id); - $assignment = new assign($context, null, null); - - // Get the generated images from file API call. - $grade = $assignment->get_user_grade($userid, false, $attemptnumber); - - // Check we found a grade. - if (empty($grade)) { - throw new coding_exception('grade not found'); - } - - // No need to handle the readonly files here, the should be already generated. - $component = 'assignfeedback_editpdf'; - $filearea = document_services::PAGE_IMAGE_FILEAREA; - $filepath = '/'; - $fs = get_file_storage(); - $files = $fs->get_directory_files($context->id, $component, $filearea, $grade->id, $filepath); - - // The important security part: we ONLY RETURN the total NUMBER of generated images. - echo $OUTPUT->header(); - echo json_encode(count($files)); - echo $OUTPUT->footer(); -} catch (Exception $e) { - // This should never happened! - // Return a 500 HTTP header so Y.io gets it as a failure. - if (substr(php_sapi_name(), 0, 3) == 'cgi') { - header("Status: 500 Internal Server Error"); - } else { - header('HTTP/1.0 500 Internal Server Error'); - } - throw new moodle_exception('An exception was caught but can not be returned for security purpose. - To easily debug, comment the try catch.'); -} diff --git a/mod/assign/feedback/editpdf/backup/moodle2/backup_assignfeedback_editpdf_subplugin.class.php b/mod/assign/feedback/editpdf/backup/moodle2/backup_assignfeedback_editpdf_subplugin.class.php deleted file mode 100644 index 4fe8cc6..0000000 --- a/mod/assign/feedback/editpdf/backup/moodle2/backup_assignfeedback_editpdf_subplugin.class.php +++ /dev/null @@ -1,73 +0,0 @@ -. - -/** - * This file contains the backup code for the feedback_editpdf plugin. - * - * @package assignfeedback_editpdf - * @copyright 2013 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -defined('MOODLE_INTERNAL') || die(); - -/** - * Provides the information to backup feedback pdf annotations. - * - * This just adds its fileareas to the annotations and the comments and annotation data. - * - * @package assignfeedback_editpdf - * @copyright 2013 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class backup_assignfeedback_editpdf_subplugin extends backup_subplugin { - - /** - * Returns the subplugin information to attach to feedback element - * @return backup_subplugin_element - */ - protected function define_grade_subplugin_structure() { - - // Create XML elements. - $subplugin = $this->get_subplugin_element(); - $subpluginwrapper = new backup_nested_element($this->get_recommended_name()); - $subpluginelementfiles = new backup_nested_element('feedback_editpdf_files', null, array('gradeid')); - $subpluginelementannotations = new backup_nested_element('feedback_editpdf_annotations'); - $subpluginelementannotation = new backup_nested_element('annotation', null, array('gradeid', 'pageno', 'type', 'x', 'y', 'endx', 'endy', 'colour', 'path', 'draft')); - $subpluginelementcomments = new backup_nested_element('feedback_editpdf_comments'); - $subpluginelementcomment = new backup_nested_element('comment', null, array('gradeid', 'pageno', 'x', 'y', 'width', 'rawtext', 'colour', 'draft')); - - // Connect XML elements into the tree. - $subplugin->add_child($subpluginwrapper); - $subpluginelementannotations->add_child($subpluginelementannotation); - $subpluginelementcomments->add_child($subpluginelementcomment); - $subpluginwrapper->add_child($subpluginelementfiles); - $subpluginwrapper->add_child($subpluginelementannotations); - $subpluginwrapper->add_child($subpluginelementcomments); - - // Set source to populate the data. - $subpluginelementfiles->set_source_sql('SELECT id AS gradeid from {assign_grades} where id = :gradeid', array('gradeid' => backup::VAR_PARENTID)); - $subpluginelementannotation->set_source_table('assignfeedback_editpdf_annot', array('gradeid' => backup::VAR_PARENTID)); - $subpluginelementcomment->set_source_table('assignfeedback_editpdf_cmnt', array('gradeid' => backup::VAR_PARENTID)); - // We only need to backup the files in the final pdf area, and the readonly page images - the others can be regenerated. - $subpluginelementfiles->annotate_files('assignfeedback_editpdf', - \assignfeedback_editpdf\document_services::FINAL_PDF_FILEAREA, 'gradeid'); - $subpluginelementfiles->annotate_files('assignfeedback_editpdf', - \assignfeedback_editpdf\document_services::PAGE_IMAGE_READONLY_FILEAREA, 'gradeid'); - $subpluginelementfiles->annotate_files('assignfeedback_editpdf', 'stamps', 'gradeid'); - return $subplugin; - } - -} diff --git a/mod/assign/feedback/editpdf/backup/moodle2/restore_assignfeedback_editpdf_subplugin.class.php b/mod/assign/feedback/editpdf/backup/moodle2/restore_assignfeedback_editpdf_subplugin.class.php deleted file mode 100644 index c520e2b..0000000 --- a/mod/assign/feedback/editpdf/backup/moodle2/restore_assignfeedback_editpdf_subplugin.class.php +++ /dev/null @@ -1,112 +0,0 @@ -. - -/** - * This file contains the restore code for the feedback_editpdf plugin. - * - * @package assignfeedback_editpdf - * @copyright 2013 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -defined('MOODLE_INTERNAL') || die(); - -/** - * Restore subplugin class. - * - * Provides the necessary information needed - * to restore one assign_feedback subplugin. - * - * @package assignfeedback_editpdf - * @copyright 2013 Damyon Wiese - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class restore_assignfeedback_editpdf_subplugin extends restore_subplugin { - - /** - * Returns the paths to be handled by the subplugin at assignment level - * @return array - */ - protected function define_grade_subplugin_structure() { - - $paths = array(); - - // We used get_recommended_name() so this works. - // The files node is a placeholder just containing gradeid so we can restore files once per grade. - $elename = $this->get_namefor('files'); - $elepath = $this->get_pathfor('/feedback_editpdf_files'); - $paths[] = new restore_path_element($elename, $elepath); - - // Now we have the list of comments and annotations per grade. - $elename = $this->get_namefor('comment'); - $elepath = $this->get_pathfor('/feedback_editpdf_comments/comment'); - $paths[] = new restore_path_element($elename, $elepath); - $elename = $this->get_namefor('annotation'); - $elepath = $this->get_pathfor('/feedback_editpdf_annotations/annotation'); - $paths[] = new restore_path_element($elename, $elepath); - - return $paths; - } - - /** - * Processes one feedback_editpdf_files element - * @param mixed $data - */ - public function process_assignfeedback_editpdf_files($data) { - $data = (object)$data; - - // In this case the id is the old gradeid which will be mapped. - $this->add_related_files('assignfeedback_editpdf', - \assignfeedback_editpdf\document_services::FINAL_PDF_FILEAREA, 'grade', null, $data->gradeid); - $this->add_related_files('assignfeedback_editpdf', - \assignfeedback_editpdf\document_services::PAGE_IMAGE_READONLY_FILEAREA, 'grade', null, $data->gradeid); - $this->add_related_files('assignfeedback_editpdf', 'stamps', 'grade', null, $data->gradeid); - } - - /** - * Processes one feedback_editpdf_annotations/annotation element - * @param mixed $data - */ - public function process_assignfeedback_editpdf_annotation($data) { - global $DB; - - $data = (object)$data; - $oldgradeid = $data->gradeid; - // The mapping is set in the restore for the core assign activity - // when a grade node is processed. - $data->gradeid = $this->get_mappingid('grade', $data->gradeid); - - $DB->insert_record('assignfeedback_editpdf_annot', $data); - - } - - /** - * Processes one feedback_editpdf_comments/comment element - * @param mixed $data - */ - public function process_assignfeedback_editpdf_comment($data) { - global $DB; - - $data = (object)$data; - $oldgradeid = $data->gradeid; - // The mapping is set in the restore for the core assign activity - // when a grade node is processed. - $data->gradeid = $this->get_mappingid('grade', $data->gradeid); - - $DB->insert_record('assignfeedback_editpdf_cmnt', $data); - - } - -} diff --git a/mod/assign/feedback/editpdf/classes/annotation.php b/mod/assign/feedback/editpdf/classes/annotation.php deleted file mode 100644 index f6bd313..0000000 --- a/mod/assign/feedback/editpdf/classes/annotation.php +++ /dev/null @@ -1,84 +0,0 @@ -. - -/** - * This file contains the annotation class for the assignfeedback_editpdf plugin - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace assignfeedback_editpdf; - -/** - * This class adds and removes annotations from a page of a response. - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class annotation { - - /** @var int unique id for this annotation */ - public $id = 0; - - /** @var int gradeid for this annotation */ - public $gradeid = 0; - - /** @var int page number for this annotation */ - public $pageno = 0; - - /** @var int starting location in pixels. Image resolution is 100 pixels per inch */ - public $x = 0; - - /** @var int ending location in pixels. Image resolution is 100 pixels per inch */ - public $endx = 0; - - /** @var int starting location in pixels. Image resolution is 100 pixels per inch */ - public $y = 0; - - /** @var int ending location in pixels. Image resolution is 100 pixels per inch */ - public $endy = 0; - - /** @var string path information for drawing the annotation. */ - public $path = ''; - - /** @var string colour - One of red, yellow, green, blue, white */ - public $colour = 'yellow'; - - /** @var string type - One of line, oval, rect, etc */ - public $type = 'line'; - - /** - * Convert a compatible stdClass into an instance of this class. - * @param stdClass $record - */ - public function __construct(\stdClass $record = null) { - if ($record) { - $intcols = array('endx', 'endy', 'x', 'y'); - foreach ($this as $key => $value) { - if (isset($record->$key)) { - if (in_array($key, $intcols)) { - $this->$key = intval($record->$key); - } else { - $this->$key = $record->$key; - } - } - } - } - } -} diff --git a/mod/assign/feedback/editpdf/classes/comment.php b/mod/assign/feedback/editpdf/classes/comment.php deleted file mode 100644 index d0cfded..0000000 --- a/mod/assign/feedback/editpdf/classes/comment.php +++ /dev/null @@ -1,76 +0,0 @@ -. - -/** - * This file contains the comment class for the assignfeedback_editpdf plugin - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace assignfeedback_editpdf; - -/** - * This class represents a comment box on a page of feedback. - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class comment { - - /** @var int unique id for this annotation */ - public $id = 0; - - /** @var int gradeid for this annotation */ - public $gradeid = 0; - - /** @var int page number for this annotation */ - public $pageno = 0; - - /** @var int starting location in pixels. Image resolution is 100 pixels per inch */ - public $x = 0; - - /** @var int starting location in pixels. Image resolution is 100 pixels per inch */ - public $y = 0; - - /** @var int width of the comment box */ - public $width = 120; - - /** @var string The comment text. */ - public $rawtext = ''; - - /** @var string colour - One of red, yellow, green, blue, white */ - public $colour = 'yellow'; - - /** - * Convert a compatible stdClass into an instance of a comment. - * @param \stdClass $record - */ - public function __construct(\stdClass $record = null) { - if ($record) { - $intcols = array('width', 'x', 'y'); - foreach ($this as $key => $value) { - if (isset($record->$key)) { - if (in_array($key, $intcols)) { - $this->$key = intval($record->$key); - } else { - $this->$key = $record->$key; - } - } - } - } - } -} diff --git a/mod/assign/feedback/editpdf/classes/comments_quick_list.php b/mod/assign/feedback/editpdf/classes/comments_quick_list.php deleted file mode 100644 index deb8be2..0000000 --- a/mod/assign/feedback/editpdf/classes/comments_quick_list.php +++ /dev/null @@ -1,94 +0,0 @@ -. - -/** - * This file contains the functions for managing a users comments quicklist. - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace assignfeedback_editpdf; - -/** - * This class performs crud operations on a users quicklist comments. - * - * No capability checks are done - they should be done by the calling class. - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class comments_quick_list { - - /** - * Get all comments for the current user. - * @return array(comment) - */ - public static function get_comments() { - global $DB, $USER; - - $comments = array(); - $records = $DB->get_records('assignfeedback_editpdf_quick', array('userid'=>$USER->id)); - - return $records; - } - - /** - * Add a comment to the quick list. - * @param string $commenttext - * @param int $width - * @param string $colour - * @return stdClass - the comment record (with new id set) - */ - public static function add_comment($commenttext, $width, $colour) { - global $DB, $USER; - - $comment = new \stdClass(); - $comment->userid = $USER->id; - $comment->rawtext = $commenttext; - $comment->width = $width; - $comment->colour = $colour; - - $comment->id = $DB->insert_record('assignfeedback_editpdf_quick', $comment); - return $comment; - } - - /** - * Get a single comment by id. - * @param int $commentid - * @return comment or false - */ - public static function get_comment($commentid) { - global $DB; - - $record = $DB->get_record('assignfeedback_editpdf_quick', array('id'=>$commentid), '*', IGNORE_MISSING); - if ($record) { - return $record; - } - return false; - } - - /** - * Remove a comment from the quick list. - * @param int $commentid - * @return bool - */ - public static function remove_comment($commentid) { - global $DB, $USER; - return $DB->delete_records('assignfeedback_editpdf_quick', array('id'=>$commentid, 'userid'=>$USER->id)); - } -} diff --git a/mod/assign/feedback/editpdf/classes/document_services.php b/mod/assign/feedback/editpdf/classes/document_services.php deleted file mode 100644 index 912bd8a..0000000 --- a/mod/assign/feedback/editpdf/classes/document_services.php +++ /dev/null @@ -1,729 +0,0 @@ -. - -/** - * This file contains the ingest manager for the assignfeedback_editpdf plugin - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace assignfeedback_editpdf; - -/** - * Functions for generating the annotated pdf. - * - * This class controls the ingest of student submission files to a normalised - * PDF 1.4 document with all submission files concatinated together. It also - * provides the functions to generate a downloadable pdf with all comments and - * annotations embedded. - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class document_services { - - /** File area for generated pdf */ - const FINAL_PDF_FILEAREA = 'download'; - /** File area for combined pdf */ - const COMBINED_PDF_FILEAREA = 'combined'; - /** File area for page images */ - const PAGE_IMAGE_FILEAREA = 'pages'; - /** File area for readonly page images */ - const PAGE_IMAGE_READONLY_FILEAREA = 'readonlypages'; - /** Filename for combined pdf */ - const COMBINED_PDF_FILENAME = 'combined.pdf'; - - /** - * This function will take an int or an assignment instance and - * return an assignment instance. It is just for convenience. - * @param int|\assign $assignment - * @return assign - */ - private static function get_assignment_from_param($assignment) { - global $CFG; - - require_once($CFG->dirroot . '/mod/assign/locallib.php'); - - if (!is_object($assignment)) { - $cm = \get_coursemodule_from_instance('assign', $assignment, 0, false, MUST_EXIST); - $context = \context_module::instance($cm->id); - - $assignment = new \assign($context, null, null); - } - return $assignment; - } - - /** - * Get a hash that will be unique and can be used in a path name. - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - */ - private static function hash($assignment, $userid, $attemptnumber) { - if (is_object($assignment)) { - $assignmentid = $assignment->get_instance()->id; - } else { - $assignmentid = $assignment; - } - return sha1($assignmentid . '_' . $userid . '_' . $attemptnumber); - } - - /** - * This function will search for all files that can be converted - * and concatinated into a PDF (1.4) - for any submission plugin - * for this students attempt. - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @return array(stored_file) - */ - public static function list_compatible_submission_files_for_attempt($assignment, $userid, $attemptnumber) { - global $USER, $DB; - - $assignment = self::get_assignment_from_param($assignment); - - // Capability checks. - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - - $files = array(); - - if ($assignment->get_instance()->teamsubmission) { - $submission = $assignment->get_group_submission($userid, 0, false); - } else { - $submission = $assignment->get_user_submission($userid, false); - } - $user = $DB->get_record('user', array('id' => $userid)); - - // User has not submitted anything yet. - if (!$submission) { - return $files; - } - // Ask each plugin for it's list of files. - foreach ($assignment->get_submission_plugins() as $plugin) { - if ($plugin->is_enabled() && $plugin->is_visible()) { - $pluginfiles = $plugin->get_files($submission, $user); - foreach ($pluginfiles as $filename => $file) { - if (($file instanceof \stored_file) && ($file->get_mimetype() === 'application/pdf')) { - $files[$filename] = $file; - } - } - } - } - return $files; - } - - /** - * This function return the combined pdf for all valid submission files. - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @return stored_file - */ - public static function get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber) { - - global $USER, $DB; - - $assignment = self::get_assignment_from_param($assignment); - - // Capability checks. - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - if ($assignment->get_instance()->teamsubmission) { - $submission = $assignment->get_group_submission($userid, 0, false); - } else { - $submission = $assignment->get_user_submission($userid, false); - } - - $contextid = $assignment->get_context()->id; - $component = 'assignfeedback_editpdf'; - $filearea = self::COMBINED_PDF_FILEAREA; - $itemid = $grade->id; - $filepath = '/'; - $filename = self::COMBINED_PDF_FILENAME; - $fs = \get_file_storage(); - - $combinedpdf = $fs->get_file($contextid, $component, $filearea, $itemid, $filepath, $filename); - if (!$combinedpdf || - ($submission && ($combinedpdf->get_timemodified() < $submission->timemodified))) { - return self::generate_combined_pdf_for_attempt($assignment, $userid, $attemptnumber); - } - return $combinedpdf; - } - - /** - * This function will take all of the compatible files for a submission - * and combine them into one PDF. - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @return stored_file - */ - public static function generate_combined_pdf_for_attempt($assignment, $userid, $attemptnumber) { - global $CFG; - - require_once($CFG->libdir . '/pdflib.php'); - - $assignment = self::get_assignment_from_param($assignment); - - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - - $files = self::list_compatible_submission_files_for_attempt($assignment, $userid, $attemptnumber); - - $pdf = new pdf(); - if (!$files) { - // No valid submission files - create an empty pdf. - $pdf->AddPage(); - } else { - - // Create a mega joined PDF. - $compatiblepdfs = array(); - foreach ($files as $file) { - $compatiblepdf = pdf::ensure_pdf_compatible($file); - if ($compatiblepdf) { - array_push($compatiblepdfs, $compatiblepdf); - } - } - - $tmpdir = \make_temp_directory('assignfeedback_editpdf/combined/' . self::hash($assignment, $userid, $attemptnumber)); - $tmpfile = $tmpdir . '/' . self::COMBINED_PDF_FILENAME; - - @unlink($tmpfile); - try { - $pagecount = $pdf->combine_pdfs($compatiblepdfs, $tmpfile); - } catch (\Exception $e) { - debugging('TCPDF could not process the pdf files:' . $e->getMessage(), DEBUG_DEVELOPER); - // TCPDF does not recover from errors so we need to re-initialise the class. - $pagecount = 0; - } - if ($pagecount == 0) { - // We at least want a single blank page. - debugging('TCPDF did not produce a valid pdf:' . $tmpfile . '. Replacing with a blank pdf.', DEBUG_DEVELOPER); - $pdf = new pdf(); - $pdf->AddPage(); - @unlink($tmpfile); - $files = false; - } - } - - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - $record = new \stdClass(); - - $record->contextid = $assignment->get_context()->id; - $record->component = 'assignfeedback_editpdf'; - $record->filearea = self::COMBINED_PDF_FILEAREA; - $record->itemid = $grade->id; - $record->filepath = '/'; - $record->filename = self::COMBINED_PDF_FILENAME; - $fs = \get_file_storage(); - - $fs->delete_area_files($record->contextid, $record->component, $record->filearea, $record->itemid); - - // Detect corrupt generated pdfs and replace with a blank one. - if ($files) { - $pagecount = $pdf->load_pdf($tmpfile); - if ($pagecount <= 0) { - $files = false; - } - } - - if (!$files) { - // This was a blank pdf. - unset($pdf); - $pdf = new pdf(); - $content = $pdf->Output(self::COMBINED_PDF_FILENAME, 'S'); - $file = $fs->create_file_from_string($record, $content); - } else { - // This was a combined pdf. - $file = $fs->create_file_from_pathname($record, $tmpfile); - @unlink($tmpfile); - - // Test the generated file for correctness. - $compatiblepdf = pdf::ensure_pdf_compatible($file); - } - - return $file; - } - - /** - * This function will return the number of pages of a pdf. - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @param bool $readonly When true we get the number of pages for the readonly version. - * @return int number of pages - */ - public static function page_number_for_attempt($assignment, $userid, $attemptnumber, $readonly = false) { - global $CFG; - - require_once($CFG->libdir . '/pdflib.php'); - - $assignment = self::get_assignment_from_param($assignment); - - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - - // When in readonly we can return the number of images in the DB because they should already exist, - // if for some reason they do not, then we proceed as for the normal version. - if ($readonly) { - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - $fs = get_file_storage(); - $files = $fs->get_directory_files($assignment->get_context()->id, 'assignfeedback_editpdf', - self::PAGE_IMAGE_READONLY_FILEAREA, $grade->id, '/'); - $pagecount = count($files); - if ($pagecount > 0) { - return $pagecount; - } - } - - // Get a combined pdf file from all submitted pdf files. - $file = self::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber); - if (!$file) { - \print_error('Could not generate combined pdf.'); - } - - // Store the combined pdf file somewhere to be opened by tcpdf. - $tmpdir = \make_temp_directory('assignfeedback_editpdf/pagetotal/' - . self::hash($assignment, $userid, $attemptnumber)); - $combined = $tmpdir . '/' . self::COMBINED_PDF_FILENAME; - $file->copy_content_to($combined); // Copy the file. - - // Get the total number of pages. - $pdf = new pdf(); - $pagecount = $pdf->set_pdf($combined); - - // Delete temporary folders and files. - @unlink($combined); - @rmdir($tmpdir); - - return $pagecount; - } - - /** - * This function will generate and return a list of the page images from a pdf. - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @return array(stored_file) - */ - public static function generate_page_images_for_attempt($assignment, $userid, $attemptnumber) { - global $CFG; - - require_once($CFG->libdir . '/pdflib.php'); - - $assignment = self::get_assignment_from_param($assignment); - - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - - // Need to generate the page images - first get a combined pdf. - $file = self::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber); - if (!$file) { - throw new \moodle_exception('Could not generate combined pdf.'); - } - - $tmpdir = \make_temp_directory('assignfeedback_editpdf/pageimages/' . self::hash($assignment, $userid, $attemptnumber)); - $combined = $tmpdir . '/' . self::COMBINED_PDF_FILENAME; - $file->copy_content_to($combined); // Copy the file. - - $pdf = new pdf(); - - $pdf->set_image_folder($tmpdir); - $pagecount = $pdf->set_pdf($combined); - - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - - $record = new \stdClass(); - $record->contextid = $assignment->get_context()->id; - $record->component = 'assignfeedback_editpdf'; - $record->filearea = self::PAGE_IMAGE_FILEAREA; - $record->itemid = $grade->id; - $record->filepath = '/'; - $fs = \get_file_storage(); - - $files = array(); - for ($i = 0; $i < $pagecount; $i++) { - $image = $pdf->get_image($i); - $record->filename = basename($image); - $files[$i] = $fs->create_file_from_pathname($record, $tmpdir . '/' . $image); - @unlink($tmpdir . '/' . $image); - } - - @unlink($combined); - @rmdir($tmpdir); - - return $files; - } - - /** - * This function returns a list of the page images from a pdf. - * - * The readonly version is different than the normal one. The readonly version contains a copy - * of the pages in the state they were when the PDF was annotated, by doing so we prevent the - * the pages that are displayed to change as soon as the submission changes. - * - * Though there is an edge case, if the PDF was annotated before MDL-45580, then it is possible - * that we do not find any readonly version of the pages. In that case, we will get the normal - * pages and copy them to the readonly area. This ensures that the pages will remain in that - * state until the submission is updated. When the normal files do not exist, we throw an exception - * because the readonly pages should only ever be displayed after a teacher has annotated the PDF, - * they would not exist until they do. - * - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @param bool $readonly If true, then we are requesting the readonly version. - * @return array(stored_file) - */ - public static function get_page_images_for_attempt($assignment, $userid, $attemptnumber, $readonly = false) { - - $assignment = self::get_assignment_from_param($assignment); - - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - - if ($assignment->get_instance()->teamsubmission) { - $submission = $assignment->get_group_submission($userid, 0, false); - } else { - $submission = $assignment->get_user_submission($userid, false); - } - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - - $contextid = $assignment->get_context()->id; - $component = 'assignfeedback_editpdf'; - $itemid = $grade->id; - $filepath = '/'; - $filearea = self::PAGE_IMAGE_FILEAREA; - - $fs = \get_file_storage(); - - // If we are after the readonly pages... - $copytoreadonly = false; - if ($readonly) { - $filearea = self::PAGE_IMAGE_READONLY_FILEAREA; - if ($fs->is_area_empty($contextid, $component, $filearea, $itemid)) { - // We have a problem here, we were supposed to find the files... - // let's fallback on the other area, and copy the files to the readonly area. - $copytoreadonly = true; - $filearea = self::PAGE_IMAGE_FILEAREA; - } - } - - $files = $fs->get_directory_files($contextid, $component, $filearea, $itemid, $filepath); - - $pages = array(); - if (!empty($files)) { - $first = reset($files); - if (!$readonly && $first->get_timemodified() < $submission->timemodified) { - // Image files are stale, we need to regenerate them, except in readonly mode. - // We also need to remove the draft annotations and comments associated with this attempt. - $fs->delete_area_files($contextid, $component, $filearea, $itemid); - page_editor::delete_draft_content($itemid); - $files = array(); - } else { - - // Need to reorder the files following their name. - // because get_directory_files() return a different order than generate_page_images_for_attempt(). - foreach($files as $file) { - // Extract the page number from the file name image_pageXXXX.png. - preg_match('/page([\d]+)\./', $file->get_filename(), $matches); - if (empty($matches) or !is_numeric($matches[1])) { - throw new \coding_exception("'" . $file->get_filename() - . "' file hasn't the expected format filename: image_pageXXXX.png."); - } - $pagenumber = (int)$matches[1]; - - // Save the page in the ordered array. - $pages[$pagenumber] = $file; - } - ksort($pages); - - if ($copytoreadonly) { - self::copy_pages_to_readonly_area($assignment, $grade); - } - } - } - - if (empty($pages)) { - if ($readonly) { - // This should never happen, there should be a version of the pages available - // whenever we are requesting the readonly version. - throw new \moodle_exception('Could not find readonly pages for grade ' . $grade->id); - } - $pages = self::generate_page_images_for_attempt($assignment, $userid, $attemptnumber); - } - - return $pages; - } - - /** - * This function returns sensible filename for a feedback file. - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @return string - */ - protected static function get_downloadable_feedback_filename($assignment, $userid, $attemptnumber) { - global $DB; - - $assignment = self::get_assignment_from_param($assignment); - - $groupmode = groups_get_activity_groupmode($assignment->get_course_module()); - $groupname = ''; - if ($groupmode) { - $groupid = groups_get_activity_group($assignment->get_course_module(), true); - $groupname = groups_get_group_name($groupid).'-'; - } - if ($groupname == '-') { - $groupname = ''; - } - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); - - if ($assignment->is_blind_marking()) { - $prefix = $groupname . get_string('participant', 'assign'); - $prefix = str_replace('_', ' ', $prefix); - $prefix = clean_filename($prefix . '_' . $assignment->get_uniqueid_for_user($userid) . '_'); - } else { - $prefix = $groupname . fullname($user); - $prefix = str_replace('_', ' ', $prefix); - $prefix = clean_filename($prefix . '_' . $assignment->get_uniqueid_for_user($userid) . '_'); - } - $prefix .= $grade->attemptnumber; - - return $prefix . '.pdf'; - } - - /** - * This function takes the combined pdf and embeds all the comments and annotations. - * - * This also moves the annotations and comments from drafts to not drafts. And it will - * copy all the images stored to the readonly area, so that they can be viewed online, and - * not be overwritten when a new submission is sent. - * - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @return stored_file - */ - public static function generate_feedback_document($assignment, $userid, $attemptnumber) { - - $assignment = self::get_assignment_from_param($assignment); - - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - if (!$assignment->can_grade()) { - \print_error('nopermission'); - } - - // Need to generate the page images - first get a combined pdf. - $file = self::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber); - if (!$file) { - throw new \moodle_exception('Could not generate combined pdf.'); - } - - $tmpdir = \make_temp_directory('assignfeedback_editpdf/final/' . self::hash($assignment, $userid, $attemptnumber)); - $combined = $tmpdir . '/' . self::COMBINED_PDF_FILENAME; - $file->copy_content_to($combined); // Copy the file. - - $pdf = new pdf(); - - $fs = \get_file_storage(); - $stamptmpdir = \make_temp_directory('assignfeedback_editpdf/stamps/' . self::hash($assignment, $userid, $attemptnumber)); - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - // Copy any new stamps to this instance. - if ($files = $fs->get_area_files($assignment->get_context()->id, - 'assignfeedback_editpdf', - 'stamps', - $grade->id, - "filename", - false)) { - foreach ($files as $file) { - $filename = $stamptmpdir . '/' . $file->get_filename(); - $file->copy_content_to($filename); // Copy the file. - } - } - - $pagecount = $pdf->set_pdf($combined); - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - page_editor::release_drafts($grade->id); - - for ($i = 0; $i < $pagecount; $i++) { - $pdf->copy_page(); - $comments = page_editor::get_comments($grade->id, $i, false); - $annotations = page_editor::get_annotations($grade->id, $i, false); - - foreach ($comments as $comment) { - $pdf->add_comment($comment->rawtext, - $comment->x, - $comment->y, - $comment->width, - $comment->colour); - } - - foreach ($annotations as $annotation) { - $pdf->add_annotation($annotation->x, - $annotation->y, - $annotation->endx, - $annotation->endy, - $annotation->colour, - $annotation->type, - $annotation->path, - $stamptmpdir); - } - } - - fulldelete($stamptmpdir); - - $filename = self::get_downloadable_feedback_filename($assignment, $userid, $attemptnumber); - $filename = clean_param($filename, PARAM_FILE); - - $generatedpdf = $tmpdir . '/' . $filename; - $pdf->save_pdf($generatedpdf); - - - $record = new \stdClass(); - - $record->contextid = $assignment->get_context()->id; - $record->component = 'assignfeedback_editpdf'; - $record->filearea = self::FINAL_PDF_FILEAREA; - $record->itemid = $grade->id; - $record->filepath = '/'; - $record->filename = $filename; - - - // Only keep one current version of the generated pdf. - $fs->delete_area_files($record->contextid, $record->component, $record->filearea, $record->itemid); - - $file = $fs->create_file_from_pathname($record, $generatedpdf); - - // Cleanup. - @unlink($generatedpdf); - @unlink($combined); - @rmdir($tmpdir); - - self::copy_pages_to_readonly_area($assignment, $grade); - - return $file; - } - - /** - * Copy the pages image to the readonly area. - * - * @param int|\assign $assignment The assignment. - * @param \stdClass $grade The grade record. - * @return void - */ - public static function copy_pages_to_readonly_area($assignment, $grade) { - $fs = get_file_storage(); - $assignment = self::get_assignment_from_param($assignment); - $contextid = $assignment->get_context()->id; - $component = 'assignfeedback_editpdf'; - $itemid = $grade->id; - - // Get all the pages. - $originalfiles = $fs->get_area_files($contextid, $component, self::PAGE_IMAGE_FILEAREA, $itemid); - if (empty($originalfiles)) { - // Nothing to do here... - return; - } - - // Delete the old readonly files. - $fs->delete_area_files($contextid, $component, self::PAGE_IMAGE_READONLY_FILEAREA, $itemid); - - // Do the copying. - foreach ($originalfiles as $originalfile) { - $fs->create_file_from_storedfile(array('filearea' => self::PAGE_IMAGE_READONLY_FILEAREA), $originalfile); - } - } - - /** - * This function returns the generated pdf (if it exists). - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @return stored_file - */ - public static function get_feedback_document($assignment, $userid, $attemptnumber) { - - $assignment = self::get_assignment_from_param($assignment); - - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - - $contextid = $assignment->get_context()->id; - $component = 'assignfeedback_editpdf'; - $filearea = self::FINAL_PDF_FILEAREA; - $itemid = $grade->id; - $filepath = '/'; - - $fs = \get_file_storage(); - $files = $fs->get_area_files($contextid, - $component, - $filearea, - $itemid, - "itemid, filepath, filename", - false); - if ($files) { - return reset($files); - } - return false; - } - - /** - * This function deletes the generated pdf for a student. - * @param int|\assign $assignment - * @param int $userid - * @param int $attemptnumber (-1 means latest attempt) - * @return bool - */ - public static function delete_feedback_document($assignment, $userid, $attemptnumber) { - - $assignment = self::get_assignment_from_param($assignment); - - if (!$assignment->can_view_submission($userid)) { - \print_error('nopermission'); - } - if (!$assignment->can_grade()) { - \print_error('nopermission'); - } - - $grade = $assignment->get_user_grade($userid, true, $attemptnumber); - - $contextid = $assignment->get_context()->id; - $component = 'assignfeedback_editpdf'; - $filearea = self::FINAL_PDF_FILEAREA; - $itemid = $grade->id; - - $fs = \get_file_storage(); - return $fs->delete_area_files($contextid, $component, $filearea, $itemid); - } - -} diff --git a/mod/assign/feedback/editpdf/classes/renderer.php b/mod/assign/feedback/editpdf/classes/renderer.php deleted file mode 100644 index a5d32e0..0000000 --- a/mod/assign/feedback/editpdf/classes/renderer.php +++ /dev/null @@ -1,258 +0,0 @@ -. - -/** - * This file contains the definition for the library class for edit PDF renderer. - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * A custom renderer class that extends the plugin_renderer_base and is used by the editpdf feedback plugin. - * - * @package assignfeedback_editpdf - * @copyright 2013 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class assignfeedback_editpdf_renderer extends plugin_renderer_base { - - /** - * Return the PDF button shortcut. - * - * @param string $name the name of a specific button. - * @return string the specific shortcut. - */ - private function get_shortcut($name) { - - $shortcuts = array('navigate-previous-button' => 'j', - 'navigate-page-select' => 'k', - 'navigate-next-button' => 'l', - 'searchcomments' => 'h', - 'comment' => 'z', - 'commentcolour' => 'x', - 'select' => 'c', - 'pen' => 'y', - 'line' => 'u', - 'rectangle' => 'i', - 'oval' => 'o', - 'highlight' => 'p', - 'annotationcolour' => 'r', - 'stamp' => 'n', - 'currentstamp' => 'm'); - - - // Return the shortcut. - return $shortcuts[$name]; - } - - /** - * Render a single colour button. - * - * @param string $icon - The key for the icon - * @param string $tool - The key for the lang string. - * @param string $accesskey Optional - The access key for the button. - * @param bool $disabled Optional - Is this button disabled. - * @return string - */ - private function render_toolbar_button($icon, $tool, $accesskey = null, $disabled=false) { - - // Build button alt text. - $alttext = new stdClass(); - $alttext->tool = $tool; - if (!empty($accesskey)) { - $alttext->shortcut = '(Alt/Shift-Alt/Ctrl-Option + ' . $accesskey . ')'; - } else { - $alttext->shortcut = ''; - } - $iconalt = get_string('toolbarbutton', 'assignfeedback_editpdf', $alttext); - - $iconhtml = $this->pix_icon($icon, $iconalt, 'assignfeedback_editpdf'); - $iconparams = array('data-tool'=>$tool, 'class'=>$tool . 'button'); - if ($disabled) { - $iconparams['disabled'] = 'true'; - } - if (!empty($accesskey)) { - $iconparams['accesskey'] = $accesskey; - } - - return html_writer::tag('button', $iconhtml, $iconparams); - } - - /** - * Render the editpdf widget in the grading form. - * - * @param assignfeedback_editpdf_widget $widget - Renderable widget containing assignment, user and attempt number. - * @return string - */ - public function render_assignfeedback_editpdf_widget(assignfeedback_editpdf_widget $widget) { - global $CFG; - - $html = ''; - - $html .= html_writer::div(get_string('jsrequired', 'assignfeedback_editpdf'), 'hiddenifjs'); - $linkid = html_writer::random_id(); - if ($widget->readonly) { - $launcheditorlink = html_writer::tag('a', - get_string('viewfeedbackonline', 'assignfeedback_editpdf'), - array('id'=>$linkid, 'class'=>'btn', 'href'=>'#')); - } else { - $launcheditorlink = html_writer::tag('a', - get_string('launcheditor', 'assignfeedback_editpdf'), - array('id'=>$linkid, 'class'=>'btn', 'href'=>'#')); - } - $links = $launcheditorlink; - - $links .= html_writer::tag('div', - get_string('unsavedchanges', 'assignfeedback_editpdf'), - array('class'=>'assignfeedback_editpdf_unsavedchanges warning')); - - $html .= html_writer::div($links, 'visibleifjs'); - $header = get_string('pluginname', 'assignfeedback_editpdf'); - $body = ''; - // Create the page navigation. - $navigation1 = ''; - $navigation2 = ''; - - // Pick the correct arrow icons for right to left mode. - if (right_to_left()) { - $nav_prev = 'nav_next'; - $nav_next = 'nav_prev'; - } else { - $nav_prev = 'nav_prev'; - $nav_next = 'nav_next'; - } - - $iconalt = get_string('navigateprevious', 'assignfeedback_editpdf'); - $iconhtml = $this->pix_icon($nav_prev, $iconalt, 'assignfeedback_editpdf'); - $navigation1 .= html_writer::tag('button', $iconhtml, array('disabled'=>'true', - 'class'=>'navigate-previous-button', 'accesskey' => $this->get_shortcut('navigate-previous-button'))); - $navigation1 .= html_writer::tag('select', null, array('disabled'=>'true', - 'aria-label' => get_string('gotopage', 'assignfeedback_editpdf'), 'class'=>'navigate-page-select', - 'accesskey' => $this->get_shortcut('navigate-page-select'))); - $iconalt = get_string('navigatenext', 'assignfeedback_editpdf'); - $iconhtml = $this->pix_icon($nav_next, $iconalt, 'assignfeedback_editpdf'); - $navigation1 .= html_writer::tag('button', $iconhtml, array('disabled'=>'true', - 'class'=>'navigate-next-button', 'accesskey' => $this->get_shortcut('navigate-next-button'))); - - $navigation1 = html_writer::div($navigation1, 'navigation', array('role'=>'navigation')); - - $navigation2 .= $this->render_toolbar_button('comment_search', 'searchcomments', $this->get_shortcut('searchcomments')); - $navigation2 = html_writer::div($navigation2, 'navigation-search', array('role'=>'navigation')); - - $toolbar1 = ''; - $toolbar2 = ''; - $toolbar3 = ''; - $toolbar4 = ''; - $clearfix = html_writer::div('', 'clearfix'); - if (!$widget->readonly) { - - // Comments. - $toolbar1 .= $this->render_toolbar_button('comment', 'comment', $this->get_shortcut('comment')); - $toolbar1 .= $this->render_toolbar_button('background_colour_clear', 'commentcolour', $this->get_shortcut('commentcolour')); - $toolbar1 = html_writer::div($toolbar1, 'toolbar', array('role'=>'toolbar')); - - // Select Tool. - $toolbar2 .= $this->render_toolbar_button('select', 'select', $this->get_shortcut('select')); - $toolbar2 = html_writer::div($toolbar2, 'toolbar', array('role'=>'toolbar')); - - // Other Tools. - $toolbar3 = $this->render_toolbar_button('pen', 'pen', $this->get_shortcut('pen')); - $toolbar3 .= $this->render_toolbar_button('line', 'line', $this->get_shortcut('line')); - $toolbar3 .= $this->render_toolbar_button('rectangle', 'rectangle', $this->get_shortcut('rectangle')); - $toolbar3 .= $this->render_toolbar_button('oval', 'oval', $this->get_shortcut('oval')); - $toolbar3 .= $this->render_toolbar_button('highlight', 'highlight', $this->get_shortcut('highlight')); - $toolbar3 .= $this->render_toolbar_button('background_colour_clear', 'annotationcolour', $this->get_shortcut('annotationcolour')); - $toolbar3 = html_writer::div($toolbar3, 'toolbar', array('role'=>'toolbar')); - - // Stamps. - $toolbar4 .= $this->render_toolbar_button('stamp', 'stamp', 'n'); - $toolbar4 .= $this->render_toolbar_button('background_colour_clear', 'currentstamp', $this->get_shortcut('currentstamp')); - $toolbar4 = html_writer::div($toolbar4, 'toolbar', array('role'=>'toolbar')); - } - - // Toobars written in reverse order because they are floated right. - $pageheader = html_writer::div($navigation1 . - $navigation2 . - $toolbar4 . - $toolbar3 . - $toolbar2 . - $toolbar1 . - $clearfix, - 'pageheader'); - $body = $pageheader; - - // Loading progress bar. - $progressbar = html_writer::div('', 'bar', array('style' => 'width: 0%')); - $progressbar = html_writer::div($progressbar, 'progress progress-info progress-striped active', - array('title' => get_string('loadingeditor', 'assignfeedback_editpdf'), - 'role'=> 'progressbar', 'aria-valuenow' => 0, 'aria-valuemin' => 0, - 'aria-valuemax' => 100)); - $progressbarlabel = html_writer::div(get_string('generatingpdf', 'assignfeedback_editpdf'), - 'progressbarlabel'); - $loading = html_writer::div($progressbar . $progressbarlabel, 'loading'); - - $canvas = html_writer::div($loading, 'drawingcanvas'); - $body .= html_writer::div($canvas, 'drawingregion'); - - $body .= '
'; - - $footer = ''; - - $editorparams = array(array('header'=>$header, - 'body'=>$body, - 'footer'=>$footer, - 'linkid'=>$linkid, - 'assignmentid'=>$widget->assignment, - 'userid'=>$widget->userid, - 'attemptnumber'=>$widget->attemptnumber, - 'stampfiles'=>$widget->stampfiles, - 'readonly'=>$widget->readonly, - 'pagetotal'=>$widget->pagetotal)); - - $this->page->requires->yui_module('moodle-assignfeedback_editpdf-editor', - 'M.assignfeedback_editpdf.editor.init', - $editorparams); - - $this->page->requires->strings_for_js(array( - 'yellow', - 'white', - 'red', - 'blue', - 'green', - 'black', - 'clear', - 'colourpicker', - 'loadingeditor', - 'pagexofy', - 'deletecomment', - 'addtoquicklist', - 'filter', - 'searchcomments', - 'commentcontextmenu', - 'deleteannotation', - 'stamp', - 'stamppicker', - 'cannotopenpdf', - 'pagenumber' - ), 'assignfeedback_editpdf'); - - return $html; - } -} diff --git a/mod/assign/feedback/editpdf/classes/widget.php b/mod/assign/feedback/editpdf/classes/widget.php deleted file mode 100644 index 83b17c7..0000000 --- a/mod/assign/feedback/editpdf/classes/widget.php +++ /dev/null @@ -1,75 +0,0 @@ -. - -/** - * This file contains the definition for the library class for edit PDF renderer. - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * A custom renderer class that extends the plugin_renderer_base and is used by the editpdf feedback plugin. - * - * @package assignfeedback_editpdf - * @copyright 2013 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class assignfeedback_editpdf_widget implements renderable { - - /** @var int $assignment - Assignment instance id */ - public $assignment = 0; - /** @var int $userid - The user id we are grading */ - public $userid = 0; - /** @var mixed $attemptnumber - The attempt number we are grading */ - public $attemptnumber = 0; - /** @var moodle_url $downloadurl */ - public $downloadurl = null; - /** @var string $downloadfilename */ - public $downloadfilename = null; - /** @var string[] $stampfiles */ - public $stampfiles = array(); - /** @var bool $readonly */ - public $readonly = true; - /** @var integer $pagetotal */ - public $pagetotal = 0; - - /** - * Constructor - * @param int $assignment - Assignment instance id - * @param int $userid - The user id we are grading - * @param int $attemptnumber - The attempt number we are grading - * @param moodle_url $downloadurl - A url to download the current generated pdf. - * @param string $downloadfilename - Name of the generated pdf. - * @param string[] $stampfiles - The file names of the stamps. - * @param bool $readonly - Show the readonly interface (no tools). - * @param integer $pagetotal - The total number of pages. - */ - public function __construct($assignment, $userid, $attemptnumber, $downloadurl, - $downloadfilename, $stampfiles, $readonly, $pagetotal) { - $this->assignment = $assignment; - $this->userid = $userid; - $this->attemptnumber = $attemptnumber; - $this->downloadurl = $downloadurl; - $this->downloadfilename = $downloadfilename; - $this->stampfiles = $stampfiles; - $this->readonly = $readonly; - $this->pagetotal = $pagetotal; - } -} diff --git a/mod/assign/feedback/editpdf/db/install.php b/mod/assign/feedback/editpdf/db/install.php deleted file mode 100644 index 1214a6a..0000000 --- a/mod/assign/feedback/editpdf/db/install.php +++ /dev/null @@ -1,53 +0,0 @@ -. - -/** - * Install code for the feedback_editpdf module. - * - * @package assignfeedback_editpdf - * @copyright 2013 Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * EditPDF install code - */ -function xmldb_assignfeedback_editpdf_install() { - global $CFG; - - // List of default stamps. - $defaultstamps = array('smile.png', 'sad.png', 'tick.png', 'cross.png'); - - // Stamp file object. - $filerecord = new stdClass; - $filerecord->component = 'assignfeedback_editpdf'; - $filerecord->contextid = context_system::instance()->id; - $filerecord->userid = get_admin()->id; - $filerecord->filearea = 'stamps'; - $filerecord->filepath = '/'; - $filerecord->itemid = 0; - - $fs = get_file_storage(); - - // Load all default stamps. - foreach ($defaultstamps as $stamp) { - $filerecord->filename = $stamp; - $fs->create_file_from_pathname($filerecord, - $CFG->dirroot . '/mod/assign/feedback/editpdf/pix/' . $filerecord->filename); - } -} diff --git a/mod/assign/feedback/editpdf/db/install.xml b/mod/assign/feedback/editpdf/db/install.xml deleted file mode 100644 index 39af982..0000000 --- a/mod/assign/feedback/editpdf/db/install.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
-
-
diff --git a/mod/assign/feedback/editpdf/fpdi/ASL20.txt b/mod/assign/feedback/editpdf/fpdi/ASL20.txt deleted file mode 100644 index d645695..0000000 --- a/mod/assign/feedback/editpdf/fpdi/ASL20.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85.php b/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85.php deleted file mode 100644 index a86c91f..0000000 --- a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85.php +++ /dev/null @@ -1,101 +0,0 @@ - ORD_u) { - return $this->error('Illegal character in ASCII85Decode.'); - } - - $chn[$state++] = $ch - ORD_exclmark; - - if ($state == 5) { - $state = 0; - $r = 0; - for ($j = 0; $j < 5; ++$j) - $r = $r * 85 + $chn[$j]; - $out .= chr($r >> 24); - $out .= chr($r >> 16); - $out .= chr($r >> 8); - $out .= chr($r); - } - } - $r = 0; - - if ($state == 1) - return $this->error('Illegal length in ASCII85Decode.'); - if ($state == 2) { - $r = $chn[0] * 85 * 85 * 85 * 85 + ($chn[1]+1) * 85 * 85 * 85; - $out .= chr($r >> 24); - } - else if ($state == 3) { - $r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + ($chn[2]+1) * 85 * 85; - $out .= chr($r >> 24); - $out .= chr($r >> 16); - } - else if ($state == 4) { - $r = $chn[0] * 85 * 85 * 85 * 85 + $chn[1] * 85 * 85 * 85 + $chn[2] * 85 * 85 + ($chn[3]+1) * 85 ; - $out .= chr($r >> 24); - $out .= chr($r >> 16); - $out .= chr($r >> 8); - } - - return $out; - } - - function encode($in) { - return $this->error("ASCII85 encoding not implemented."); - } - } -} diff --git a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85_FPDI.php b/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85_FPDI.php deleted file mode 100644 index 03413eb..0000000 --- a/mod/assign/feedback/editpdf/fpdi/filters/FilterASCII85_FPDI.php +++ /dev/null @@ -1,33 +0,0 @@ -fpdi =& $fpdi; - } - - function error($msg) { - $this->fpdi->error($msg); - } -} \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/filters/FilterLZW.php b/mod/assign/feedback/editpdf/fpdi/filters/FilterLZW.php deleted file mode 100644 index d3d3333..0000000 --- a/mod/assign/feedback/editpdf/fpdi/filters/FilterLZW.php +++ /dev/null @@ -1,157 +0,0 @@ -error('LZW flavour not supported.'); - } - - $this->initsTable(); - - $this->data = $data; - $this->dataLength = strlen($data); - - // Initialize pointers - $this->bytePointer = 0; - $this->bitPointer = 0; - - $this->nextData = 0; - $this->nextBits = 0; - - $oldCode = 0; - - $string = ''; - $uncompData = ''; - - while (($code = $this->getNextCode()) != 257) { - if ($code == 256) { - $this->initsTable(); - $code = $this->getNextCode(); - - if ($code == 257) { - break; - } - - $uncompData .= $this->sTable[$code]; - $oldCode = $code; - - } else { - - if ($code < $this->tIdx) { - $string = $this->sTable[$code]; - $uncompData .= $string; - - $this->addStringToTable($this->sTable[$oldCode], $string[0]); - $oldCode = $code; - } else { - $string = $this->sTable[$oldCode]; - $string = $string . $string[0]; - $uncompData .= $string; - - $this->addStringToTable($string); - $oldCode = $code; - } - } - } - - return $uncompData; - } - - - /** - * Initialize the string table. - */ - function initsTable() { - $this->sTable = array(); - - for ($i = 0; $i < 256; $i++) - $this->sTable[$i] = chr($i); - - $this->tIdx = 258; - $this->bitsToGet = 9; - } - - /** - * Add a new string to the string table. - */ - function addStringToTable ($oldString, $newString='') { - $string = $oldString.$newString; - - // Add this new String to the table - $this->sTable[$this->tIdx++] = $string; - - if ($this->tIdx == 511) { - $this->bitsToGet = 10; - } else if ($this->tIdx == 1023) { - $this->bitsToGet = 11; - } else if ($this->tIdx == 2047) { - $this->bitsToGet = 12; - } - } - - // Returns the next 9, 10, 11 or 12 bits - function getNextCode() { - if ($this->bytePointer == $this->dataLength) { - return 257; - } - - $this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff); - $this->nextBits += 8; - - if ($this->nextBits < $this->bitsToGet) { - $this->nextData = ($this->nextData << 8) | (ord($this->data[$this->bytePointer++]) & 0xff); - $this->nextBits += 8; - } - - $code = ($this->nextData >> ($this->nextBits - $this->bitsToGet)) & $this->andTable[$this->bitsToGet-9]; - $this->nextBits -= $this->bitsToGet; - - return $code; - } - - function encode($in) { - $this->error("LZW encoding not implemented."); - } - } -} diff --git a/mod/assign/feedback/editpdf/fpdi/filters/FilterLZW_FPDI.php b/mod/assign/feedback/editpdf/fpdi/filters/FilterLZW_FPDI.php deleted file mode 100644 index decc170..0000000 --- a/mod/assign/feedback/editpdf/fpdi/filters/FilterLZW_FPDI.php +++ /dev/null @@ -1,33 +0,0 @@ -fpdi =& $fpdi; - } - - function error($msg) { - $this->fpdi->error($msg); - } -} \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/fpdf_tpl.php b/mod/assign/feedback/editpdf/fpdi/fpdf_tpl.php deleted file mode 100644 index 20584a5..0000000 --- a/mod/assign/feedback/editpdf/fpdi/fpdf_tpl.php +++ /dev/null @@ -1,460 +0,0 @@ -Error('This method is only usable with FPDF. Use TCPDF methods startTemplate() instead.'); - return; - } - - if ($this->page <= 0) - $this->error("You have to add a page to fpdf first!"); - - if ($x == null) - $x = 0; - if ($y == null) - $y = 0; - if ($w == null) - $w = $this->w; - if ($h == null) - $h = $this->h; - - // Save settings - $this->tpl++; - $tpl =& $this->tpls[$this->tpl]; - $tpl = array( - 'o_x' => $this->x, - 'o_y' => $this->y, - 'o_AutoPageBreak' => $this->AutoPageBreak, - 'o_bMargin' => $this->bMargin, - 'o_tMargin' => $this->tMargin, - 'o_lMargin' => $this->lMargin, - 'o_rMargin' => $this->rMargin, - 'o_h' => $this->h, - 'o_w' => $this->w, - 'o_FontFamily' => $this->FontFamily, - 'o_FontStyle' => $this->FontStyle, - 'o_FontSizePt' => $this->FontSizePt, - 'o_FontSize' => $this->FontSize, - 'buffer' => '', - 'x' => $x, - 'y' => $y, - 'w' => $w, - 'h' => $h - ); - - $this->SetAutoPageBreak(false); - - // Define own high and width to calculate possitions correct - $this->h = $h; - $this->w = $w; - - $this->_intpl = true; - $this->SetXY($x + $this->lMargin, $y + $this->tMargin); - $this->SetRightMargin($this->w - $w + $this->rMargin); - - if ($this->CurrentFont) { - $fontkey = $this->FontFamily . $this->FontStyle; - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - - $this->_out(sprintf('BT /F%d %.2f Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); - } - - return $this->tpl; - } - - /** - * End Template - * - * This method ends a template and reset initiated variables on beginTemplate. - * - * @return mixed If a template is opened, the ID is returned. If not a false is returned. - */ - function endTemplate() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::endTemplate'), $args); - } - - if ($this->_intpl) { - $this->_intpl = false; - $tpl =& $this->tpls[$this->tpl]; - $this->SetXY($tpl['o_x'], $tpl['o_y']); - $this->tMargin = $tpl['o_tMargin']; - $this->lMargin = $tpl['o_lMargin']; - $this->rMargin = $tpl['o_rMargin']; - $this->h = $tpl['o_h']; - $this->w = $tpl['o_w']; - $this->SetAutoPageBreak($tpl['o_AutoPageBreak'], $tpl['o_bMargin']); - - $this->FontFamily = $tpl['o_FontFamily']; - $this->FontStyle = $tpl['o_FontStyle']; - $this->FontSizePt = $tpl['o_FontSizePt']; - $this->FontSize = $tpl['o_FontSize']; - - $fontkey = $this->FontFamily . $this->FontStyle; - if ($fontkey) - $this->CurrentFont =& $this->fonts[$fontkey]; - - return $this->tpl; - } else { - return false; - } - } - - /** - * Use a Template in current Page or other Template - * - * You can use a template in a page or in another template. - * You can give the used template a new size like you use the Image()-method. - * All parameters are optional. The width or height is calculated automaticaly - * if one is given. If no parameter is given the origin size as defined in - * beginTemplate() is used. - * The calculated or used width and height are returned as an array. - * - * @param int $tplidx A valid template-Id - * @param int $_x The x-position - * @param int $_y The y-position - * @param int $_w The new width of the template - * @param int $_h The new height of the template - * @return array The height and width of the template - */ - function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0) { - if ($this->page <= 0) - $this->error('You have to add a page first!'); - - if (!isset($this->tpls[$tplidx])) - $this->error('Template does not exist!'); - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['tpls'][$tplidx] =& $this->tpls[$tplidx]; - } - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_x == null) - $_x = 0; - if ($_y == null) - $_y = 0; - - $_x += $tpl['x']; - $_y += $tpl['y']; - - $wh = $this->getTemplateSize($tplidx, $_w, $_h); - $_w = $wh['w']; - $_h = $wh['h']; - - $tData = array( - 'x' => $this->x, - 'y' => $this->y, - 'w' => $_w, - 'h' => $_h, - 'scaleX' => ($_w / $w), - 'scaleY' => ($_h / $h), - 'tx' => $_x, - 'ty' => ($this->h - $_y - $_h), - 'lty' => ($this->h - $_y - $_h) - ($this->h - $h) * ($_h / $h) - ); - - $this->_out(sprintf('q %.4F 0 0 %.4F %.4F %.4F cm', $tData['scaleX'], $tData['scaleY'], $tData['tx'] * $this->k, $tData['ty'] * $this->k)); // Translate - $this->_out(sprintf('%s%d Do Q', $this->tplprefix, $tplidx)); - - $this->lastUsedTemplateData = $tData; - - return array('w' => $_w, 'h' => $_h); - } - - /** - * Get The calculated Size of a Template - * - * If one size is given, this method calculates the other one. - * - * @param int $tplidx A valid template-Id - * @param int $_w The width of the template - * @param int $_h The height of the template - * @return array The height and width of the template - */ - function getTemplateSize($tplidx, $_w = 0, $_h = 0) { - if (!isset($this->tpls[$tplidx])) - return false; - - $tpl =& $this->tpls[$tplidx]; - $w = $tpl['w']; - $h = $tpl['h']; - - if ($_w == 0 and $_h == 0) { - $_w = $w; - $_h = $h; - } - - if($_w == 0) - $_w = $_h * $w / $h; - if($_h == 0) - $_h = $_w * $h / $w; - - return array("w" => $_w, "h" => $_h); - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - public function SetFont($family, $style='', $size=null, $fontfile='', $subset='default', $out=true) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetFont'), $args); - } - - parent::SetFont($family, $style, $size); - - $fontkey = $this->FontFamily . $this->FontStyle; - - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } else { - $this->_res['page'][$this->page]['fonts'][$fontkey] =& $this->fonts[$fontkey]; - } - } - - /** - * See FPDF/TCPDF-Documentation ;-) - */ - function Image( - $file, $x = '', $y = '', $w = 0, $h = 0, $type = '', $link = '', $align = '', $resize = false, - $dpi = 300, $palign = '', $ismask = false, $imgmask = false, $border = 0, $fitbox = false, - $hidden = false, $fitonpage = false, $alt = false, $altimgs = array() - ) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Image'), $args); - } - - $ret = parent::Image($file, $x, $y, $w, $h, $type, $link); - if ($this->_intpl) { - $this->_res['tpl'][$this->tpl]['images'][$file] =& $this->images[$file]; - } else { - $this->_res['page'][$this->page]['images'][$file] =& $this->images[$file]; - } - - return $ret; - } - - /** - * See FPDF-Documentation ;-) - * - * AddPage is not available when you're "in" a template. - */ - function AddPage($orientation = '', $format = '', $keepmargins = false, $tocpage = false) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddPage'), $args); - } - - if ($this->_intpl) - $this->Error('Adding pages in templates isn\'t possible!'); - - parent::AddPage($orientation, $format); - } - - /** - * Preserve adding Links in Templates ...won't work - */ - function Link($x, $y, $w, $h, $link, $spaces = 0) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::Link'), $args); - } - - if ($this->_intpl) - $this->Error('Using links in templates aren\'t possible!'); - - parent::Link($x, $y, $w, $h, $link); - } - - function AddLink() { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::AddLink'), $args); - } - - if ($this->_intpl) - $this->Error('Adding links in templates aren\'t possible!'); - return parent::AddLink(); - } - - function SetLink($link, $y = 0, $page = -1) { - if (is_subclass_of($this, 'TCPDF')) { - $args = func_get_args(); - return call_user_func_array(array($this, 'TCPDF::SetLink'), $args); - } - - if ($this->_intpl) - $this->Error('Setting links in templates aren\'t possible!'); - parent::SetLink($link, $y, $page); - } - - /** - * Private Method that writes the form xobjects - */ - function _putformxobjects() { - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; - reset($this->tpls); - foreach($this->tpls AS $tplidx => $tpl) { - - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; - $this->_newobj(); - $this->tpls[$tplidx]['n'] = $this->n; - $this->_out('<<'.$filter.'/Type /XObject'); - $this->_out('/Subtype /Form'); - $this->_out('/FormType 1'); - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', - // llx - $tpl['x'] * $this->k, - // lly - -$tpl['y'] * $this->k, - // urx - ($tpl['w'] + $tpl['x']) * $this->k, - // ury - ($tpl['h'] - $tpl['y']) * $this->k - )); - - if ($tpl['x'] != 0 || $tpl['y'] != 0) { - $this->_out(sprintf('/Matrix [1 0 0 1 %.5F %.5F]', - -$tpl['x'] * $this->k * 2, $tpl['y'] * $this->k * 2 - )); - } - - $this->_out('/Resources '); - - $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { - $this->_out('/Font <<'); - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); - $this->_out('>>'); - } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) - { - $this->_out('/XObject <<'); - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { - foreach($this->_res['tpl'][$tplidx]['images'] as $image) - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); - } - if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); - } - $this->_out('>>'); - } - $this->_out('>>'); - - $this->_out('/Length ' . strlen($p) . ' >>'); - $this->_putstream($p); - $this->_out('endobj'); - } - } - - /** - * Overwritten to add _putformxobjects() after _putimages() - * - */ - function _putimages() { - parent::_putimages(); - $this->_putformxobjects(); - } - - function _putxobjectdict() { - parent::_putxobjectdict(); - - if (count($this->tpls)) { - foreach($this->tpls as $tplidx => $tpl) { - $this->_out(sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n'])); - } - } - } - - /** - * Private Method - */ - function _out($s) { - if ($this->state == 2 && $this->_intpl) { - $this->tpls[$this->tpl]['buffer'] .= $s . "\n"; - } else { - parent::_out($s); - } - } -} diff --git a/mod/assign/feedback/editpdf/fpdi/fpdi.php b/mod/assign/feedback/editpdf/fpdi/fpdi.php deleted file mode 100644 index 8cae46c..0000000 --- a/mod/assign/feedback/editpdf/fpdi/fpdi.php +++ /dev/null @@ -1,588 +0,0 @@ -current_filename = $filename; - - if (!isset($this->parsers[$filename])) - $this->parsers[$filename] = $this->_getPdfParser($filename); - $this->current_parser =& $this->parsers[$filename]; - - return $this->parsers[$filename]->getPageCount(); - } - - /** - * Returns a PDF parser object - * - * @param string $filename - * @return fpdi_pdf_parser - */ - function _getPdfParser($filename) { - return new fpdi_pdf_parser($filename, $this); - } - - /** - * Get the current PDF version - * - * @return string - */ - function getPDFVersion() { - return $this->PDFVersion; - } - - /** - * Set the PDF version - * - * @return string - */ - function setPDFVersion($version = '1.3') { - $this->PDFVersion = $version; - } - - /** - * Import a page - * - * @param int $pageno pagenumber - * @return int Index of imported page - to use with fpdf_tpl::useTemplate() - */ - function importPage($pageno, $boxName = '/CropBox') { - if ($this->_intpl) { - return $this->error('Please import the desired pages before creating a new template.'); - } - - $fn = $this->current_filename; - - // check if page already imported - $pageKey = $fn . '-' . ((int)$pageno) . $boxName; - if (isset($this->_importedPages[$pageKey])) - return $this->_importedPages[$pageKey]; - - $parser =& $this->parsers[$fn]; - $parser->setPageno($pageno); - - if (!in_array($boxName, $parser->availableBoxes)) - return $this->Error(sprintf('Unknown box: %s', $boxName)); - - $pageboxes = $parser->getPageBoxes($pageno, $this->k); - - /** - * MediaBox - * CropBox: Default -> MediaBox - * BleedBox: Default -> CropBox - * TrimBox: Default -> CropBox - * ArtBox: Default -> CropBox - */ - if (!isset($pageboxes[$boxName]) && ($boxName == '/BleedBox' || $boxName == '/TrimBox' || $boxName == '/ArtBox')) - $boxName = '/CropBox'; - if (!isset($pageboxes[$boxName]) && $boxName == '/CropBox') - $boxName = '/MediaBox'; - - if (!isset($pageboxes[$boxName])) - return false; - - $this->lastUsedPageBox = $boxName; - - $box = $pageboxes[$boxName]; - - $this->tpl++; - $this->tpls[$this->tpl] = array(); - $tpl =& $this->tpls[$this->tpl]; - $tpl['parser'] =& $parser; - $tpl['resources'] = $parser->getPageResources(); - $tpl['buffer'] = $parser->getContent(); - $tpl['box'] = $box; - - // To build an array that can be used by PDF_TPL::useTemplate() - $this->tpls[$this->tpl] = array_merge($this->tpls[$this->tpl], $box); - - // An imported page will start at 0,0 everytime. Translation will be set in _putformxobjects() - $tpl['x'] = 0; - $tpl['y'] = 0; - - // handle rotated pages - $rotation = $parser->getPageRotation($pageno); - $tpl['_rotationAngle'] = 0; - if (isset($rotation[1]) && ($angle = $rotation[1] % 360) != 0) { - $steps = $angle / 90; - - $_w = $tpl['w']; - $_h = $tpl['h']; - $tpl['w'] = $steps % 2 == 0 ? $_w : $_h; - $tpl['h'] = $steps % 2 == 0 ? $_h : $_w; - - if ($angle < 0) - $angle += 360; - - $tpl['_rotationAngle'] = $angle * -1; - } - - $this->_importedPages[$pageKey] = $this->tpl; - - return $this->tpl; - } - - /** - * Returns the last used page box - * - * @return string - */ - function getLastUsedPageBox() { - return $this->lastUsedPageBox; - } - - - function useTemplate($tplidx, $_x = null, $_y = null, $_w = 0, $_h = 0, $adjustPageSize = false) { - if ($adjustPageSize == true && is_null($_x) && is_null($_y)) { - $size = $this->getTemplateSize($tplidx, $_w, $_h); - $orientation = $size['w'] > $size['h'] ? 'L' : 'P'; - $size = array($size['w'], $size['h']); - - if (is_subclass_of($this, 'TCPDF')) { - $this->setPageFormat($size, $orientation); - } else { - $size = $this->_getpagesize($size); - - if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) - { - // New size or orientation - if($orientation=='P') - { - $this->w = $size[0]; - $this->h = $size[1]; - } - else - { - $this->w = $size[1]; - $this->h = $size[0]; - } - $this->wPt = $this->w*$this->k; - $this->hPt = $this->h*$this->k; - $this->PageBreakTrigger = $this->h-$this->bMargin; - $this->CurOrientation = $orientation; - $this->CurPageSize = $size; - $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); - } - } - } - - $this->_out('q 0 J 1 w 0 j 0 G 0 g'); // reset standard values - $s = parent::useTemplate($tplidx, $_x, $_y, $_w, $_h); - $this->_out('Q'); - - return $s; - } - - /** - * Private method, that rebuilds all needed objects of source files - */ - function _putimportedobjects() { - if (is_array($this->parsers) && count($this->parsers) > 0) { - foreach($this->parsers AS $filename => $p) { - $this->current_parser =& $this->parsers[$filename]; - if (isset($this->_obj_stack[$filename]) && is_array($this->_obj_stack[$filename])) { - while(($n = key($this->_obj_stack[$filename])) !== null) { - $nObj = $this->current_parser->pdf_resolve_object($this->current_parser->c, $this->_obj_stack[$filename][$n][1]); - - $this->_newobj($this->_obj_stack[$filename][$n][0]); - - if ($nObj[0] == PDF_TYPE_STREAM) { - $this->pdf_write_value($nObj); - } else { - $this->pdf_write_value($nObj[1]); - } - - $this->_out('endobj'); - $this->_obj_stack[$filename][$n] = null; // free memory - unset($this->_obj_stack[$filename][$n]); - reset($this->_obj_stack[$filename]); - } - } - } - } - } - - - /** - * Private Method that writes the form xobjects - */ - function _putformxobjects() { - $filter=($this->compress) ? '/Filter /FlateDecode ' : ''; - reset($this->tpls); - foreach($this->tpls AS $tplidx => $tpl) { - $p=($this->compress) ? gzcompress($tpl['buffer']) : $tpl['buffer']; - $this->_newobj(); - $cN = $this->n; // TCPDF/Protection: rem current "n" - - $this->tpls[$tplidx]['n'] = $this->n; - $this->_out('<<' . $filter . '/Type /XObject'); - $this->_out('/Subtype /Form'); - $this->_out('/FormType 1'); - - $this->_out(sprintf('/BBox [%.2F %.2F %.2F %.2F]', - (isset($tpl['box']['llx']) ? $tpl['box']['llx'] : $tpl['x']) * $this->k, - (isset($tpl['box']['lly']) ? $tpl['box']['lly'] : -$tpl['y']) * $this->k, - (isset($tpl['box']['urx']) ? $tpl['box']['urx'] : $tpl['w'] + $tpl['x']) * $this->k, - (isset($tpl['box']['ury']) ? $tpl['box']['ury'] : $tpl['h'] - $tpl['y']) * $this->k - )); - - $c = 1; - $s = 0; - $tx = 0; - $ty = 0; - - if (isset($tpl['box'])) { - $tx = -$tpl['box']['llx']; - $ty = -$tpl['box']['lly']; - - if ($tpl['_rotationAngle'] <> 0) { - $angle = $tpl['_rotationAngle'] * M_PI/180; - $c=cos($angle); - $s=sin($angle); - - switch($tpl['_rotationAngle']) { - case -90: - $tx = -$tpl['box']['lly']; - $ty = $tpl['box']['urx']; - break; - case -180: - $tx = $tpl['box']['urx']; - $ty = $tpl['box']['ury']; - break; - case -270: - $tx = $tpl['box']['ury']; - $ty = -$tpl['box']['llx']; - break; - } - } - } elseif ($tpl['x'] != 0 || $tpl['y'] != 0) { - $tx = -$tpl['x'] * 2; - $ty = $tpl['y'] * 2; - } - - $tx *= $this->k; - $ty *= $this->k; - - if ($c != 1 || $s != 0 || $tx != 0 || $ty != 0) { - $this->_out(sprintf('/Matrix [%.5F %.5F %.5F %.5F %.5F %.5F]', - $c, $s, -$s, $c, $tx, $ty - )); - } - - $this->_out('/Resources '); - - if (isset($tpl['resources'])) { - $this->current_parser =& $tpl['parser']; - $this->pdf_write_value($tpl['resources']); // "n" will be changed - } else { - $this->_out('<_res['tpl'][$tplidx]['fonts']) && count($this->_res['tpl'][$tplidx]['fonts'])) { - $this->_out('/Font <<'); - foreach($this->_res['tpl'][$tplidx]['fonts'] as $font) - $this->_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R'); - $this->_out('>>'); - } - if(isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images']) || - isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) - { - $this->_out('/XObject <<'); - if (isset($this->_res['tpl'][$tplidx]['images']) && count($this->_res['tpl'][$tplidx]['images'])) { - foreach($this->_res['tpl'][$tplidx]['images'] as $image) - $this->_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R'); - } - if (isset($this->_res['tpl'][$tplidx]['tpls']) && count($this->_res['tpl'][$tplidx]['tpls'])) { - foreach($this->_res['tpl'][$tplidx]['tpls'] as $i => $tpl) - $this->_out($this->tplprefix . $i . ' ' . $tpl['n'] . ' 0 R'); - } - $this->_out('>>'); - } - $this->_out('>>'); - } - - $this->_out('/Group <>'); - - $nN = $this->n; // TCPDF: rem new "n" - $this->n = $cN; // TCPDF: reset to current "n" - if (is_subclass_of($this, 'TCPDF')) { - $p = $this->_getrawstream($p); - $this->_out('/Length ' . strlen($p) . ' >>'); - $this->_out("stream\n" . $p . "\nendstream"); - } else { - $this->_out('/Length ' . strlen($p) . ' >>'); - $this->_putstream($p); - } - $this->_out('endobj'); - $this->n = $nN; // TCPDF: reset to new "n" - } - - $this->_putimportedobjects(); - } - - /** - * Rewritten to handle existing own defined objects - */ - function _newobj($obj_id = false, $onlynewobj = false) { - if (!$obj_id) { - $obj_id = ++$this->n; - } - - //Begin a new object - if (!$onlynewobj) { - $this->offsets[$obj_id] = is_subclass_of($this, 'TCPDF') ? $this->bufferlen : strlen($this->buffer); - $this->_out($obj_id . ' 0 obj'); - $this->_current_obj_id = $obj_id; // for later use with encryption - } - - return $obj_id; - } - - /** - * Writes a value - * Needed to rebuild the source document - * - * @param mixed $value A PDF-Value. Structure of values see cases in this method - */ - function pdf_write_value(&$value) - { - if (is_subclass_of($this, 'TCPDF')) { - parent::pdf_write_value($value); - } - - switch ($value[0]) { - - case PDF_TYPE_TOKEN: - $this->_straightOut($value[1] . ' '); - break; - case PDF_TYPE_NUMERIC: - case PDF_TYPE_REAL: - if (is_float($value[1]) && $value[1] != 0) { - $this->_straightOut(rtrim(rtrim(sprintf('%F', $value[1]), '0'), '.') . ' '); - } else { - $this->_straightOut($value[1] . ' '); - } - break; - - case PDF_TYPE_ARRAY: - - // An array. Output the proper - // structure and move on. - - $this->_straightOut('['); - for ($i = 0; $i < count($value[1]); $i++) { - $this->pdf_write_value($value[1][$i]); - } - - $this->_out(']'); - break; - - case PDF_TYPE_DICTIONARY: - - // A dictionary. - $this->_straightOut('<<'); - - reset ($value[1]); - - while (list($k, $v) = each($value[1])) { - $this->_straightOut($k . ' '); - $this->pdf_write_value($v); - } - - $this->_straightOut('>>'); - break; - - case PDF_TYPE_OBJREF: - - // An indirect object reference - // Fill the object stack if needed - $cpfn =& $this->current_parser->filename; - - if (!isset($this->_don_obj_stack[$cpfn][$value[1]])) { - $this->_newobj(false, true); - $this->_obj_stack[$cpfn][$value[1]] = array($this->n, $value); - $this->_don_obj_stack[$cpfn][$value[1]] = array($this->n, $value); // Value is maybee obsolete!!! - } - $objid = $this->_don_obj_stack[$cpfn][$value[1]][0]; - - $this->_out($objid . ' 0 R'); - break; - - case PDF_TYPE_STRING: - - // A string. - $this->_straightOut('(' . $value[1] . ')'); - - break; - - case PDF_TYPE_STREAM: - - // A stream. First, output the - // stream dictionary, then the - // stream data itself. - $this->pdf_write_value($value[1]); - $this->_out('stream'); - $this->_out($value[2][1]); - $this->_out('endstream'); - break; - - case PDF_TYPE_HEX: - $this->_straightOut('<' . $value[1] . '>'); - break; - - case PDF_TYPE_BOOLEAN: - $this->_straightOut($value[1] ? 'true ' : 'false '); - break; - - case PDF_TYPE_NULL: - // The null object. - - $this->_straightOut('null '); - break; - } - } - - - /** - * Modified so not each call will add a newline to the output. - */ - function _straightOut($s) { - if (!is_subclass_of($this, 'TCPDF')) { - if($this->state==2) - $this->pages[$this->page] .= $s; - else - $this->buffer .= $s; - } else { - if ($this->state == 2) { - if ($this->inxobj) { - // we are inside an XObject template - $this->xobjects[$this->xobjid]['outdata'] .= $s; - } elseif ((!$this->InFooter) AND isset($this->footerlen[$this->page]) AND ($this->footerlen[$this->page] > 0)) { - // puts data before page footer - $pagebuff = $this->getPageBuffer($this->page); - $page = substr($pagebuff, 0, -$this->footerlen[$this->page]); - $footer = substr($pagebuff, -$this->footerlen[$this->page]); - $this->setPageBuffer($this->page, $page.$s.$footer); - // update footer position - $this->footerpos[$this->page] += strlen($s); - } else { - // set page data - $this->setPageBuffer($this->page, $s, true); - } - } elseif ($this->state > 0) { - // set general data - $this->setBuffer($s); - } - } - } - - /** - * rewritten to close opened parsers - * - */ - function _enddoc() { - parent::_enddoc(); - $this->_closeParsers(); - } - - /** - * close all files opened by parsers - */ - function _closeParsers() { - if ($this->state > 2 && count($this->parsers) > 0) { - $this->cleanUp(); - return true; - } - return false; - } - - /** - * Removes cylced references and closes the file handles of the parser objects - */ - function cleanUp() { - foreach ($this->parsers as $k => $_){ - $this->parsers[$k]->cleanUp(); - $this->parsers[$k] = null; - unset($this->parsers[$k]); - } - } -} \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/fpdi2tcpdf_bridge.php b/mod/assign/feedback/editpdf/fpdi/fpdi2tcpdf_bridge.php deleted file mode 100644 index b4a6c70..0000000 --- a/mod/assign/feedback/editpdf/fpdi/fpdi2tcpdf_bridge.php +++ /dev/null @@ -1,171 +0,0 @@ -libdir.'/pdflib.php'); - -/** - * This class is used as a bridge between TCPDF and FPDI - * and will create the possibility to use both FPDF and TCPDF - * via one FPDI version. - * - * We'll simply remap TCPDF to FPDF again. - * - * It'll be loaded and extended by FPDF_TPL. - * Modified to extend the moodle TCPDF wrapper instead. - */ -class FPDF extends pdf { - - function _putstream($s, $n=0) { - $this->_out($this->_getstream($s)); - } - - function _getxobjectdict() { - $out = parent::_getxobjectdict(); - if (count($this->tpls)) { - foreach($this->tpls as $tplidx => $tpl) { - $out .= sprintf('%s%d %d 0 R', $this->tplprefix, $tplidx, $tpl['n']); - } - } - - return $out; - } - - /** - * Encryption of imported data by FPDI - * - * @param array $value - */ - function pdf_write_value(&$value) { - switch ($value[0]) { - case PDF_TYPE_STRING: - if ($this->encrypted) { - $value[1] = $this->_unescape($value[1]); - $value[1] = $this->_encrypt_data($this->_current_obj_id, $value[1]); - $value[1] = TCPDF_STATIC::_escape($value[1]); - } - break; - - case PDF_TYPE_STREAM: - if ($this->encrypted) { - $value[2][1] = $this->_encrypt_data($this->_current_obj_id, $value[2][1]); - $value[1][1]['/Length'] = array( - PDF_TYPE_NUMERIC, - strlen($value[2][1]) - ); - } - break; - - case PDF_TYPE_HEX: - if ($this->encrypted) { - $value[1] = $this->hex2str($value[1]); - $value[1] = $this->_encrypt_data($this->_current_obj_id, $value[1]); - - // remake hexstring of encrypted string - $value[1] = $this->str2hex($value[1]); - } - break; - } - } - - /** - * Unescapes a PDF string - * - * @param string $s - * @return string - */ - function _unescape($s) { - $out = ''; - for ($count = 0, $n = strlen($s); $count < $n; $count++) { - if ($s[$count] != '\\' || $count == $n-1) { - $out .= $s[$count]; - } else { - switch ($s[++$count]) { - case ')': - case '(': - case '\\': - $out .= $s[$count]; - break; - case 'f': - $out .= chr(0x0C); - break; - case 'b': - $out .= chr(0x08); - break; - case 't': - $out .= chr(0x09); - break; - case 'r': - $out .= chr(0x0D); - break; - case 'n': - $out .= chr(0x0A); - break; - case "\r": - if ($count != $n-1 && $s[$count+1] == "\n") - $count++; - break; - case "\n": - break; - default: - // Octal-Values - if (ord($s[$count]) >= ord('0') && - ord($s[$count]) <= ord('9')) { - $oct = ''. $s[$count]; - - if (ord($s[$count+1]) >= ord('0') && - ord($s[$count+1]) <= ord('9')) { - $oct .= $s[++$count]; - - if (ord($s[$count+1]) >= ord('0') && - ord($s[$count+1]) <= ord('9')) { - $oct .= $s[++$count]; - } - } - - $out .= chr(octdec($oct)); - } else { - $out .= $s[$count]; - } - } - } - } - return $out; - } - - /** - * Hexadecimal to string - * - * @param string $hex - * @return string - */ - function hex2str($hex) { - return pack('H*', str_replace(array("\r", "\n", ' '), '', $hex)); - } - - /** - * String to hexadecimal - * - * @param string $str - * @return string - */ - function str2hex($str) { - return current(unpack('H*', $str)); - } -} diff --git a/mod/assign/feedback/editpdf/fpdi/fpdi_pdf_parser.php b/mod/assign/feedback/editpdf/fpdi/fpdi_pdf_parser.php deleted file mode 100644 index 41a0e03..0000000 --- a/mod/assign/feedback/editpdf/fpdi/fpdi_pdf_parser.php +++ /dev/null @@ -1,423 +0,0 @@ -fpdi =& $fpdi; - - parent::pdf_parser($filename); - - // resolve Pages-Dictonary - $pages = $this->pdf_resolve_object($this->c, $this->root[1][1]['/Pages']); - - // Read pages - $this->read_pages($this->c, $pages, $this->pages); - - // count pages; - $this->page_count = count($this->pages); - } - - /** - * Removes reference to fpdi object and closes the file handle - */ - function cleanUp() { - $this->fpdi = null; - $this->closeFile(); - } - - /** - * Overwrite parent::error() - * - * @param string $msg Error-Message - */ - function error($msg) { - $this->fpdi->error($msg); - } - - /** - * Get pagecount from sourcefile - * - * @return int - */ - function getPageCount() { - return $this->page_count; - } - - - /** - * Set pageno - * - * @param int $pageno Pagenumber to use - */ - function setPageno($pageno) { - $pageno = ((int) $pageno) - 1; - - if ($pageno < 0 || $pageno >= $this->getPageCount()) { - $this->fpdi->error('Pagenumber is wrong!'); - } - - $this->pageno = $pageno; - } - - /** - * Get page-resources from current page - * - * @return array - */ - function getPageResources() { - return $this->_getPageResources($this->pages[$this->pageno]); - } - - /** - * Get page-resources from /Page - * - * @param array $obj Array of pdf-data - */ - function _getPageResources ($obj) { // $obj = /Page - $obj = $this->pdf_resolve_object($this->c, $obj); - - // If the current object has a resources - // dictionary associated with it, we use - // it. Otherwise, we move back to its - // parent object. - if (isset ($obj[1][1]['/Resources'])) { - $res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Resources']); - if ($res[0] == PDF_TYPE_OBJECT) - return $res[1]; - return $res; - } else { - if (!isset ($obj[1][1]['/Parent'])) { - return false; - } else { - $res = $this->_getPageResources($obj[1][1]['/Parent']); - if ($res[0] == PDF_TYPE_OBJECT) - return $res[1]; - return $res; - } - } - } - - - /** - * Get content of current page - * - * If more /Contents is an array, the streams are concated - * - * @return string - */ - function getContent() { - $buffer = ''; - - if (isset($this->pages[$this->pageno][1][1]['/Contents'])) { - $contents = $this->_getPageContent($this->pages[$this->pageno][1][1]['/Contents']); - foreach($contents AS $tmp_content) { - $buffer .= $this->_rebuildContentStream($tmp_content) . ' '; - } - } - - return $buffer; - } - - - /** - * Resolve all content-objects - * - * @param array $content_ref - * @return array - */ - function _getPageContent($content_ref) { - $contents = array(); - - if ($content_ref[0] == PDF_TYPE_OBJREF) { - $content = $this->pdf_resolve_object($this->c, $content_ref); - if ($content[1][0] == PDF_TYPE_ARRAY) { - $contents = $this->_getPageContent($content[1]); - } else { - $contents[] = $content; - } - } elseif ($content_ref[0] == PDF_TYPE_ARRAY) { - foreach ($content_ref[1] AS $tmp_content_ref) { - $contents = array_merge($contents,$this->_getPageContent($tmp_content_ref)); - } - } - - return $contents; - } - - - /** - * Rebuild content-streams - * - * @param array $obj - * @return string - */ - function _rebuildContentStream($obj) { - $filters = array(); - - if (isset($obj[1][1]['/Filter'])) { - $_filter = $obj[1][1]['/Filter']; - - if ($_filter[0] == PDF_TYPE_OBJREF) { - $tmpFilter = $this->pdf_resolve_object($this->c, $_filter); - $_filter = $tmpFilter[1]; - } - - if ($_filter[0] == PDF_TYPE_TOKEN) { - $filters[] = $_filter; - } elseif ($_filter[0] == PDF_TYPE_ARRAY) { - $filters = $_filter[1]; - } - } - - $stream = $obj[2][1]; - - foreach ($filters AS $_filter) { - switch ($_filter[1]) { - case '/FlateDecode': - case '/Fl': - // $stream .= "\x0F\x0D"; // in an errorious stream this suffix could work - // $stream .= "\x0A"; - // $stream .= "\x0D"; - if (function_exists('gzuncompress')) { - $oStream = $stream; - $stream = (strlen($stream) > 0) ? @gzuncompress($stream) : ''; - } else { - $this->error(sprintf('To handle %s filter, please compile php with zlib support.',$_filter[1])); - } - - if ($stream === false) { - $oStream = substr($oStream, 2); - $stream = @gzinflate($oStream); - if ($stream == false) { - $this->error('Error while decompressing stream.'); - } - } - break; - case '/LZWDecode': - include_once('filters/FilterLZW_FPDI.php'); - $decoder = new FilterLZW_FPDI($this->fpdi); - $stream = $decoder->decode($stream); - break; - case '/ASCII85Decode': - include_once('filters/FilterASCII85_FPDI.php'); - $decoder = new FilterASCII85_FPDI($this->fpdi); - $stream = $decoder->decode($stream); - break; - case null: - $stream = $stream; - break; - default: - $this->error(sprintf('Unsupported Filter: %s',$_filter[1])); - } - } - - return $stream; - } - - - /** - * Get a Box from a page - * Arrayformat is same as used by fpdf_tpl - * - * @param array $page a /Page - * @param string $box_index Type of Box @see $availableBoxes - * @param float Scale factor from user space units to points - * @return array - */ - function getPageBox($page, $box_index, $k) { - $page = $this->pdf_resolve_object($this->c, $page); - $box = null; - if (isset($page[1][1][$box_index])) - $box =& $page[1][1][$box_index]; - - if (!is_null($box) && $box[0] == PDF_TYPE_OBJREF) { - $tmp_box = $this->pdf_resolve_object($this->c, $box); - $box = $tmp_box[1]; - } - - if (!is_null($box) && $box[0] == PDF_TYPE_ARRAY) { - $b =& $box[1]; - return array('x' => $b[0][1] / $k, - 'y' => $b[1][1] / $k, - 'w' => abs($b[0][1] - $b[2][1]) / $k, - 'h' => abs($b[1][1] - $b[3][1]) / $k, - 'llx' => min($b[0][1], $b[2][1]) / $k, - 'lly' => min($b[1][1], $b[3][1]) / $k, - 'urx' => max($b[0][1], $b[2][1]) / $k, - 'ury' => max($b[1][1], $b[3][1]) / $k, - ); - } elseif (!isset ($page[1][1]['/Parent'])) { - return false; - } else { - return $this->getPageBox($this->pdf_resolve_object($this->c, $page[1][1]['/Parent']), $box_index, $k); - } - } - - /** - * Get all page boxes by page no - * - * @param int The page number - * @param float Scale factor from user space units to points - * @return array - */ - function getPageBoxes($pageno, $k) { - return $this->_getPageBoxes($this->pages[$pageno - 1], $k); - } - - /** - * Get all boxes from /Page - * - * @param array a /Page - * @return array - */ - function _getPageBoxes($page, $k) { - $boxes = array(); - - foreach($this->availableBoxes AS $box) { - if ($_box = $this->getPageBox($page, $box, $k)) { - $boxes[$box] = $_box; - } - } - - return $boxes; - } - - /** - * Get the page rotation by pageno - * - * @param integer $pageno - * @return array - */ - function getPageRotation($pageno) { - return $this->_getPageRotation($this->pages[$pageno - 1]); - } - - function _getPageRotation($obj) { // $obj = /Page - $obj = $this->pdf_resolve_object($this->c, $obj); - if (isset ($obj[1][1]['/Rotate'])) { - $res = $this->pdf_resolve_object($this->c, $obj[1][1]['/Rotate']); - if ($res[0] == PDF_TYPE_OBJECT) - return $res[1]; - return $res; - } else { - if (!isset ($obj[1][1]['/Parent'])) { - return false; - } else { - $res = $this->_getPageRotation($obj[1][1]['/Parent']); - if ($res[0] == PDF_TYPE_OBJECT) - return $res[1]; - return $res; - } - } - } - - /** - * Read all /Page(es) - * - * @param object pdf_context - * @param array /Pages - * @param array the result-array - */ - function read_pages(&$c, &$pages, &$result) { - // Get the kids dictionary - $_kids = $this->pdf_resolve_object ($c, $pages[1][1]['/Kids']); - - if (!is_array($_kids)) - $this->error('Cannot find /Kids in current /Page-Dictionary'); - - if ($_kids[1][0] == PDF_TYPE_ARRAY) { - $kids = $_kids[1][1]; - } else { - $kids = $_kids[1]; - } - - foreach ($kids as $v) { - $pg = $this->pdf_resolve_object ($c, $v); - if ($pg[1][1]['/Type'][1] === '/Pages') { - // If one of the kids is an embedded - // /Pages array, resolve it as well. - if ($pg !== $pages) { - $this->read_pages($c, $pg, $result); - } - } else { - $result[] = $pg; - } - } - } - - - - /** - * Get PDF-Version - * - * And reset the PDF Version used in FPDI if needed - */ - function getPDFVersion() { - parent::getPDFVersion(); - $this->fpdi->setPDFVersion(max($this->fpdi->getPDFVersion(), $this->pdfVersion)); - } -} diff --git a/mod/assign/feedback/editpdf/fpdi/pdf_context.php b/mod/assign/feedback/editpdf/fpdi/pdf_context.php deleted file mode 100644 index f404039..0000000 --- a/mod/assign/feedback/editpdf/fpdi/pdf_context.php +++ /dev/null @@ -1,104 +0,0 @@ -file =& $f; - if (is_string($this->file)) - $this->_mode = 1; - $this->reset(); - } - - // Optionally move the file - // pointer to a new location - // and reset the buffered data - - function reset($pos = null, $l = 100) { - if ($this->_mode == 0) { - if (!is_null ($pos)) { - fseek ($this->file, $pos); - } - - $this->buffer = $l > 0 ? fread($this->file, $l) : ''; - $this->length = strlen($this->buffer); - if ($this->length < $l) - $this->increase_length($l - $this->length); - } else { - $this->buffer = $this->file; - $this->length = strlen($this->buffer); - } - $this->offset = 0; - $this->stack = array(); - } - - // Make sure that there is at least one - // character beyond the current offset in - // the buffer to prevent the tokenizer - // from attempting to access data that does - // not exist - - function ensure_content() { - if ($this->offset >= $this->length - 1) { - return $this->increase_length(); - } else { - return true; - } - } - - // Forcefully read more data into the buffer - - function increase_length($l = 100) { - if ($this->_mode == 0 && feof($this->file)) { - return false; - } elseif ($this->_mode == 0) { - $totalLength = $this->length + $l; - do { - $toRead = $totalLength - $this->length; - if ($toRead < 1) - break; - - $this->buffer .= fread($this->file, $toRead); - } while ((($this->length = strlen($this->buffer)) != $totalLength) && !feof($this->file)); - - return true; - } else { - return false; - } - } - } -} \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/fpdi/pdf_parser.php b/mod/assign/feedback/editpdf/fpdi/pdf_parser.php deleted file mode 100644 index b1e7b8d..0000000 --- a/mod/assign/feedback/editpdf/fpdi/pdf_parser.php +++ /dev/null @@ -1,719 +0,0 @@ -filename = $filename; - - $this->f = @fopen($this->filename, 'rb'); - - if (!$this->f) - $this->error(sprintf('Cannot open %s !', $filename)); - - $this->getPDFVersion(); - - $this->c = new pdf_context($this->f); - - // Read xref-Data - $this->xref = array(); - $this->pdf_read_xref($this->xref, $this->pdf_find_xref()); - - // Check for Encryption - $this->getEncryption(); - - // Read root - $this->pdf_read_root(); - } - - /** - * Close the opened file - */ - function closeFile() { - if (isset($this->f) && is_resource($this->f)) { - fclose($this->f); - unset($this->f); - } - } - - /** - * Print Error and die - * - * @param string $msg Error-Message - */ - function error($msg) { - die('PDF-Parser Error: ' . $msg); - } - - /** - * Check Trailer for Encryption - */ - function getEncryption() { - if (isset($this->xref['trailer'][1]['/Encrypt'])) { - $this->error('File is encrypted!'); - } - } - - /** - * Find/Return /Root - * - * @return array - */ - function pdf_find_root() { - if ($this->xref['trailer'][1]['/Root'][0] != PDF_TYPE_OBJREF) { - $this->error('Wrong Type of Root-Element! Must be an indirect reference'); - } - - return $this->xref['trailer'][1]['/Root']; - } - - /** - * Read the /Root - */ - function pdf_read_root() { - // read root - $this->root = $this->pdf_resolve_object($this->c, $this->pdf_find_root()); - } - - /** - * Get PDF-Version - * - * And reset the PDF Version used in FPDI if needed - */ - function getPDFVersion() { - fseek($this->f, 0); - preg_match('/\d\.\d/',fread($this->f, 16), $m); - if (isset($m[0])) - $this->pdfVersion = $m[0]; - return $this->pdfVersion; - } - - /** - * Find the xref-Table - */ - function pdf_find_xref() { - $toRead = 1500; - - $stat = fseek ($this->f, -$toRead, SEEK_END); - if ($stat === -1) { - fseek ($this->f, 0); - } - $data = fread($this->f, $toRead); - - $pos = strlen($data) - strpos(strrev($data), strrev('startxref')); - $data = substr($data, $pos); - - if (!preg_match('/\s*(\d+).*$/s', $data, $matches)) { - $this->error('Unable to find pointer to xref table'); - } - - return (int) $matches[1]; - } - - /** - * Read xref-table - * - * @param array $result Array of xref-table - * @param integer $offset of xref-table - */ - function pdf_read_xref(&$result, $offset) { - $o_pos = $offset-min(20, $offset); - fseek($this->f, $o_pos); // set some bytes backwards to fetch errorious docs - - $data = fread($this->f, 100); - - $xrefPos = strrpos($data, 'xref'); - - if ($xrefPos === false) { - fseek($this->f, $offset); - $c = new pdf_context($this->f); - $xrefStreamObjDec = $this->pdf_read_value($c); - - if (is_array($xrefStreamObjDec) && isset($xrefStreamObjDec[0]) && $xrefStreamObjDec[0] == PDF_TYPE_OBJDEC) { - $this->error(sprintf('This document (%s) probably uses a compression technique which is not supported by the free parser shipped with FPDI.', $this->filename)); - } else { - $this->error('Unable to find xref table.'); - } - } - - if (!isset($result['xref_location'])) { - $result['xref_location'] = $o_pos + $xrefPos; - $result['max_object'] = 0; - } - - $cylces = -1; - $bytesPerCycle = 100; - - fseek($this->f, $o_pos = $o_pos + $xrefPos + 4); // set the handle directly after the "xref"-keyword - $data = fread($this->f, $bytesPerCycle); - - while (($trailerPos = strpos($data, 'trailer', max($bytesPerCycle * $cylces++, 0))) === false && !feof($this->f)) { - $data .= fread($this->f, $bytesPerCycle); - } - - if ($trailerPos === false) { - $this->error('Trailer keyword not found after xref table'); - } - - $data = substr($data, 0, $trailerPos); - - // get Line-Ending - preg_match_all("/(\r\n|\n|\r)/", substr($data, 0, 100), $m); // check the first 100 bytes for linebreaks - - $differentLineEndings = count(array_unique($m[0])); - if ($differentLineEndings > 1) { - $lines = preg_split("/(\r\n|\n|\r)/", $data, -1, PREG_SPLIT_NO_EMPTY); - } else { - $lines = explode($m[0][1], $data); - } - - $data = $differentLineEndings = $m = null; - unset($data, $differentLineEndings, $m); - - $linesCount = count($lines); - - $start = 1; - - for ($i = 0; $i < $linesCount; $i++) { - $line = trim($lines[$i]); - if ($line) { - $pieces = explode(' ', $line); - $c = count($pieces); - switch($c) { - case 2: - $start = (int)$pieces[0]; - $end = $start + (int)$pieces[1]; - if ($end > $result['max_object']) - $result['max_object'] = $end; - break; - case 3: - if (!isset($result['xref'][$start])) - $result['xref'][$start] = array(); - - if (!array_key_exists($gen = (int) $pieces[1], $result['xref'][$start])) { - $result['xref'][$start][$gen] = $pieces[2] == 'n' ? (int) $pieces[0] : null; - } - $start++; - break; - default: - $this->error('Unexpected data in xref table'); - } - } - } - - $lines = $pieces = $line = $start = $end = $gen = null; - unset($lines, $pieces, $line, $start, $end, $gen); - - fseek($this->f, $o_pos + $trailerPos + 7); - - $c = new pdf_context($this->f); - $trailer = $this->pdf_read_value($c); - - $c = null; - unset($c); - - if (!isset($result['trailer'])) { - $result['trailer'] = $trailer; - } - - if (isset($trailer[1]['/Prev'])) { - $this->pdf_read_xref($result, $trailer[1]['/Prev'][1]); - } - - $trailer = null; - unset($trailer); - - return true; - } - - /** - * Reads an Value - * - * @param object $c pdf_context - * @param string $token a Token - * @return mixed - */ - function pdf_read_value(&$c, $token = null) { - if (is_null($token)) { - $token = $this->pdf_read_token($c); - } - - if ($token === false) { - return false; - } - - switch ($token) { - case '<': - // This is a hex string. - // Read the value, then the terminator - - $pos = $c->offset; - - while(1) { - - $match = strpos ($c->buffer, '>', $pos); - - // If you can't find it, try - // reading more data from the stream - - if ($match === false) { - if (!$c->increase_length()) { - return false; - } else { - continue; - } - } - - $result = substr ($c->buffer, $c->offset, $match - $c->offset); - $c->offset = $match + 1; - - return array (PDF_TYPE_HEX, $result); - } - - break; - case '<<': - // This is a dictionary. - - $result = array(); - - // Recurse into this function until we reach - // the end of the dictionary. - while (($key = $this->pdf_read_token($c)) !== '>>') { - if ($key === false) { - return false; - } - - if (($value = $this->pdf_read_value($c)) === false) { - return false; - } - - // Catch missing value - if ($value[0] == PDF_TYPE_TOKEN && $value[1] == '>>') { - $result[$key] = array(PDF_TYPE_NULL); - break; - } - - $result[$key] = $value; - } - - return array (PDF_TYPE_DICTIONARY, $result); - - case '[': - // This is an array. - - $result = array(); - - // Recurse into this function until we reach - // the end of the array. - while (($token = $this->pdf_read_token($c)) !== ']') { - if ($token === false) { - return false; - } - - if (($value = $this->pdf_read_value($c, $token)) === false) { - return false; - } - - $result[] = $value; - } - - return array (PDF_TYPE_ARRAY, $result); - - case '(' : - // This is a string - $pos = $c->offset; - - $openBrackets = 1; - do { - for (; $openBrackets != 0 && $pos < $c->length; $pos++) { - switch (ord($c->buffer[$pos])) { - case 0x28: // '(' - $openBrackets++; - break; - case 0x29: // ')' - $openBrackets--; - break; - case 0x5C: // backslash - $pos++; - } - } - } while($openBrackets != 0 && $c->increase_length()); - - $result = substr($c->buffer, $c->offset, $pos - $c->offset - 1); - $c->offset = $pos; - - return array (PDF_TYPE_STRING, $result); - - case 'stream': - $o_pos = ftell($c->file)-strlen($c->buffer); - $o_offset = $c->offset; - - $c->reset($startpos = $o_pos + $o_offset); - - $e = 0; // ensure line breaks in front of the stream - if ($c->buffer[0] == chr(10) || $c->buffer[0] == chr(13)) - $e++; - if ($c->buffer[1] == chr(10) && $c->buffer[0] != chr(10)) - $e++; - - if ($this->actual_obj[1][1]['/Length'][0] == PDF_TYPE_OBJREF) { - $tmp_c = new pdf_context($this->f); - $tmp_length = $this->pdf_resolve_object($tmp_c, $this->actual_obj[1][1]['/Length']); - $length = $tmp_length[1][1]; - } else { - $length = $this->actual_obj[1][1]['/Length'][1]; - } - - if ($length > 0) { - $c->reset($startpos + $e,$length); - $v = $c->buffer; - } else { - $v = ''; - } - $c->reset($startpos + $e + $length + 9); // 9 = strlen("endstream") - - return array(PDF_TYPE_STREAM, $v); - - default : - if (is_numeric ($token)) { - // A numeric token. Make sure that - // it is not part of something else. - if (($tok2 = $this->pdf_read_token ($c)) !== false) { - if (is_numeric ($tok2)) { - - // Two numeric tokens in a row. - // In this case, we're probably in - // front of either an object reference - // or an object specification. - // Determine the case and return the data - if (($tok3 = $this->pdf_read_token ($c)) !== false) { - switch ($tok3) { - case 'obj': - return array (PDF_TYPE_OBJDEC, (int) $token, (int) $tok2); - case 'R': - return array (PDF_TYPE_OBJREF, (int) $token, (int) $tok2); - } - // If we get to this point, that numeric value up - // there was just a numeric value. Push the extra - // tokens back into the stack and return the value. - array_push ($c->stack, $tok3); - } - } - - array_push ($c->stack, $tok2); - } - - if ($token === (string)((int)$token)) - return array (PDF_TYPE_NUMERIC, (int)$token); - else - return array (PDF_TYPE_REAL, (float)$token); - } elseif ($token == 'true' || $token == 'false') { - return array (PDF_TYPE_BOOLEAN, $token == 'true'); - } elseif ($token == 'null') { - return array (PDF_TYPE_NULL); - } else { - // Just a token. Return it. - return array (PDF_TYPE_TOKEN, $token); - } - } - } - - /** - * Resolve an object - * - * @param object $c pdf_context - * @param array $obj_spec The object-data - * @param boolean $encapsulate Must set to true, cause the parsing and fpdi use this method only without this para - */ - function pdf_resolve_object(&$c, $obj_spec, $encapsulate = true) { - // Exit if we get invalid data - if (!is_array($obj_spec)) { - $ret = false; - return $ret; - } - - if ($obj_spec[0] == PDF_TYPE_OBJREF) { - - // This is a reference, resolve it - if (isset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]])) { - - // Save current file position - // This is needed if you want to resolve - // references while you're reading another object - // (e.g.: if you need to determine the length - // of a stream) - - $old_pos = ftell($c->file); - - // Reposition the file pointer and - // load the object header. - - $c->reset($this->xref['xref'][$obj_spec[1]][$obj_spec[2]]); - - $header = $this->pdf_read_value($c); - - if ($header[0] != PDF_TYPE_OBJDEC || $header[1] != $obj_spec[1] || $header[2] != $obj_spec[2]) { - $toSearchFor = $obj_spec[1] . ' ' . $obj_spec[2] . ' obj'; - if (preg_match('/' . $toSearchFor . '/', $c->buffer)) { - $c->offset = strpos($c->buffer, $toSearchFor) + strlen($toSearchFor); - // reset stack - $c->stack = array(); - } else { - $this->error("Unable to find object ({$obj_spec[1]}, {$obj_spec[2]}) at expected location"); - } - } - - // If we're being asked to store all the information - // about the object, we add the object ID and generation - // number for later use - $result = array(); - $this->actual_obj =& $result; - if ($encapsulate) { - $result = array ( - PDF_TYPE_OBJECT, - 'obj' => $obj_spec[1], - 'gen' => $obj_spec[2] - ); - } - - // Now simply read the object data until - // we encounter an end-of-object marker - while(1) { - $value = $this->pdf_read_value($c); - if ($value === false || count($result) > 4) { - // in this case the parser coudn't find an endobj so we break here - break; - } - - if ($value[0] == PDF_TYPE_TOKEN && $value[1] === 'endobj') { - break; - } - - $result[] = $value; - } - - $c->reset($old_pos); - - if (isset($result[2][0]) && $result[2][0] == PDF_TYPE_STREAM) { - $result[0] = PDF_TYPE_STREAM; - } - - return $result; - } - } else { - return $obj_spec; - } - } - - - - /** - * Reads a token from the file - * - * @param object $c pdf_context - * @return mixed - */ - function pdf_read_token(&$c) - { - // If there is a token available - // on the stack, pop it out and - // return it. - - if (count($c->stack)) { - return array_pop($c->stack); - } - - // Strip away any whitespace - - do { - if (!$c->ensure_content()) { - return false; - } - $c->offset += strspn($c->buffer, "\x20\x0A\x0C\x0D\x09\x00", $c->offset); - } while ($c->offset >= $c->length - 1); - - // Get the first character in the stream - - $char = $c->buffer[$c->offset++]; - - switch ($char) { - - case '[': - case ']': - case '(': - case ')': - - // This is either an array or literal string - // delimiter, Return it - - return $char; - - case '<': - case '>': - - // This could either be a hex string or - // dictionary delimiter. Determine the - // appropriate case and return the token - - if ($c->buffer[$c->offset] == $char) { - if (!$c->ensure_content()) { - return false; - } - $c->offset++; - return $char . $char; - } else { - return $char; - } - - case '%': - - // This is a comment - jump over it! - - $pos = $c->offset; - while(1) { - $match = preg_match("/(\r\n|\r|\n)/", $c->buffer, $m, PREG_OFFSET_CAPTURE, $pos); - if ($match === 0) { - if (!$c->increase_length()) { - return false; - } else { - continue; - } - } - - $c->offset = $m[0][1]+strlen($m[0][0]); - - return $this->pdf_read_token($c); - } - - default: - - // This is "another" type of token (probably - // a dictionary entry or a numeric value) - // Find the end and return it. - - if (!$c->ensure_content()) { - return false; - } - - while(1) { - - // Determine the length of the token - - $pos = strcspn($c->buffer, "\x20%[]<>()/\x0A\x0C\x0D\x09\x00", $c->offset); - - if ($c->offset + $pos <= $c->length - 1) { - break; - } else { - // If the script reaches this point, - // the token may span beyond the end - // of the current buffer. Therefore, - // we increase the size of the buffer - // and try again--just to be safe. - - $c->increase_length(); - } - } - - $result = substr($c->buffer, $c->offset - 1, $pos + 1); - - $c->offset += $pos; - return $result; - } - } - } -} diff --git a/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt b/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt deleted file mode 100644 index 93a9dee..0000000 --- a/mod/assign/feedback/editpdf/fpdi/readme_moodle.txt +++ /dev/null @@ -1,17 +0,0 @@ -FPDI -================================== - -No changes from the upstream version have been made. Both FPDI and FPDF_TPL have -been downloaded and unzipped to this directory. - -Information ------------ - -URL: http://www.setasign.de/products/pdf-php-solutions/fpdi/ -Download from: http://www.setasign.de/products/pdf-php-solutions/fpdi/downloads -Documentation: http://www.setasign.de/products/pdf-php-solutions/fpdi/manuals/ -License: Apache Software License 2.0 - -Downloaded versions: -FPDI: 1.4.4 -FPDF_TPL: 1.2.3 diff --git a/mod/assign/feedback/editpdf/lib.php b/mod/assign/feedback/editpdf/lib.php deleted file mode 100644 index 80f98e5..0000000 --- a/mod/assign/feedback/editpdf/lib.php +++ /dev/null @@ -1,78 +0,0 @@ -. - -/** - * This file contains the version information for the comments feedback plugin - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * Serves assignment feedback and other files. - * - * @param mixed $course course or id of the course - * @param mixed $cm course module or id of the course module - * @param context $context - * @param string $filearea - * @param array $args - * @param bool $forcedownload - * @return bool false if file not found, does not return if found - just send the file - */ -function assignfeedback_editpdf_pluginfile($course, - $cm, - context $context, - $filearea, - $args, - $forcedownload) { - global $USER, $DB, $CFG; - - if ($context->contextlevel == CONTEXT_MODULE) { - - require_login($course, false, $cm); - $itemid = (int)array_shift($args); - - if (!$assign = $DB->get_record('assign', array('id'=>$cm->instance))) { - return false; - } - - $record = $DB->get_record('assign_grades', array('id'=>$itemid), 'userid,assignment', MUST_EXIST); - $userid = $record->userid; - if ($assign->id != $record->assignment) { - return false; - } - - // Check is users feedback or has grading permission. - if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) { - return false; - } - - $relativepath = implode('/', $args); - - $fullpath = "/{$context->id}/assignfeedback_editpdf/$filearea/$itemid/$relativepath"; - - $fs = get_file_storage(); - if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { - return false; - } - // Download MUST be forced - security! - send_stored_file($file, 0, 0, true);// Check if we want to retrieve the stamps. - } - -} diff --git a/mod/assign/feedback/editpdf/locallib.php b/mod/assign/feedback/editpdf/locallib.php deleted file mode 100644 index 0bde754..0000000 --- a/mod/assign/feedback/editpdf/locallib.php +++ /dev/null @@ -1,297 +0,0 @@ -. - -/** - * This file contains the definition for the library class for PDF feedback plugin - * - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -use \assignfeedback_editpdf\document_services; -use \assignfeedback_editpdf\page_editor; - -/** - * library class for editpdf feedback plugin extending feedback plugin base class - * - * @package assignfeedback_editpdf - * @copyright 2012 Davo Smith - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class assign_feedback_editpdf extends assign_feedback_plugin { - - /** @var boolean|null $enabledcache Cached lookup of the is_enabled function */ - private $enabledcache = null; - - /** - * Get the name of the file feedback plugin - * @return string - */ - public function get_name() { - return get_string('pluginname', 'assignfeedback_editpdf'); - } - - /** - * Create a widget for rendering the editor. - * - * @param int $userid - * @param stdClass $grade - * @param bool $readonly - * @return assignfeedback_editpdf_widget - */ - public function get_widget($userid, $grade, $readonly) { - $attempt = -1; - if ($grade && $grade->attemptnumber) { - $attempt = $grade->attemptnumber; - } else { - $grade = $this->assignment->get_user_grade($userid, true); - } - - $feedbackfile = document_services::get_feedback_document($this->assignment->get_instance()->id, - $userid, - $attempt); - - $stampfiles = array(); - $fs = get_file_storage(); - $syscontext = context_system::instance(); - - // Copy any new stamps to this instance. - if ($files = $fs->get_area_files($syscontext->id, - 'assignfeedback_editpdf', - 'stamps', - 0, - "filename", - false)) { - foreach ($files as $file) { - $filename = $file->get_filename(); - if ($filename !== '.') { - - $existingfile = $fs->get_file($this->assignment->get_context()->id, - 'assignfeedback_editpdf', - 'stamps', - $grade->id, - '/', - $file->get_filename()); - if (!$existingfile) { - $newrecord = new stdClass(); - $newrecord->contextid = $this->assignment->get_context()->id; - $newrecord->itemid = $grade->id; - $fs->create_file_from_storedfile($newrecord, $file); - } - } - } - } - - // Now get the full list of stamp files for this instance. - if ($files = $fs->get_area_files($this->assignment->get_context()->id, - 'assignfeedback_editpdf', - 'stamps', - $grade->id, - "filename", - false)) { - foreach ($files as $file) { - $filename = $file->get_filename(); - if ($filename !== '.') { - $url = moodle_url::make_pluginfile_url($this->assignment->get_context()->id, - 'assignfeedback_editpdf', - 'stamps', - $grade->id, - '/', - $file->get_filename(), - false); - array_push($stampfiles, $url->out()); - } - } - } - - $url = false; - $filename = ''; - if ($feedbackfile) { - $url = moodle_url::make_pluginfile_url($this->assignment->get_context()->id, - 'assignfeedback_editpdf', - document_services::FINAL_PDF_FILEAREA, - $grade->id, - '/', - $feedbackfile->get_filename(), - false); - $filename = $feedbackfile->get_filename(); - } - - // Retrieve total number of pages. - $pagetotal = document_services::page_number_for_attempt($this->assignment->get_instance()->id, - $userid, - $attempt, - $readonly); - - $widget = new assignfeedback_editpdf_widget($this->assignment->get_instance()->id, - $userid, - $attempt, - $url, - $filename, - $stampfiles, - $readonly, - $pagetotal); - return $widget; - } - - /** - * Get form elements for grading form - * - * @param stdClass $grade - * @param MoodleQuickForm $mform - * @param stdClass $data - * @param int $userid - * @return bool true if elements were added to the form - */ - public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdClass $data, $userid) { - global $PAGE; - - $attempt = -1; - if ($grade) { - $attempt = $grade->attemptnumber; - } - - $files = document_services::list_compatible_submission_files_for_attempt($this->assignment, $userid, $attempt); - // Only show the editor if there was a compatible file submitted. - if (count($files)) { - - $renderer = $PAGE->get_renderer('assignfeedback_editpdf'); - - $widget = $this->get_widget($userid, $grade, false); - - $html = $renderer->render($widget); - $mform->addElement('static', 'editpdf', get_string('editpdf', 'assignfeedback_editpdf'), $html); - $mform->addHelpButton('editpdf', 'editpdf', 'assignfeedback_editpdf'); - $mform->addElement('hidden', 'editpdf_source_userid', $userid); - $mform->setType('editpdf_source_userid', PARAM_INT); - $mform->setConstant('editpdf_source_userid', $userid); - } - } - - /** - * Generate the pdf. - * - * @param stdClass $grade - * @param stdClass $data - * @return bool - */ - public function save(stdClass $grade, stdClass $data) { - // Source user id is only added to the form if there was a pdf. - if (!empty($data->editpdf_source_userid)) { - $sourceuserid = $data->editpdf_source_userid; - // Copy drafts annotations and comments if current user is different to sourceuserid. - if ($sourceuserid != $grade->userid) { - page_editor::copy_drafts_from_to($this->assignment, $grade, $sourceuserid); - } - } - if (page_editor::has_annotations_or_comments($grade->id, true)) { - document_services::generate_feedback_document($this->assignment, $grade->userid, $grade->attemptnumber); - } - - return true; - } - - /** - * Display the list of files in the feedback status table. - * - * @param stdClass $grade - * @param bool $showviewlink (Always set to false). - * @return string - */ - public function view_summary(stdClass $grade, & $showviewlink) { - $showviewlink = false; - return $this->view($grade); - } - - /** - * 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->assignment->render_area_files('assignfeedback_editpdf', - document_services::FINAL_PDF_FILEAREA, - $grade->id); - - // Also show the link to the read-only interface. - $renderer = $PAGE->get_renderer('assignfeedback_editpdf'); - $widget = $this->get_widget($grade->userid, $grade, true); - - $html .= $renderer->render($widget); - } - return $html; - } - - /** - * Return true if there are no released comments/annotations. - * - * @param stdClass $grade - */ - public function is_empty(stdClass $grade) { - global $DB; - - $comments = $DB->count_records('assignfeedback_editpdf_cmnt', array('gradeid'=>$grade->id, 'draft'=>0)); - $annotations = $DB->count_records('assignfeedback_editpdf_annot', array('gradeid'=>$grade->id, 'draft'=>0)); - return $comments == 0 && $annotations == 0; - } - - /** - * The assignment has been deleted - remove the plugin specific data - * - * @return bool - */ - public function delete_instance() { - global $DB; - $grades = $DB->get_records('assign_grades', array('assignment'=>$this->assignment->get_instance()->id), '', 'id'); - if ($grades) { - list($gradeids, $params) = $DB->get_in_or_equal(array_keys($grades), SQL_PARAMS_NAMED); - $DB->delete_records_select('assignfeedback_editpdf_annot', 'gradeid ' . $gradeids, $params); - $DB->delete_records_select('assignfeedback_editpdf_cmnt', 'gradeid ' . $gradeids, $params); - } - return true; - } - - /** - * Automatically enable or disable editpdf feedback plugin based on - * whether the ghostscript path is set correctly. - * - * @return bool - */ - public function is_enabled() { - if ($this->enabledcache === null) { - $testpath = assignfeedback_editpdf\pdf::test_gs_path(false); - $this->enabledcache = ($testpath->status == assignfeedback_editpdf\pdf::GSPATH_OK); - } - return $this->enabledcache; - } - /** - * Automatically hide the setting for the editpdf feedback plugin. - * - * @return bool false - */ - public function is_configurable() { - return false; - } -} diff --git a/mod/assign/feedback/editpdf/pix/background_colour_blue.png b/mod/assign/feedback/editpdf/pix/background_colour_blue.png deleted file mode 100644 index c233e18..0000000 Binary files a/mod/assign/feedback/editpdf/pix/background_colour_blue.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/background_colour_blue.svg b/mod/assign/feedback/editpdf/pix/background_colour_blue.svg deleted file mode 100644 index 032b557..0000000 --- a/mod/assign/feedback/editpdf/pix/background_colour_blue.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -image/svg+xml - - - - \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/pix/background_colour_clear.png b/mod/assign/feedback/editpdf/pix/background_colour_clear.png deleted file mode 100644 index 139d1c1..0000000 Binary files a/mod/assign/feedback/editpdf/pix/background_colour_clear.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/background_colour_clear.svg b/mod/assign/feedback/editpdf/pix/background_colour_clear.svg deleted file mode 100644 index 5c32932..0000000 --- a/mod/assign/feedback/editpdf/pix/background_colour_clear.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/background_colour_green.png b/mod/assign/feedback/editpdf/pix/background_colour_green.png deleted file mode 100644 index e47b064..0000000 Binary files a/mod/assign/feedback/editpdf/pix/background_colour_green.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/background_colour_green.svg b/mod/assign/feedback/editpdf/pix/background_colour_green.svg deleted file mode 100644 index 04e73d7..0000000 --- a/mod/assign/feedback/editpdf/pix/background_colour_green.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -image/svg+xml - - - - \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/pix/background_colour_red.png b/mod/assign/feedback/editpdf/pix/background_colour_red.png deleted file mode 100644 index bc6fdf8..0000000 Binary files a/mod/assign/feedback/editpdf/pix/background_colour_red.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/background_colour_red.svg b/mod/assign/feedback/editpdf/pix/background_colour_red.svg deleted file mode 100644 index 23f146c..0000000 --- a/mod/assign/feedback/editpdf/pix/background_colour_red.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -image/svg+xml - - - - \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/pix/background_colour_white.png b/mod/assign/feedback/editpdf/pix/background_colour_white.png deleted file mode 100644 index 0060462..0000000 Binary files a/mod/assign/feedback/editpdf/pix/background_colour_white.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/background_colour_white.svg b/mod/assign/feedback/editpdf/pix/background_colour_white.svg deleted file mode 100644 index 43a77c2..0000000 --- a/mod/assign/feedback/editpdf/pix/background_colour_white.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - -]> - - - - - - - - diff --git a/mod/assign/feedback/editpdf/pix/background_colour_yellow.png b/mod/assign/feedback/editpdf/pix/background_colour_yellow.png deleted file mode 100644 index 6fd29ed..0000000 Binary files a/mod/assign/feedback/editpdf/pix/background_colour_yellow.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/background_colour_yellow.svg b/mod/assign/feedback/editpdf/pix/background_colour_yellow.svg deleted file mode 100644 index 9fbecc0..0000000 --- a/mod/assign/feedback/editpdf/pix/background_colour_yellow.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -image/svg+xml - - - - \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/pix/colour_black.png b/mod/assign/feedback/editpdf/pix/colour_black.png deleted file mode 100644 index 156d9ca..0000000 Binary files a/mod/assign/feedback/editpdf/pix/colour_black.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/colour_black.svg b/mod/assign/feedback/editpdf/pix/colour_black.svg deleted file mode 100644 index a83eb2a..0000000 --- a/mod/assign/feedback/editpdf/pix/colour_black.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/colour_blue.png b/mod/assign/feedback/editpdf/pix/colour_blue.png deleted file mode 100644 index 64e9957..0000000 Binary files a/mod/assign/feedback/editpdf/pix/colour_blue.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/colour_blue.svg b/mod/assign/feedback/editpdf/pix/colour_blue.svg deleted file mode 100644 index 72e341d..0000000 --- a/mod/assign/feedback/editpdf/pix/colour_blue.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -image/svg+xml - - - - \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/pix/colour_green.png b/mod/assign/feedback/editpdf/pix/colour_green.png deleted file mode 100644 index 350829d..0000000 Binary files a/mod/assign/feedback/editpdf/pix/colour_green.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/colour_green.svg b/mod/assign/feedback/editpdf/pix/colour_green.svg deleted file mode 100644 index 0ff9f53..0000000 --- a/mod/assign/feedback/editpdf/pix/colour_green.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -image/svg+xml - - - - \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/pix/colour_red.png b/mod/assign/feedback/editpdf/pix/colour_red.png deleted file mode 100644 index f6aa1a4..0000000 Binary files a/mod/assign/feedback/editpdf/pix/colour_red.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/colour_red.svg b/mod/assign/feedback/editpdf/pix/colour_red.svg deleted file mode 100644 index d2576aa..0000000 --- a/mod/assign/feedback/editpdf/pix/colour_red.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -image/svg+xml - - - - \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/pix/colour_white.png b/mod/assign/feedback/editpdf/pix/colour_white.png deleted file mode 100644 index 03cd4d1..0000000 Binary files a/mod/assign/feedback/editpdf/pix/colour_white.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/colour_white.svg b/mod/assign/feedback/editpdf/pix/colour_white.svg deleted file mode 100644 index 2bdf8f6..0000000 --- a/mod/assign/feedback/editpdf/pix/colour_white.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - -]> - - - - - - diff --git a/mod/assign/feedback/editpdf/pix/colour_yellow.png b/mod/assign/feedback/editpdf/pix/colour_yellow.png deleted file mode 100644 index 9a1c349..0000000 Binary files a/mod/assign/feedback/editpdf/pix/colour_yellow.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/colour_yellow.svg b/mod/assign/feedback/editpdf/pix/colour_yellow.svg deleted file mode 100644 index a1486a8..0000000 --- a/mod/assign/feedback/editpdf/pix/colour_yellow.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -image/svg+xml - - - - \ No newline at end of file diff --git a/mod/assign/feedback/editpdf/pix/comment.png b/mod/assign/feedback/editpdf/pix/comment.png deleted file mode 100644 index 4836397..0000000 Binary files a/mod/assign/feedback/editpdf/pix/comment.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/comment.svg b/mod/assign/feedback/editpdf/pix/comment.svg deleted file mode 100644 index ce84664..0000000 --- a/mod/assign/feedback/editpdf/pix/comment.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/comment_search.png b/mod/assign/feedback/editpdf/pix/comment_search.png deleted file mode 100644 index d50342a..0000000 Binary files a/mod/assign/feedback/editpdf/pix/comment_search.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/comment_search.svg b/mod/assign/feedback/editpdf/pix/comment_search.svg deleted file mode 100644 index 5cde175..0000000 --- a/mod/assign/feedback/editpdf/pix/comment_search.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/cross.png b/mod/assign/feedback/editpdf/pix/cross.png deleted file mode 100644 index daf333d..0000000 Binary files a/mod/assign/feedback/editpdf/pix/cross.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/highlight.png b/mod/assign/feedback/editpdf/pix/highlight.png deleted file mode 100644 index 447957d..0000000 Binary files a/mod/assign/feedback/editpdf/pix/highlight.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/highlight.svg b/mod/assign/feedback/editpdf/pix/highlight.svg deleted file mode 100644 index 1f18f9e..0000000 --- a/mod/assign/feedback/editpdf/pix/highlight.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/line.png b/mod/assign/feedback/editpdf/pix/line.png deleted file mode 100644 index e8c6ec5..0000000 Binary files a/mod/assign/feedback/editpdf/pix/line.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/line.svg b/mod/assign/feedback/editpdf/pix/line.svg deleted file mode 100644 index b162dea..0000000 --- a/mod/assign/feedback/editpdf/pix/line.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/nav_next.png b/mod/assign/feedback/editpdf/pix/nav_next.png deleted file mode 100644 index 52058995..0000000 Binary files a/mod/assign/feedback/editpdf/pix/nav_next.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/nav_next.svg b/mod/assign/feedback/editpdf/pix/nav_next.svg deleted file mode 100644 index 7bceca8..0000000 --- a/mod/assign/feedback/editpdf/pix/nav_next.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/nav_prev.png b/mod/assign/feedback/editpdf/pix/nav_prev.png deleted file mode 100644 index 039e8a9..0000000 Binary files a/mod/assign/feedback/editpdf/pix/nav_prev.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/nav_prev.svg b/mod/assign/feedback/editpdf/pix/nav_prev.svg deleted file mode 100644 index d1a828b..0000000 --- a/mod/assign/feedback/editpdf/pix/nav_prev.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/oval.png b/mod/assign/feedback/editpdf/pix/oval.png deleted file mode 100644 index 4e87cb1..0000000 Binary files a/mod/assign/feedback/editpdf/pix/oval.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/oval.svg b/mod/assign/feedback/editpdf/pix/oval.svg deleted file mode 100644 index f6059c1..0000000 --- a/mod/assign/feedback/editpdf/pix/oval.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/pen.png b/mod/assign/feedback/editpdf/pix/pen.png deleted file mode 100644 index 85b3d6b..0000000 Binary files a/mod/assign/feedback/editpdf/pix/pen.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/pen.svg b/mod/assign/feedback/editpdf/pix/pen.svg deleted file mode 100644 index 77c11fc..0000000 --- a/mod/assign/feedback/editpdf/pix/pen.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/rectangle.png b/mod/assign/feedback/editpdf/pix/rectangle.png deleted file mode 100644 index d7e79c8..0000000 Binary files a/mod/assign/feedback/editpdf/pix/rectangle.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/rectangle.svg b/mod/assign/feedback/editpdf/pix/rectangle.svg deleted file mode 100644 index 0befc1c..0000000 --- a/mod/assign/feedback/editpdf/pix/rectangle.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/sad.png b/mod/assign/feedback/editpdf/pix/sad.png deleted file mode 100644 index e87bf42..0000000 Binary files a/mod/assign/feedback/editpdf/pix/sad.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/select.png b/mod/assign/feedback/editpdf/pix/select.png deleted file mode 100644 index e8d8e6a..0000000 Binary files a/mod/assign/feedback/editpdf/pix/select.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/select.svg b/mod/assign/feedback/editpdf/pix/select.svg deleted file mode 100644 index 7c8e459..0000000 --- a/mod/assign/feedback/editpdf/pix/select.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/smile.png b/mod/assign/feedback/editpdf/pix/smile.png deleted file mode 100644 index ec6d945..0000000 Binary files a/mod/assign/feedback/editpdf/pix/smile.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/stamp.png b/mod/assign/feedback/editpdf/pix/stamp.png deleted file mode 100644 index 371642b..0000000 Binary files a/mod/assign/feedback/editpdf/pix/stamp.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/stamp.svg b/mod/assign/feedback/editpdf/pix/stamp.svg deleted file mode 100644 index 4a0a8e4..0000000 --- a/mod/assign/feedback/editpdf/pix/stamp.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/pix/tick.png b/mod/assign/feedback/editpdf/pix/tick.png deleted file mode 100644 index a74ec2d..0000000 Binary files a/mod/assign/feedback/editpdf/pix/tick.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/trash.png b/mod/assign/feedback/editpdf/pix/trash.png deleted file mode 100644 index fc6aa0c..0000000 Binary files a/mod/assign/feedback/editpdf/pix/trash.png and /dev/null differ diff --git a/mod/assign/feedback/editpdf/pix/trash.svg b/mod/assign/feedback/editpdf/pix/trash.svg deleted file mode 100644 index a772952..0000000 --- a/mod/assign/feedback/editpdf/pix/trash.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - -]> - - - - - diff --git a/mod/assign/feedback/editpdf/styles.css b/mod/assign/feedback/editpdf/styles.css deleted file mode 100644 index d596434..0000000 --- a/mod/assign/feedback/editpdf/styles.css +++ /dev/null @@ -1,282 +0,0 @@ -.assignfeedback_editpdf_widget .toolbar ul { - display: none; -} - -.assignfeedback_editpdf_widget .toolbar li { - list-style-type: none; -} -.assignfeedback_editpdf_widget .drawingcanvas { - position: relative; - min-width: 817px; - min-height: 1169px; - cursor: crosshair; -} - -.assignfeedback_editpdf_widget { - user-select: none; - -moz-user-select: none; - -webkit-user-select: none; - -o-user-select: none; -} - -.assignfeedback_editpdf_widget .pageheader { - background-color: #ebebeb; - border-bottom: 1px solid #cccccc; - padding: 0px; - padding-left: 20px; - padding-right: 20px; - min-height: 50px; -} - -.moodle-dialogue-base .moodle-dialogue.assignfeedback_editpdf_widget .moodle-dialogue-bd { - padding: 0px; -} - -.assignfeedback_editpdf_unsavedchanges.haschanges{ - display: block; -} -.assignfeedback_editpdf_unsavedchanges { - display: none; - margin-top: 1em; -} -.yui3-colourpicker-hidden, -.yui3-commentsearch-hidden, -.yui3-commentmenu-hidden { - display: none; -} -.assignfeedback_editpdf_widget .pageheader button img { - padding-top: 3px; - vertical-align: top; -} -.assignfeedback_editpdf_widget .pageheader button:active { - background-color: #ccc; -} -.assignfeedback_editpdf_widget .pageheader select, -.assignfeedback_editpdf_widget .pageheader button { - background: none; - padding: 4px 7px; - border: 0px; - border-radius: 0px; - margin: 0px; - height: 30px; - line-height: 30px; - vertical-align: top; - cursor: pointer; -} -.assignfeedback_editpdf_widget .pageheader select { - vertical-align: top; - -webkit-appearance: none; - -moz-appearance: menulist-text; - background-color: #fff; - padding: 0px 10px; -} -.assignfeedback_editpdf_widget .pageheader select::-ms-expand { - display: none; -} - -.assignfeedback_editpdf_widget .pageheader .navigation button + button, -.assignfeedback_editpdf_widget .pageheader .toolbar button + button, -.assignfeedback_editpdf_widget .pageheader .navigation select + button, -.assignfeedback_editpdf_widget .pageheader .toolbar select + button { - border-left: 1px solid #cccccc; - border-right: 0px; -} - -.assignfeedback_editpdf_widget .pageheader .navigation button { - border-right: 1px solid #cccccc; -} -.assignfeedback_editpdf_widget .pageheader .toolbar, -.assignfeedback_editpdf_widget .pageheader .navigation-search, -.assignfeedback_editpdf_widget .pageheader .navigation { - border: 1px solid #cccccc; - border-bottom-color: #b3b3b3; - border-radius: 4px; - margin: 10px 4px; - background-color: white; - height: 30px; - line-height: 30px; - padding: 0px; -} - -.assignfeedback_editpdf_commentsearch ul { - max-height: 400px; - overflow-y: auto; - padding: 1em; -} -.assignfeedback_editpdf_commentsearch ul li pre { - background-color: #efefef; -} -.assignfeedback_editpdf_commentsearch ul li pre:hover { - background-color: #ddd; -} -.assignfeedback_editpdf_commentsearch ul li { - line-height: 0px; - margin: 2px; -} -.assignfeedback_editpdf_commentsearch a pre { - font-family: helvetica; - margin: 0px; - padding: 4px; -} - -.assignfeedback_editpdf_widget .navigation-search, -.assignfeedback_editpdf_widget .navigation { - float: left; -} - -.dir-rtl .assignfeedback_editpdf_widget .navigation-search, -.dir-rtl .assignfeedback_editpdf_widget .navigation { - float: right; -} -.assignfeedback_editpdf_widget .toolbar button { - box-shadow: none; - -moz-box-shadow: none; - -webkit-box-shadow: none; -} -.assignfeedback_editpdf_widget .toolbar { - float: right; -} -.dir-rtl .assignfeedback_editpdf_widget .toolbar { - float: left; -} -.assignfeedback_editpdf_widget .navigation, -.assignfeedback_editpdf_widget .navigation-search, -.assignfeedback_editpdf_widget .toolbar { - display: inline-block; -} - -.assignfeedback_editpdf_colourpicker ul { - margin: 0px; -} - -.assignfeedback_editpdf_commentmenu li.quicklist_comment { - width: 150px; -} -.assignfeedback_editpdf_commentmenu li.quicklist_comment a { - white-space: nowrap; - display: inline-block; - max-width: 130px; - overflow: hidden; - text-overflow: ellipsis; -} -.assignfeedback_editpdf_commentmenu a.delete_quicklist_comment { - float: right; -} -.dir-rtl .assignfeedback_editpdf_commentmenu a.delete_quicklist_comment { - float: left; -} -.assignfeedback_editpdf_dropdown button { - border: 0px; - background: none; - padding: 6px 7px; - border-radius: 0px; - border-top: 1px solid #cccccc; -} -.assignfeedback_editpdf_dropdown li:first-child button { - border-top: 0px; -} -.moodle-dialogue-base .moodle-dialogue.assignfeedback_editpdf_dropdown .moodle-dialogue-wrap { - box-shadow: none; - -moz-box-shadow: none; - -webkit-box-shadow: none; - margin-left: 0px; - margin-right: 0px; - margin-top: 0px; - border-radius: 4px; -} -.moodle-dialogue-base .moodle-dialogue.assignfeedback_editpdf_dropdown .moodle-dialogue-bd { - padding: 0px; -} -.assignfeedback_editpdf_dropdown .moodle-dialogue-hd, -.assignfeedback_editpdf_dropdown .moodle-dialogue-ft { - display: none; -} -.assignfeedback_editpdf_menu li hr { - margin: 0px; -} -.assignfeedback_editpdf_menu li a { - text-decoration: none; - color: #555; - margin: 10px; -} -.assignfeedback_editpdf_menu li:hover, -.assignfeedback_editpdf_menu li:hover a, -.assignfeedback_editpdf_menu li a:hover { - background-color: #ebebeb; - background-image: radial-gradient(ellipse at center, #ffffff 60%,#dfdfdf 100%); -} -ul.assignfeedback_editpdf_menu { - margin: 0px; -} -.assignfeedback_editpdf_menu li { - list-style-type: none; - margin: 0px; - border-radius: 4px; -} -.assignfeedback_editpdf_menu li img { - height: auto; -} -.assignfeedback_editpdf_menu li button { - margin: 0px; - background: none; -} - -.assignfeedback_editpdf_widget .pageheader button:hover { - background-color: #ebebeb; - background-image: radial-gradient(ellipse at center, #ffffff 60%,#dfdfdf 100%); -} - -.assignfeedback_editpdf_widget .pageheader button.assignfeedback_editpdf_selectedbutton:hover, -.assignfeedback_editpdf_widget .pageheader button.assignfeedback_editpdf_selectedbutton { - background-color: #dfdfdf; - background-image: radial-gradient(ellipse at center, #ffffff 40%,#dfdfdf 100%); -} - -.assignfeedback_editpdf_widget .commentdrawable img { - padding: 1px; -} - -.assignfeedback_editpdf_widget .commentdrawable a { - float: right; - position: relative; - left: -17px; - top: 2px; - height: 14px; - background-color: white; - border-left: 1px solid #ccc; - border-bottom: 1px solid #ccc; - line-height: 14px; -} - -.dir-rtl .assignfeedback_editpdf_widget .commentdrawable a { - float: left; - left: none; - right: -17px; - border-left: 0px; - border-right: 1px solid #ccc; -} - -.assignfeedback_editpdf_widget .commentdrawable textarea { - padding: 4px; - padding-right: 20px; - resize: none; - overflow: hidden; - color: black; - border: 2px solid #ccc; - border-radius: 4px; - font-size: 16px; - font-family: helvetica; - min-height: 1.2em; -} - -.assignfeedback_editpdf_widget .commentdrawable { - display: inline-block; -} - -.dir-rtl .assignfeedback_editpdf_widget .commentdrawable textarea { - padding-left: 20px; - padding-right: 4px; -} -.assignfeedback_editpdf_widget .drawingcanvas .loading .progressbarlabel { - text-align: center; -} diff --git a/mod/assign/feedback/editpdf/tests/behat/behat_assignfeedback_editpdf.php b/mod/assign/feedback/editpdf/tests/behat/behat_assignfeedback_editpdf.php deleted file mode 100644 index 41fab07..0000000 --- a/mod/assign/feedback/editpdf/tests/behat/behat_assignfeedback_editpdf.php +++ /dev/null @@ -1,54 +0,0 @@ -. - -/** - * Behat editpdf-related steps definitions. - * - * @package assignfeedback_editpdf - * @category test - * @copyright 2013 Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. - -require_once(__DIR__ . '/../../../../../../lib/behat/behat_base.php'); - -use Behat\Behat\Context\Step\Given as Given; - -/** - * Steps definitions related with the editpdf. - * - * @package assignfeedback_editpdf - * @category test - * @copyright 2013 Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class behat_assignfeedback_editpdf extends behat_base { - - /** - * Checks that Ghostscript is installed. - * - * @Given /^ghostscript is installed$/ - */ - public function ghostscript_is_installed() { - $testpath = assignfeedback_editpdf\pdf::test_gs_path(); - if (!extension_loaded('zlib') or - $testpath->status !== assignfeedback_editpdf\pdf::GSPATH_OK) { - throw new \Moodle\BehatExtension\Exception\SkippedException; - } - } -} diff --git a/mod/assign/feedback/editpdf/tests/fixtures/submission.pdf b/mod/assign/feedback/editpdf/tests/fixtures/submission.pdf deleted file mode 100644 index 576d378..0000000 Binary files a/mod/assign/feedback/editpdf/tests/fixtures/submission.pdf and /dev/null differ diff --git a/mod/assign/feedback/editpdf/tests/fixtures/testgs.pdf b/mod/assign/feedback/editpdf/tests/fixtures/testgs.pdf deleted file mode 100644 index f96796a..0000000 Binary files a/mod/assign/feedback/editpdf/tests/fixtures/testgs.pdf and /dev/null differ diff --git a/mod/assign/feedback/editpdf/thirdpartylibs.xml b/mod/assign/feedback/editpdf/thirdpartylibs.xml deleted file mode 100644 index fafb71c..0000000 --- a/mod/assign/feedback/editpdf/thirdpartylibs.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - fpdi - FPDI - Apache - 1.4.4 - 2.0 - - diff --git a/mod/assign/feedback/editpdf/yui/src/editor/build.json b/mod/assign/feedback/editpdf/yui/src/editor/build.json deleted file mode 100644 index d61260b..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/build.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "moodle-assignfeedback_editpdf-editor", - "builds": { - "moodle-assignfeedback_editpdf-editor": { - "jsfiles": [ - "globals.js", - "point.js", - "rect.js", - "edit.js", - "drawable.js", - "annotation.js", - "annotationline.js", - "annotationrectangle.js", - "annotationoval.js", - "annotationpen.js", - "annotationhighlight.js", - "annotationstamp.js", - "dropdown.js", - "colourpicker.js", - "stamppicker.js", - "commentmenu.js", - "commentsearch.js", - "comment.js", - "quickcomment.js", - "quickcommentlist.js", - "editor.js" - ] - } - } -} diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/annotation.js b/mod/assign/feedback/editpdf/yui/src/editor/js/annotation.js deleted file mode 100644 index ed05e28..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/js/annotation.js +++ /dev/null @@ -1,339 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Provides an in browser PDF editor. - * - * @module moodle-assignfeedback_editpdf-editor - */ - -/** - * Class representing a highlight. - * - * @namespace M.assignfeedback_editpdf - * @class annotation - * @constructor - */ -ANNOTATION = function(config) { - ANNOTATION.superclass.constructor.apply(this, [config]); -}; - -ANNOTATION.NAME = "annotation"; -ANNOTATION.ATTRS = {}; - -Y.extend(ANNOTATION, Y.Base, { - /** - * Reference to M.assignfeedback_editpdf.editor. - * @property editor - * @type M.assignfeedback_editpdf.editor - * @public - */ - editor : null, - - /** - * Grade id - * @property gradeid - * @type Int - * @public - */ - gradeid : 0, - - /** - * Comment page number - * @property pageno - * @type Int - * @public - */ - pageno : 0, - - /** - * X position - * @property x - * @type Int - * @public - */ - x : 0, - - /** - * Y position - * @property y - * @type Int - * @public - */ - y : 0, - - /** - * Ending x position - * @property endx - * @type Int - * @public - */ - endx : 0, - - /** - * Ending y position - * @property endy - * @type Int - * @public - */ - endy : 0, - - /** - * Path - * @property path - * @type String - list of points like x1,y1:x2,y2 - * @public - */ - path : '', - - /** - * Tool. - * @property type - * @type String - * @public - */ - type : 'rect', - - /** - * Annotation colour. - * @property colour - * @type String - * @public - */ - colour : 'red', - - /** - * Reference to M.assignfeedback_editpdf.drawable - * @property drawable - * @type M.assignfeedback_editpdf.drawable - * @public - */ - drawable : false, - - /** - * Initialise the annotation. - * - * @method initializer - * @return void - */ - initializer : function(config) { - this.editor = config.editor || null; - this.gradeid = parseInt(config.gradeid, 10) || 0; - this.pageno = parseInt(config.pageno, 10) || 0; - this.x = parseInt(config.x, 10) || 0; - this.y = parseInt(config.y, 10) || 0; - this.endx = parseInt(config.endx, 10) || 0; - this.endy = parseInt(config.endy, 10) || 0; - this.path = config.path || ''; - this.type = config.type || 'rect'; - this.colour = config.colour || 'red'; - this.drawable = false; - }, - - /** - * Clean a comment record, returning an oject with only fields that are valid. - * @public - * @method clean - * @return {} - */ - clean : function() { - return { - gradeid : this.gradeid, - x : parseInt(this.x, 10), - y : parseInt(this.y, 10), - endx : parseInt(this.endx, 10), - endy : parseInt(this.endy, 10), - type : this.type, - path : this.path, - pageno : this.pageno, - colour : this.colour - }; - }, - - /** - * Draw a selection around this annotation if it is selected. - * @public - * @method draw_highlight - * @return M.assignfeedback_editpdf.drawable - */ - draw_highlight : function() { - var bounds, - drawingregion = Y.one(SELECTOR.DRAWINGREGION), - offsetcanvas = Y.one(SELECTOR.DRAWINGCANVAS).getXY(), - shape; - - if (this.editor.currentannotation === this) { - // Draw a highlight around the annotation. - bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([new M.assignfeedback_editpdf.point(this.x, this.y), - new M.assignfeedback_editpdf.point(this.endx, this.endy)]); - - shape = this.editor.graphic.addShape({ - type: Y.Rect, - width: bounds.width, - height: bounds.height, - stroke: { - weight: STROKEWEIGHT, - color: SELECTEDBORDERCOLOUR - }, - fill: { - color: SELECTEDFILLCOLOUR - }, - x: bounds.x, - y: bounds.y - }); - this.drawable.shapes.push(shape); - - // Add a delete X to the annotation. - var deleteicon = Y.Node.create(''), - deletelink = Y.Node.create(''); - - deleteicon.setAttrs({ - 'alt': M.util.get_string('deleteannotation', 'assignfeedback_editpdf') - }); - deleteicon.setStyles({ - 'backgroundColor' : 'white' - }); - deletelink.addClass('deleteannotationbutton'); - deletelink.append(deleteicon); - - drawingregion.append(deletelink); - deletelink.setData('annotation', this); - deletelink.setStyle('zIndex', '200'); - - deletelink.on('click', this.remove, this); - deletelink.on('key', this.remove, 'space,enter', this); - - deletelink.setX(offsetcanvas[0] + bounds.x + bounds.width - 18); - deletelink.setY(offsetcanvas[1] + bounds.y + 6); - this.drawable.nodes.push(deletelink); - } - return this.drawable; - }, - - /** - * Draw an annotation - * @public - * @method draw - * @return M.assignfeedback_editpdf.drawable|false - */ - draw : function() { - // Should be overridden by the subclass. - this.draw_highlight(); - return this.drawable; - }, - - /** - * Delete an annotation - * @protected - * @method remove - * @param event - */ - remove : function(e) { - var annotations; - - e.preventDefault(); - - annotations = this.editor.pages[this.editor.currentpage].annotations; - for (i = 0; i < annotations.length; i++) { - if (annotations[i] === this) { - annotations.splice(i, 1); - if (this.drawable) { - this.drawable.erase(); - } - this.editor.currentannotation = false; - this.editor.save_current_page(); - return; - } - } - }, - - /** - * Move an annotation to a new location. - * @public - * @param int newx - * @param int newy - * @method move_annotation - */ - move : function(newx, newy) { - var diffx = newx - this.x, - diffy = newy - this.y, - newpath, oldpath, xy, - x, y; - - this.x += diffx; - this.y += diffy; - this.endx += diffx; - this.endy += diffy; - - if (this.path) { - newpath = []; - oldpath = this.path.split(':'); - Y.each(oldpath, function(position) { - xy = position.split(','); - x = parseInt(xy[0], 10); - y = parseInt(xy[1], 10); - newpath.push((x + diffx) + ',' + (y + diffy)); - }); - - this.path = newpath.join(':'); - - } - if (this.drawable) { - this.drawable.erase(); - } - this.editor.drawables.push(this.draw()); - }, - - /** - * Draw the in progress edit. - * - * @public - * @method draw_current_edit - * @param M.assignfeedback_editpdf.edit edit - */ - draw_current_edit : function(edit) { - var noop = edit && false; - // Override me please. - return noop; - }, - - /** - * Promote the current edit to a real annotation. - * - * @public - * @method init_from_edit - * @param M.assignfeedback_editpdf.edit edit - * @return bool if width/height is more than min. required. - */ - init_from_edit : function(edit) { - var bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([edit.start, edit.end]); - - this.gradeid = this.editor.get('gradeid'); - this.pageno = this.editor.currentpage; - this.x = bounds.x; - this.y = bounds.y; - this.endx = bounds.x + bounds.width; - this.endy = bounds.y + bounds.height; - this.colour = edit.annotationcolour; - this.path = ''; - return (bounds.has_min_width() && bounds.has_min_height()); - } - -}); - -M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; -M.assignfeedback_editpdf.annotation = ANNOTATION; diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationhighlight.js b/mod/assign/feedback/editpdf/yui/src/editor/js/annotationhighlight.js deleted file mode 100644 index 136d8cb..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationhighlight.js +++ /dev/null @@ -1,153 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Provides an in browser PDF editor. - * - * @module moodle-assignfeedback_editpdf-editor - */ - -/** - * Class representing a highlight. - * - * @namespace M.assignfeedback_editpdf - * @class annotationhighlight - * @extends M.assignfeedback_editpdf.annotation - * @module moodle-assignfeedback_editpdf-editor - */ -ANNOTATIONHIGHLIGHT = function(config) { - ANNOTATIONHIGHLIGHT.superclass.constructor.apply(this, [config]); -}; - -ANNOTATIONHIGHLIGHT.NAME = "annotationhighlight"; -ANNOTATIONHIGHLIGHT.ATTRS = {}; - -Y.extend(ANNOTATIONHIGHLIGHT, M.assignfeedback_editpdf.annotation, { - /** - * Draw a highlight annotation - * @protected - * @method draw - * @return M.assignfeedback_editpdf.drawable - */ - draw : function() { - var drawable, - shape, - bounds, - highlightcolour; - - drawable = new M.assignfeedback_editpdf.drawable(this.editor); - bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([new M.assignfeedback_editpdf.point(this.x, this.y), - new M.assignfeedback_editpdf.point(this.endx, this.endy)]); - - highlightcolour = ANNOTATIONCOLOUR[this.colour]; - - // Add an alpha channel to the rgb colour. - - highlightcolour = highlightcolour.replace('rgb', 'rgba'); - highlightcolour = highlightcolour.replace(')', ',0.5)'); - - shape = this.editor.graphic.addShape({ - type: Y.Rect, - width: bounds.width, - height: bounds.height, - stroke: false, - fill: { - color: highlightcolour - }, - x: bounds.x, - y: bounds.y - }); - - drawable.shapes.push(shape); - this.drawable = drawable; - - return ANNOTATIONHIGHLIGHT.superclass.draw.apply(this); - }, - - /** - * Draw the in progress edit. - * - * @public - * @method draw_current_edit - * @param M.assignfeedback_editpdf.edit edit - */ - draw_current_edit : function(edit) { - var drawable = new M.assignfeedback_editpdf.drawable(this.editor), - shape, - bounds, - highlightcolour; - - bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y), - new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]); - - // Set min. width of highlight. - if (!bounds.has_min_width()) { - bounds.set_min_width(); - } - - highlightcolour = ANNOTATIONCOLOUR[edit.annotationcolour]; - // Add an alpha channel to the rgb colour. - - highlightcolour = highlightcolour.replace('rgb', 'rgba'); - highlightcolour = highlightcolour.replace(')', ',0.5)'); - - // We will draw a box with the current background colour. - shape = this.editor.graphic.addShape({ - type: Y.Rect, - width: bounds.width, - height: 16, - stroke: false, - fill: { - color: highlightcolour - }, - x: bounds.x, - y: edit.start.y - }); - - drawable.shapes.push(shape); - - return drawable; - }, - - /** - * Promote the current edit to a real annotation. - * - * @public - * @method init_from_edit - * @param M.assignfeedback_editpdf.edit edit - * @return bool true if highlight bound is more than min width/height, else false. - */ - init_from_edit : function(edit) { - var bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([edit.start, edit.end]); - - this.gradeid = this.editor.get('gradeid'); - this.pageno = this.editor.currentpage; - this.x = bounds.x; - this.y = edit.start.y; - this.endx = bounds.x + bounds.width; - this.endy = edit.start.y + 16; - this.colour = edit.annotationcolour; - this.page = ''; - - return (bounds.has_min_width()); - } - -}); - -M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; -M.assignfeedback_editpdf.annotationhighlight = ANNOTATIONHIGHLIGHT; diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationline.js b/mod/assign/feedback/editpdf/yui/src/editor/js/annotationline.js deleted file mode 100644 index 6539040..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationline.js +++ /dev/null @@ -1,120 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Provides an in browser PDF editor. - * - * @module moodle-assignfeedback_editpdf-editor - */ - -/** - * Class representing a line. - * - * @namespace M.assignfeedback_editpdf - * @class annotationline - * @extends M.assignfeedback_editpdf.annotation - */ -ANNOTATIONLINE = function(config) { - ANNOTATIONLINE.superclass.constructor.apply(this, [config]); -}; - -ANNOTATIONLINE.NAME = "annotationline"; -ANNOTATIONLINE.ATTRS = {}; - -Y.extend(ANNOTATIONLINE, M.assignfeedback_editpdf.annotation, { - /** - * Draw a line annotation - * @protected - * @method draw - * @return M.assignfeedback_editpdf.drawable - */ - draw : function() { - var drawable, - shape; - - drawable = new M.assignfeedback_editpdf.drawable(this.editor); - - shape = this.editor.graphic.addShape({ - type: Y.Path, - fill: false, - stroke: { - weight: STROKEWEIGHT, - color: ANNOTATIONCOLOUR[this.colour] - } - }); - - shape.moveTo(this.x, this.y); - shape.lineTo(this.endx, this.endy); - shape.end(); - drawable.shapes.push(shape); - this.drawable = drawable; - - return ANNOTATIONLINE.superclass.draw.apply(this); - }, - - /** - * Draw the in progress edit. - * - * @public - * @method draw_current_edit - * @param M.assignfeedback_editpdf.edit edit - */ - draw_current_edit : function(edit) { - var drawable = new M.assignfeedback_editpdf.drawable(this.editor), - shape; - - shape = this.editor.graphic.addShape({ - type: Y.Path, - fill: false, - stroke: { - weight: STROKEWEIGHT, - color: ANNOTATIONCOLOUR[edit.annotationcolour] - } - }); - - shape.moveTo(edit.start.x, edit.start.y); - shape.lineTo(edit.end.x, edit.end.y); - shape.end(); - - drawable.shapes.push(shape); - - return drawable; - }, - - /** - * Promote the current edit to a real annotation. - * - * @public - * @method init_from_edit - * @param M.assignfeedback_editpdf.edit edit - * @return bool true if line bound is more than min width/height, else false. - */ - init_from_edit : function(edit) { - this.gradeid = this.editor.get('gradeid'); - this.pageno = this.editor.currentpage; - this.x = edit.start.x; - this.y = edit.start.y; - this.endx = edit.end.x; - this.endy = edit.end.y; - this.colour = edit.annotationcolour; - this.path = ''; - - return !(((this.endx - this.x) === 0) && ((this.endy - this.y) === 0)); - } - -}); - -M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; -M.assignfeedback_editpdf.annotationline = ANNOTATIONLINE; diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationoval.js b/mod/assign/feedback/editpdf/yui/src/editor/js/annotationoval.js deleted file mode 100644 index 8c39409..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationoval.js +++ /dev/null @@ -1,113 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Provides an in browser PDF editor. - * - * @module moodle-assignfeedback_editpdf-editor - */ - -/** - * Class representing a oval. - * - * @namespace M.assignfeedback_editpdf - * @class annotationoval - * @extends M.assignfeedback_editpdf.annotation - */ -ANNOTATIONOVAL = function(config) { - ANNOTATIONOVAL.superclass.constructor.apply(this, [config]); -}; - -ANNOTATIONOVAL.NAME = "annotationoval"; -ANNOTATIONOVAL.ATTRS = {}; - -Y.extend(ANNOTATIONOVAL, M.assignfeedback_editpdf.annotation, { - /** - * Draw a oval annotation - * @protected - * @method draw - * @return M.assignfeedback_editpdf.drawable - */ - draw : function() { - var drawable, - shape; - - drawable = new M.assignfeedback_editpdf.drawable(this.editor); - - bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([new M.assignfeedback_editpdf.point(this.x, this.y), - new M.assignfeedback_editpdf.point(this.endx, this.endy)]); - - shape = this.editor.graphic.addShape({ - type: Y.Ellipse, - width: bounds.width, - height: bounds.height, - stroke: { - weight: STROKEWEIGHT, - color: ANNOTATIONCOLOUR[this.colour] - }, - x: bounds.x, - y: bounds.y - }); - drawable.shapes.push(shape); - this.drawable = drawable; - - return ANNOTATIONOVAL.superclass.draw.apply(this); - }, - - /** - * Draw the in progress edit. - * - * @public - * @method draw_current_edit - * @param M.assignfeedback_editpdf.edit edit - */ - draw_current_edit : function(edit) { - var drawable = new M.assignfeedback_editpdf.drawable(this.editor), - shape, - bounds; - - bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y), - new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]); - - // Set min. width and height of oval. - if (!bounds.has_min_width()) { - bounds.set_min_width(); - } - if (!bounds.has_min_height()) { - bounds.set_min_height(); - } - - shape = this.editor.graphic.addShape({ - type: Y.Ellipse, - width: bounds.width, - height: bounds.height, - stroke: { - weight: STROKEWEIGHT, - color: ANNOTATIONCOLOUR[edit.annotationcolour] - }, - x: bounds.x, - y: bounds.y - }); - - drawable.shapes.push(shape); - - return drawable; - } -}); - -M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; -M.assignfeedback_editpdf.annotationoval = ANNOTATIONOVAL; diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationpen.js b/mod/assign/feedback/editpdf/yui/src/editor/js/annotationpen.js deleted file mode 100644 index 96aa832..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationpen.js +++ /dev/null @@ -1,160 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Provides an in browser PDF editor. - * - * @module moodle-assignfeedback_editpdf-editor - */ - -/** - * Class representing a pen. - * - * @namespace M.assignfeedback_editpdf - * @class annotationpen - * @extends M.assignfeedback_editpdf.annotation - */ -ANNOTATIONPEN = function(config) { - ANNOTATIONPEN.superclass.constructor.apply(this, [config]); -}; - -ANNOTATIONPEN.NAME = "annotationpen"; -ANNOTATIONPEN.ATTRS = {}; - -Y.extend(ANNOTATIONPEN, M.assignfeedback_editpdf.annotation, { - /** - * Draw a pen annotation - * @protected - * @method draw - * @return M.assignfeedback_editpdf.drawable - */ - draw : function() { - var drawable, - shape, - first, - positions, - xy; - - drawable = new M.assignfeedback_editpdf.drawable(this.editor); - - shape = this.editor.graphic.addShape({ - type: Y.Path, - fill: false, - stroke: { - weight: STROKEWEIGHT, - color: ANNOTATIONCOLOUR[this.colour] - } - }); - - first = true; - // Recreate the pen path array. - positions = this.path.split(':'); - // Redraw all the lines. - Y.each(positions, function(position) { - xy = position.split(','); - if (first) { - shape.moveTo(xy[0], xy[1]); - first = false; - } else { - shape.lineTo(xy[0], xy[1]); - } - }, this); - - shape.end(); - - drawable.shapes.push(shape); - this.drawable = drawable; - - return ANNOTATIONPEN.superclass.draw.apply(this); - }, - - /** - * Draw the in progress edit. - * - * @public - * @method draw_current_edit - * @param M.assignfeedback_editpdf.edit edit - */ - draw_current_edit : function(edit) { - var drawable = new M.assignfeedback_editpdf.drawable(this.editor), - shape, - first; - - shape = this.editor.graphic.addShape({ - type: Y.Path, - fill: false, - stroke: { - weight: STROKEWEIGHT, - color: ANNOTATIONCOLOUR[edit.annotationcolour] - } - }); - - first = true; - // Recreate the pen path array. - // Redraw all the lines. - Y.each(edit.path, function(position) { - if (first) { - shape.moveTo(position.x, position.y); - first = false; - } else { - shape.lineTo(position.x, position.y); - } - }, this); - - shape.end(); - - drawable.shapes.push(shape); - - return drawable; - }, - - - /** - * Promote the current edit to a real annotation. - * - * @public - * @method init_from_edit - * @param M.assignfeedback_editpdf.edit edit - * @return bool true if pen bound is more than min width/height, else false. - */ - init_from_edit : function(edit) { - var bounds = new M.assignfeedback_editpdf.rect(), - pathlist = [], - i = 0; - - // This will get the boundaries of all points in the path. - bounds.bound(edit.path); - - for (i = 0; i < edit.path.length; i++) { - pathlist.push(parseInt(edit.path[i].x, 10) + ',' + parseInt(edit.path[i].y, 10)); - } - - this.gradeid = this.editor.get('gradeid'); - this.pageno = this.editor.currentpage; - this.x = bounds.x; - this.y = bounds.y; - this.endx = bounds.x + bounds.width; - this.endy = bounds.y + bounds.height; - this.colour = edit.annotationcolour; - this.path = pathlist.join(':'); - - return (bounds.has_min_width() || bounds.has_min_height()); - } - - -}); - -M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; -M.assignfeedback_editpdf.annotationpen = ANNOTATIONPEN; diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationrectangle.js b/mod/assign/feedback/editpdf/yui/src/editor/js/annotationrectangle.js deleted file mode 100644 index c732014..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationrectangle.js +++ /dev/null @@ -1,113 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Provides an in browser PDF editor. - * - * @module moodle-assignfeedback_editpdf-editor - */ - -/** - * Class representing a rectangle. - * - * @namespace M.assignfeedback_editpdf - * @class annotationrectangle - * @extends M.assignfeedback_editpdf.annotation - */ -ANNOTATIONRECTANGLE = function(config) { - ANNOTATIONRECTANGLE.superclass.constructor.apply(this, [config]); -}; - -ANNOTATIONRECTANGLE.NAME = "annotationrectangle"; -ANNOTATIONRECTANGLE.ATTRS = {}; - -Y.extend(ANNOTATIONRECTANGLE, M.assignfeedback_editpdf.annotation, { - /** - * Draw a rectangle annotation - * @protected - * @method draw - * @return M.assignfeedback_editpdf.drawable - */ - draw : function() { - var drawable, - shape; - - drawable = new M.assignfeedback_editpdf.drawable(this.editor); - - bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([new M.assignfeedback_editpdf.point(this.x, this.y), - new M.assignfeedback_editpdf.point(this.endx, this.endy)]); - - shape = this.editor.graphic.addShape({ - type: Y.Rect, - width: bounds.width, - height: bounds.height, - stroke: { - weight: STROKEWEIGHT, - color: ANNOTATIONCOLOUR[this.colour] - }, - x: bounds.x, - y: bounds.y - }); - drawable.shapes.push(shape); - this.drawable = drawable; - - return ANNOTATIONRECTANGLE.superclass.draw.apply(this); - }, - - /** - * Draw the in progress edit. - * - * @public - * @method draw_current_edit - * @param M.assignfeedback_editpdf.edit edit - */ - draw_current_edit : function(edit) { - var drawable = new M.assignfeedback_editpdf.drawable(this.editor), - shape, - bounds; - - bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([new M.assignfeedback_editpdf.point(edit.start.x, edit.start.y), - new M.assignfeedback_editpdf.point(edit.end.x, edit.end.y)]); - - // Set min. width and height of rectangle. - if (!bounds.has_min_width()) { - bounds.set_min_width(); - } - if (!bounds.has_min_height()) { - bounds.set_min_height(); - } - - shape = this.editor.graphic.addShape({ - type: Y.Rect, - width: bounds.width, - height: bounds.height, - stroke: { - weight: STROKEWEIGHT, - color: ANNOTATIONCOLOUR[edit.annotationcolour] - }, - x: bounds.x, - y: bounds.y - }); - - drawable.shapes.push(shape); - - return drawable; - } -}); - -M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; -M.assignfeedback_editpdf.annotationrectangle = ANNOTATIONRECTANGLE; diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationstamp.js b/mod/assign/feedback/editpdf/yui/src/editor/js/annotationstamp.js deleted file mode 100644 index 71db2f6..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/js/annotationstamp.js +++ /dev/null @@ -1,169 +0,0 @@ -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see . - -/** - * Provides an in browser PDF editor. - * - * @module moodle-assignfeedback_editpdf-editor - */ - -/** - * Class representing a stamp. - * - * @namespace M.assignfeedback_editpdf - * @class annotationstamp - * @extends M.assignfeedback_editpdf.annotation - */ -ANNOTATIONSTAMP = function(config) { - ANNOTATIONSTAMP.superclass.constructor.apply(this, [config]); -}; - -ANNOTATIONSTAMP.NAME = "annotationstamp"; -ANNOTATIONSTAMP.ATTRS = {}; - -Y.extend(ANNOTATIONSTAMP, M.assignfeedback_editpdf.annotation, { - /** - * Draw a stamp annotation - * @protected - * @method draw - * @return M.assignfeedback_editpdf.drawable - */ - draw : function() { - var drawable = new M.assignfeedback_editpdf.drawable(this.editor), - drawingregion = Y.one(SELECTOR.DRAWINGREGION), - node, - position; - - position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(this.x, this.y)); - node = Y.Node.create('
'); - node.setStyles({ - 'position': 'absolute', - 'display': 'inline-block', - 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(this.path) + ')', - 'width': (this.endx - this.x), - 'height': (this.endy - this.y), - 'backgroundSize': '100% 100%', - 'zIndex': 50 - }); - - drawingregion.append(node); - node.setX(position.x); - node.setY(position.y); - - // Pass throught the event handlers on the div. - node.on('gesturemovestart', this.editor.edit_start, null, this.editor); - node.on('gesturemove', this.editor.edit_move, null, this.editor); - node.on('gesturemoveend', this.editor.edit_end, null, this.editor); - - drawable.nodes.push(node); - - this.drawable = drawable; - return ANNOTATIONSTAMP.superclass.draw.apply(this); - }, - - /** - * Draw the in progress edit. - * - * @public - * @method draw_current_edit - * @param M.assignfeedback_editpdf.edit edit - */ - draw_current_edit : function(edit) { - var bounds = new M.assignfeedback_editpdf.rect(), - drawable = new M.assignfeedback_editpdf.drawable(this.editor), - drawingregion = Y.one(SELECTOR.DRAWINGREGION), - node, - position; - - bounds.bound([edit.start, edit.end]); - position = this.editor.get_window_coordinates(new M.assignfeedback_editpdf.point(bounds.x, bounds.y)); - - node = Y.Node.create('
'); - node.setStyles({ - 'position': 'absolute', - 'display': 'inline-block', - 'backgroundImage': 'url(' + this.editor.get_stamp_image_url(edit.stamp) + ')', - 'width': bounds.width, - 'height': bounds.height, - 'backgroundSize': '100% 100%', - 'zIndex': 50 - }); - - drawingregion.append(node); - node.setX(position.x); - node.setY(position.y); - - drawable.nodes.push(node); - - return drawable; - }, - - /** - * Promote the current edit to a real annotation. - * - * @public - * @method init_from_edit - * @param M.assignfeedback_editpdf.edit edit - * @return bool if width/height is more than min. required. - */ - init_from_edit : function(edit) { - var bounds = new M.assignfeedback_editpdf.rect(); - bounds.bound([edit.start, edit.end]); - - if (bounds.width < 40) { - bounds.width = 40; - } - if (bounds.height < 40) { - bounds.height = 40; - } - this.gradeid = this.editor.get('gradeid'); - this.pageno = this.editor.currentpage; - this.x = bounds.x; - this.y = bounds.y; - this.endx = bounds.x + bounds.width; - this.endy = bounds.y + bounds.height; - this.colour = edit.annotationcolour; - this.path = edit.stamp; - - // Min width and height is always more than 40px. - return true; - }, - - /** - * Move an annotation to a new location. - * @public - * @param int newx - * @param int newy - * @method move_annotation - */ - move : function(newx, newy) { - var diffx = newx - this.x, - diffy = newy - this.y; - - this.x += diffx; - this.y += diffy; - this.endx += diffx; - this.endy += diffy; - - if (this.drawable) { - this.drawable.erase(); - } - this.editor.drawables.push(this.draw()); - } - -}); - -M.assignfeedback_editpdf = M.assignfeedback_editpdf || {}; -M.assignfeedback_editpdf.annotationstamp = ANNOTATIONSTAMP; diff --git a/mod/assign/feedback/editpdf/yui/src/editor/js/colourpicker.js b/mod/assign/feedback/editpdf/yui/src/editor/js/colourpicker.js deleted file mode 100644 index 919ac88..0000000 --- a/mod/assign/feedback/editpdf/yui/src/editor/js/colourpicker.js +++ /dev/null @@ -1,130 +0,0 @@ -var COLOURPICKER_NAME = "Colourpicker", - COLOURPICKER; - -/** - * Provides an in browser PDF editor. - * - * @module moodle-assignfeedback_editpdf-editor - */ - -/** - * COLOURPICKER - * This is a drop down list of colours. - * - * @namespace M.assignfeedback_editpdf - * @class colourpicker - * @constructor - * @extends M.assignfeedback_editpdf.dropdown - */ -COLOURPICKER = function(config) { - COLOURPICKER.superclass.constructor.apply(this, [config]); -}; - -Y.extend(COLOURPICKER, M.assignfeedback_editpdf.dropdown, { - - /** - * Initialise the menu. - * - * @method initializer - * @return void - */ - initializer : function(config) { - var colourlist = Y.Node.create('