mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
MDL-52954 assign: Rebuild the assignment single grade page.
This commit is contained in:
parent
2a3647bae5
commit
bb690849c9
86 changed files with 4593 additions and 279 deletions
66
mod/assign/feedback/editpdf/classes/event/observer.php
Normal file
66
mod/assign/feedback/editpdf/classes/event/observer.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* An event observer.
|
||||
*
|
||||
* @package assignfeedback_editpdf
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace assignfeedback_editpdf\event;
|
||||
|
||||
/**
|
||||
* Simple task to run the grade cron.
|
||||
*/
|
||||
class observer {
|
||||
|
||||
/**
|
||||
* Listen to events and queue the submission for processing.
|
||||
* @param \mod_assign\event\submission_created $event
|
||||
*/
|
||||
public static function submission_created(\mod_assign\event\submission_created $event) {
|
||||
global $DB;
|
||||
|
||||
$submissionid = $event->other['submissionid'];
|
||||
$submissionattempt = $event->other['submissionattempt'];
|
||||
$fields = array( 'submissionid' => $submissionid, 'submissionattempt' => $submissionattempt);
|
||||
$record = (object) $fields;
|
||||
|
||||
$exists = $DB->get_records('assignfeedback_editpdf_queue', $fields);
|
||||
if (!$exists) {
|
||||
$DB->insert_record('assignfeedback_editpdf_queue', $record);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen to events and queue the submission for processing.
|
||||
* @param \mod_assign\event\submission_updated $event
|
||||
*/
|
||||
public static function submission_updated(\mod_assign\event\submission_updated $event) {
|
||||
global $DB;
|
||||
|
||||
$submissionid = $event->other['submissionid'];
|
||||
$submissionattempt = $event->other['submissionattempt'];
|
||||
$fields = array( 'submissionid' => $submissionid, 'submissionattempt' => $submissionattempt);
|
||||
$record = (object) $fields;
|
||||
|
||||
$exists = $DB->get_records('assignfeedback_editpdf_queue', $fields);
|
||||
if (!$exists) {
|
||||
$DB->insert_record('assignfeedback_editpdf_queue', $record);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -118,10 +118,7 @@ class assignfeedback_editpdf_renderer extends plugin_renderer_base {
|
|||
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 .= '<input type="hidden" name="assignfeedback_editpdf_haschanges" value="false"/>';
|
||||
|
||||
$html .= html_writer::div($links, 'visibleifjs');
|
||||
$header = get_string('pluginname', 'assignfeedback_editpdf');
|
||||
|
@ -129,6 +126,7 @@ class assignfeedback_editpdf_renderer extends plugin_renderer_base {
|
|||
// Create the page navigation.
|
||||
$navigation1 = '';
|
||||
$navigation2 = '';
|
||||
$navigation3 = '';
|
||||
|
||||
// Pick the correct arrow icons for right to left mode.
|
||||
if (right_to_left()) {
|
||||
|
@ -156,6 +154,7 @@ class assignfeedback_editpdf_renderer extends plugin_renderer_base {
|
|||
$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 = '';
|
||||
|
@ -210,7 +209,14 @@ class assignfeedback_editpdf_renderer extends plugin_renderer_base {
|
|||
|
||||
$canvas = html_writer::div($loading, 'drawingcanvas');
|
||||
$canvas = html_writer::div($canvas, 'drawingregion');
|
||||
$body .= html_writer::div($canvas, 'hideoverflow');
|
||||
$changesmessage = html_writer::tag('div',
|
||||
get_string('draftchangessaved', 'assignfeedback_editpdf'),
|
||||
array('class'=>'assignfeedback_editpdf_unsavedchanges warning label label-info'));
|
||||
|
||||
$changesmessage = html_writer::div($changesmessage, 'unsaved-changes');
|
||||
$canvas .= $changesmessage;
|
||||
|
||||
$body .= $canvas;
|
||||
|
||||
$footer = '';
|
||||
|
||||
|
|
107
mod/assign/feedback/editpdf/classes/task/convert_submissions.php
Normal file
107
mod/assign/feedback/editpdf/classes/task/convert_submissions.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* A scheduled task.
|
||||
*
|
||||
* @package assignfeedback_editpdf
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace assignfeedback_editpdf\task;
|
||||
|
||||
use core\task\scheduled_task;
|
||||
use assignfeedback_editpdf\document_services;
|
||||
use context_module;
|
||||
use assign;
|
||||
|
||||
/**
|
||||
* Simple task to run the grade cron.
|
||||
*/
|
||||
class convert_submissions extends scheduled_task {
|
||||
|
||||
/**
|
||||
* Get a descriptive name for this task (shown to admins).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_name() {
|
||||
return get_string('preparesubmissionsforannotation', 'assignfeedback_editpdf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the job.
|
||||
* Throw exceptions on errors (the job will be retried).
|
||||
*/
|
||||
public function execute() {
|
||||
global $CFG, $DB;
|
||||
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
|
||||
$records = $DB->get_records('assignfeedback_editpdf_queue');
|
||||
|
||||
$assignmentcache = array();
|
||||
|
||||
foreach ($records as $record) {
|
||||
$submissionid = $record->submissionid;
|
||||
$submission = $DB->get_record('assign_submission', array('id' => $submissionid), '*', IGNORE_MISSING);
|
||||
if (!$submission) {
|
||||
// Submission no longer exists.
|
||||
$DB->delete_records('assignfeedback_editpdf_queue', array('id' => $record->id));
|
||||
continue;
|
||||
}
|
||||
|
||||
$assignmentid = $submission->assignment;
|
||||
$attemptnumber = $record->submissionattempt;
|
||||
|
||||
if (empty($assignmentcache[$assignmentid])) {
|
||||
$cm = get_coursemodule_from_instance('assign', $assignmentid, 0, false, MUST_EXIST);
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
$assignment = new assign($context, null, null);
|
||||
$assignmentcache[$assignmentid] = $assignment;
|
||||
} else {
|
||||
$assignment = $assignmentcache[$assignmentid];
|
||||
}
|
||||
|
||||
$users = array();
|
||||
if ($submission->userid) {
|
||||
array_push($users, $submission->userid);
|
||||
} else {
|
||||
$members = $assignment->get_submission_group_members($submission->groupid, true);
|
||||
|
||||
foreach ($members as $memberid) {
|
||||
array_push($users, $memberid);
|
||||
}
|
||||
}
|
||||
|
||||
mtrace('Convert ' . count($users) . ' submission attempt(s) for assignment ' . $assignmentid);
|
||||
foreach ($users as $userid) {
|
||||
document_services::get_page_images_for_attempt($assignment,
|
||||
$userid,
|
||||
$attemptnumber,
|
||||
true);
|
||||
document_services::get_page_images_for_attempt($assignment,
|
||||
$userid,
|
||||
$attemptnumber,
|
||||
false);
|
||||
}
|
||||
|
||||
$DB->delete_records('assignfeedback_editpdf_queue', array('id' => $record->id));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
36
mod/assign/feedback/editpdf/db/events.php
Normal file
36
mod/assign/feedback/editpdf/db/events.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* EditPDF event handler definition.
|
||||
*
|
||||
* @package assignfeedback_editpdf
|
||||
* @category event
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// List of observers.
|
||||
$observers = array(
|
||||
array(
|
||||
'eventname' => '\mod_assign\event\submission_created',
|
||||
'callback' => '\assignfeedback_editpdf\event\observer::submission_created',
|
||||
),
|
||||
array(
|
||||
'eventname' => '\mod_assign\event\submission_updated',
|
||||
'callback' => '\assignfeedback_editpdf\event\observer::submission_updated',
|
||||
),
|
||||
);
|
14
mod/assign/feedback/editpdf/db/install.xml
Normal file → Executable file
14
mod/assign/feedback/editpdf/db/install.xml
Normal file → Executable file
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/assign/feedback/editpdf/db" VERSION="20130926" COMMENT="XMLDB file for Moodle mod/assign/feedback/editpdf"
|
||||
<XMLDB PATH="mod/assign/feedback/editpdf/db" VERSION="20160216" COMMENT="XMLDB file for Moodle mod/assign/feedback/editpdf"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
|
@ -59,5 +59,15 @@
|
|||
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="assignfeedback_editpdf_queue" COMMENT="Queue for processing.">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
|
||||
<FIELD NAME="submissionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="submissionattempt" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
44
mod/assign/feedback/editpdf/db/tasks.php
Normal file
44
mod/assign/feedback/editpdf/db/tasks.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Definition of core scheduled tasks.
|
||||
*
|
||||
* The handlers defined on this file are processed and registered into
|
||||
* the Moodle DB after any install or upgrade operation. All plugins
|
||||
* support this.
|
||||
*
|
||||
* @package core
|
||||
* @category task
|
||||
* @copyright 2016 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/* List of handlers */
|
||||
|
||||
$tasks = array(
|
||||
array(
|
||||
'classname' => 'assignfeedback_editpdf\task\convert_submissions',
|
||||
'blocking' => 0,
|
||||
'minute' => '*/15',
|
||||
'hour' => '*',
|
||||
'day' => '*',
|
||||
'dayofweek' => '*',
|
||||
'month' => '*'
|
||||
),
|
||||
);
|
|
@ -30,7 +30,9 @@ defined('MOODLE_INTERNAL') || die();
|
|||
* @return bool
|
||||
*/
|
||||
function xmldb_assignfeedback_editpdf_upgrade($oldversion) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Moodle v2.8.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
@ -41,5 +43,29 @@ function xmldb_assignfeedback_editpdf_upgrade($oldversion) {
|
|||
// Moodle v3.0.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
if ($oldversion < 2016021600) {
|
||||
|
||||
// Define table assignfeedback_editpdf_queue to be created.
|
||||
$table = new xmldb_table('assignfeedback_editpdf_queue');
|
||||
|
||||
// Adding fields to table assignfeedback_editpdf_queue.
|
||||
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
|
||||
$table->add_field('submissionid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
$table->add_field('submissionattempt', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
|
||||
|
||||
// Adding keys to table assignfeedback_editpdf_queue.
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
|
||||
// Conditionally launch create table for assignfeedback_editpdf_queue.
|
||||
if (!$dbman->table_exists($table)) {
|
||||
$dbman->create_table($table);
|
||||
}
|
||||
|
||||
// Editpdf savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2016021600, 'assignfeedback', 'editpdf');
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,8 @@ $string['test_notexecutable'] = 'The ghostscript points to a file that is not ex
|
|||
$string['test_ok'] = 'The ghostscript path appears to be OK - please check you can see the message in the image below';
|
||||
$string['toolbarbutton'] = '{$a->tool} {$a->shortcut}';
|
||||
$string['tool'] = 'Tool';
|
||||
$string['unsavedchanges'] = 'Unsaved changes';
|
||||
$string['viewfeedbackonline'] = 'View annotated PDF...';
|
||||
$string['white'] = 'White';
|
||||
$string['yellow'] = 'Yellow';
|
||||
$string['draftchangessaved'] = 'Draft annotations saved';
|
||||
$string['preparesubmissionsforannotation'] = 'Prepare submissions for annotation';
|
||||
|
|
|
@ -168,21 +168,16 @@ class assign_feedback_editpdf extends assign_feedback_plugin {
|
|||
$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');
|
||||
|
||||
$renderer = $PAGE->get_renderer('assignfeedback_editpdf');
|
||||
$widget = $this->get_widget($userid, $grade, false);
|
||||
|
||||
$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);
|
||||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -364,4 +359,12 @@ class assign_feedback_editpdf extends assign_feedback_plugin {
|
|||
public function get_file_areas() {
|
||||
return array(document_services::FINAL_PDF_FILEAREA => $this->get_name());
|
||||
}
|
||||
|
||||
/**
|
||||
* This plugin will inject content into the review panel with javascript.
|
||||
* @return bool true
|
||||
*/
|
||||
public function supports_review_panel() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,20 @@
|
|||
cursor: crosshair;
|
||||
background-repeat: no-repeat;
|
||||
background-color: #ccc;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.assignfeedback_editpdf_widget .moodle-dialogue-bd .drawingregion {
|
||||
position: inherit;
|
||||
}
|
||||
.assignfeedback_editpdf_widget .drawingregion {
|
||||
border: 1px solid #ccc;
|
||||
left: 1em;
|
||||
right: 1em;
|
||||
top: 52px;
|
||||
bottom: 0px;
|
||||
position: absolute;
|
||||
overflow: auto;
|
||||
width: 842px; /* A4 portrait should not need a horizontal scrollbar */
|
||||
}
|
||||
|
||||
.assignfeedback_editpdf_widget {
|
||||
|
@ -32,18 +42,25 @@
|
|||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
min-height: 50px;
|
||||
height: 52px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.moodle-dialogue-base .moodle-dialogue.assignfeedback_editpdf_widget .moodle-dialogue-bd {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.assignfeedback_editpdf_unsavedchanges.haschanges{
|
||||
display: block;
|
||||
.assignfeedback_editpdf_widget .assignfeedback_editpdf_unsavedchanges.haschanges{
|
||||
display: inline-block;
|
||||
}
|
||||
.assignfeedback_editpdf_unsavedchanges {
|
||||
.assignfeedback_editpdf_widget .assignfeedback_editpdf_unsavedchanges {
|
||||
display: none;
|
||||
margin-top: 1em;
|
||||
position: absolute;
|
||||
left: 20px;
|
||||
top: 60px;
|
||||
}
|
||||
.dir-rtl .assignfeedback_editpdf_widget .assignfeedback_editpdf_unsavedchanges {
|
||||
float: right;
|
||||
}
|
||||
.yui3-colourpicker-hidden,
|
||||
.yui3-commentsearch-hidden,
|
||||
|
@ -290,3 +307,31 @@ ul.assignfeedback_editpdf_menu {
|
|||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
@media (max-width: 899px) {
|
||||
.assignfeedback_editpdf_widget .pageheader {
|
||||
height: 104px;
|
||||
}
|
||||
.assignfeedback_editpdf_widget .drawingregion {
|
||||
top: 104px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.assignfeedback_editpdf_widget .drawingregion {
|
||||
position: inherit;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.assignfeedback_editpdf_widget .pageheader {
|
||||
height: 52px;
|
||||
}
|
||||
.assignfeedback_editpdf_widget .drawingregion {
|
||||
top: 52px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 683px) {
|
||||
.assignfeedback_editpdf_widget .pageheader {
|
||||
height: 104px;
|
||||
}
|
||||
.assignfeedback_editpdf_widget .drawingregion {
|
||||
top: 104px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,11 +50,9 @@ Feature: In an assignment, teacher can annotate PDF files during grading
|
|||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
And I follow "View/grade all submissions"
|
||||
And I follow "View all submissions"
|
||||
And I click on "Edit" "link" in the "Submitted for grading" "table_row"
|
||||
And I click on "Grade" "link" in the "Submitted for grading" "table_row"
|
||||
And I follow "Launch PDF editor..."
|
||||
And I change window size to "large"
|
||||
And I should see "Page 1 of 3"
|
||||
And I click on ".navigate-next-button" "css_element"
|
||||
And I should see "Page 2 of 3"
|
||||
|
@ -62,11 +60,10 @@ Feature: In an assignment, teacher can annotate PDF files during grading
|
|||
And I click on ".linebutton" "css_element"
|
||||
And I click on ".commentcolourbutton" "css_element"
|
||||
And I click on "//img[@alt=\"Blue\"]/parent::button" "xpath_element"
|
||||
And I change window size to "medium"
|
||||
And I wait until the page is ready
|
||||
And I click on "Close" "button"
|
||||
And I press "Save changes"
|
||||
And I should see "The grade changes were saved"
|
||||
And I wait until the page is ready
|
||||
And I should see "The changes to the grade and feedback were saved"
|
||||
|
||||
@javascript
|
||||
Scenario: Submit a PDF file as a student in a team and annotate the PDF as a teacher
|
||||
|
@ -129,17 +126,15 @@ Feature: In an assignment, teacher can annotate PDF files during grading
|
|||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
And I follow "View/grade all submissions"
|
||||
And I follow "View all submissions"
|
||||
And I click on "Edit" "link" in the "Student 2" "table_row"
|
||||
And I click on "Grade" "link" in the "Student 2" "table_row"
|
||||
And I follow "Launch PDF editor..."
|
||||
And I change window size to "large"
|
||||
And I click on ".stampbutton" "css_element"
|
||||
And I click on ".drawingcanvas" "css_element"
|
||||
And I change window size to "medium"
|
||||
And I wait until the page is ready
|
||||
And I click on "Close" "button"
|
||||
And I click on ".linebutton" "css_element"
|
||||
And I draw on the pdf
|
||||
And I press "Save changes"
|
||||
And I should see "The grade changes were saved"
|
||||
And I press "Continue"
|
||||
And I should see "The changes to the grade and feedback were saved"
|
||||
And I press "Ok"
|
||||
And I click on "Edit settings" "link"
|
||||
And I follow "Test assignment name"
|
||||
And I follow "View all submissions"
|
||||
And I should see "View annotated PDF..." in the "student2@example.com" "table_row"
|
||||
|
|
|
@ -49,4 +49,33 @@ class behat_assignfeedback_editpdf extends behat_base {
|
|||
throw new \Moodle\BehatExtension\Exception\SkippedException;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw on the pdf.
|
||||
*
|
||||
* @When /^I draw on the pdf$/
|
||||
*/
|
||||
public function i_draw_on_the_pdf() {
|
||||
$js = ' (function() {
|
||||
var instance = M.assignfeedback_editpdf.instance;
|
||||
var event = { clientX: 100, clientY: 250, preventDefault: function() {} };
|
||||
instance.edit_start(event);
|
||||
}()); ';
|
||||
$this->getSession()->executeScript($js);
|
||||
sleep(1);
|
||||
$js = ' (function() {
|
||||
var instance = M.assignfeedback_editpdf.instance;
|
||||
var event = { clientX: 150, clientY: 275, preventDefault: function() {} };
|
||||
instance.edit_move(event);
|
||||
}()); ';
|
||||
$this->getSession()->executeScript($js);
|
||||
sleep(1);
|
||||
$js = ' (function() {
|
||||
var instance = M.assignfeedback_editpdf.instance;
|
||||
var event = { clientX: 200, clientY: 300, preventDefault: function() {} };
|
||||
instance.edit_end(event);
|
||||
}()); ';
|
||||
$this->getSession()->executeScript($js);
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,26 +50,22 @@ Feature: In a group assignment, teacher can annotate PDF files for all users
|
|||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
And I follow "View/grade all submissions"
|
||||
And I follow "View all submissions"
|
||||
And I click on "Grade" "link" in the "Submitted for grading" "table_row"
|
||||
And I follow "Launch PDF editor..."
|
||||
And I change window size to "large"
|
||||
And I click on ".navigate-next-button" "css_element"
|
||||
And I click on ".stampbutton" "css_element"
|
||||
And I click on ".drawingcanvas" "css_element"
|
||||
And I change window size to "medium"
|
||||
And I draw on the pdf
|
||||
And I wait until the page is ready
|
||||
And I click on "Close" "button"
|
||||
And I press "Save changes"
|
||||
And I should see "The grade changes were saved"
|
||||
And I should see "The changes to the grade and feedback were saved"
|
||||
And I press "Ok"
|
||||
And I click on "Edit settings" "link"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I follow "Course 1"
|
||||
And I follow "Test assignment name"
|
||||
When I follow "View annotated PDF..."
|
||||
And I change window size to "large"
|
||||
Then I should see "Annotate PDF"
|
||||
And I change window size to "medium"
|
||||
And I wait until the page is ready
|
||||
And I click on "Close" "button"
|
||||
And I log out
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2015111600;
|
||||
$plugin->version = 2016021601;
|
||||
$plugin->requires = 2015111000;
|
||||
$plugin->component = 'assignfeedback_editpdf';
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
|
|||
ANNOTATIONCOLOURBUTTON : '.annotationcolourbutton',
|
||||
DELETEANNOTATIONBUTTON : '.deleteannotationbutton',
|
||||
UNSAVEDCHANGESDIV : '.assignfeedback_editpdf_unsavedchanges',
|
||||
UNSAVEDCHANGESINPUT : 'input[name="assignfeedback_editpdf_haschanges"]',
|
||||
STAMPSBUTTON : '.currentstampbutton',
|
||||
DIALOGUE : '.' + CSS.DIALOGUE
|
||||
},
|
||||
|
@ -3097,6 +3098,15 @@ EDITOR.prototype = {
|
|||
*/
|
||||
dialogue : null,
|
||||
|
||||
/**
|
||||
* The panel used for all action menu displays.
|
||||
*
|
||||
* @property type
|
||||
* @type Y.Node
|
||||
* @protected
|
||||
*/
|
||||
panel : null,
|
||||
|
||||
/**
|
||||
* The number of pages in the pdf.
|
||||
*
|
||||
|
@ -3258,11 +3268,24 @@ EDITOR.prototype = {
|
|||
link.on('click', this.link_handler, this);
|
||||
link.on('key', this.link_handler, 'down:13', this);
|
||||
|
||||
this.currentedit.start = false;
|
||||
this.currentedit.end = false;
|
||||
if (!this.get('readonly')) {
|
||||
this.quicklist = new M.assignfeedback_editpdf.quickcommentlist(this);
|
||||
}
|
||||
// We call the amd module to see if we can take control of the review panel.
|
||||
require(['mod_assign/grading_review_panel'], function(ReviewPanelManager) {
|
||||
var panelManager = new ReviewPanelManager();
|
||||
|
||||
var panel = panelManager.getReviewPanel('assignfeedback_editpdf');
|
||||
if (panel) {
|
||||
panel = Y.one(panel);
|
||||
panel.empty();
|
||||
link.ancestor('.fitem').hide();
|
||||
this.open_in_panel(panel);
|
||||
}
|
||||
this.currentedit.start = false;
|
||||
this.currentedit.end = false;
|
||||
if (!this.get('readonly')) {
|
||||
this.quicklist = new M.assignfeedback_editpdf.quickcommentlist(this);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -3341,6 +3364,36 @@ EDITOR.prototype = {
|
|||
return newpoint;
|
||||
},
|
||||
|
||||
/**
|
||||
* Open the edit-pdf editor in the panel in the page instead of a popup.
|
||||
* @method open_in_panel
|
||||
*/
|
||||
open_in_panel : function(panel) {
|
||||
var drawingcanvas, drawingregion;
|
||||
|
||||
this.panel = panel;
|
||||
panel.append(this.get('body'));
|
||||
panel.addClass(CSS.DIALOGUE);
|
||||
|
||||
this.loadingicon = this.get_dialogue_element(SELECTOR.LOADINGICON);
|
||||
|
||||
drawingcanvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS);
|
||||
this.graphic = new Y.Graphic({render : drawingcanvas});
|
||||
|
||||
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
|
||||
drawingregion.on('scroll', this.move_canvas, this);
|
||||
|
||||
if (!this.get('readonly')) {
|
||||
drawingcanvas.on('gesturemovestart', this.edit_start, null, this);
|
||||
drawingcanvas.on('gesturemove', this.edit_move, null, this);
|
||||
drawingcanvas.on('gesturemoveend', this.edit_end, null, this);
|
||||
|
||||
this.refresh_button_state();
|
||||
}
|
||||
|
||||
this.load_all_pages();
|
||||
},
|
||||
|
||||
/**
|
||||
* Called to open the pdf editing dialogue.
|
||||
* @method link_handler
|
||||
|
@ -3496,14 +3549,18 @@ EDITOR.prototype = {
|
|||
try {
|
||||
data = Y.JSON.parse(responsetext);
|
||||
if (data.error || !data.pagecount) {
|
||||
this.dialogue.hide();
|
||||
if (this.dialogue) {
|
||||
this.dialogue.hide();
|
||||
}
|
||||
// Display alert dialogue.
|
||||
error = new M.core.alert({ message: M.util.get_string('cannotopenpdf', 'assignfeedback_editpdf') });
|
||||
error.show();
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
this.dialogue.hide();
|
||||
if (this.dialogue) {
|
||||
this.dialogue.hide();
|
||||
}
|
||||
// Display alert dialogue.
|
||||
error = new M.core.alert({ title: M.util.get_string('cannotopenpdf', 'assignfeedback_editpdf')});
|
||||
error.show();
|
||||
|
@ -3734,7 +3791,11 @@ EDITOR.prototype = {
|
|||
* @method get_dialogue_element
|
||||
*/
|
||||
get_dialogue_element : function(selector) {
|
||||
return this.dialogue.get('boundingBox').one(selector);
|
||||
if (this.panel) {
|
||||
return this.panel.one(selector);
|
||||
} else {
|
||||
return this.dialogue.get('boundingBox').one(selector);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -3915,10 +3976,12 @@ EDITOR.prototype = {
|
|||
resize : function() {
|
||||
var drawingregion, drawregionheight;
|
||||
|
||||
if (!this.dialogue.get('visible')) {
|
||||
return;
|
||||
if (this.dialogue) {
|
||||
if (!this.dialogue.get('visible')) {
|
||||
return;
|
||||
}
|
||||
this.dialogue.centerDialogue();
|
||||
}
|
||||
this.dialogue.centerDialogue();
|
||||
|
||||
// Make sure the dialogue box is not bigger than the max height of the viewport.
|
||||
drawregionheight = Y.one('body').get('winHeight') - 120; // Space for toolbar + titlebar.
|
||||
|
@ -3926,7 +3989,9 @@ EDITOR.prototype = {
|
|||
drawregionheight = 100;
|
||||
}
|
||||
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
|
||||
drawingregion.setStyle('maxHeight', drawregionheight +'px');
|
||||
if (this.dialogue) {
|
||||
drawingregion.setStyle('maxHeight', drawregionheight +'px');
|
||||
}
|
||||
this.redraw();
|
||||
return true;
|
||||
},
|
||||
|
@ -3985,8 +4050,16 @@ EDITOR.prototype = {
|
|||
if (jsondata.error) {
|
||||
return new M.core.ajaxException(jsondata);
|
||||
}
|
||||
Y.one('#' + this.get('linkid')).siblings(SELECTOR.UNSAVEDCHANGESDIV)
|
||||
.item(0).addClass('haschanges');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESINPUT).set('value', 'true');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('opacity', 1);
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'inline-block');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).transition({
|
||||
duration: 1,
|
||||
delay: 2,
|
||||
opacity: 0
|
||||
}, function() {
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'none');
|
||||
});
|
||||
} catch (e) {
|
||||
return new M.core.exception(e);
|
||||
}
|
||||
|
@ -4229,7 +4302,8 @@ M.assignfeedback_editpdf.editor = M.assignfeedback_editpdf.editor || {};
|
|||
* @param {Object} params
|
||||
*/
|
||||
M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || function(params) {
|
||||
return new EDITOR(params);
|
||||
M.assignfeedback_editpdf.instance = new EDITOR(params);
|
||||
return M.assignfeedback_editpdf.instance;
|
||||
};
|
||||
|
||||
|
||||
|
@ -4243,6 +4317,7 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
|
|||
"json",
|
||||
"event-move",
|
||||
"event-resize",
|
||||
"transition",
|
||||
"querystring-stringify-simple",
|
||||
"moodle-core-notification-dialog",
|
||||
"moodle-core-notification-exception",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -42,6 +42,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
|
|||
ANNOTATIONCOLOURBUTTON : '.annotationcolourbutton',
|
||||
DELETEANNOTATIONBUTTON : '.deleteannotationbutton',
|
||||
UNSAVEDCHANGESDIV : '.assignfeedback_editpdf_unsavedchanges',
|
||||
UNSAVEDCHANGESINPUT : 'input[name="assignfeedback_editpdf_haschanges"]',
|
||||
STAMPSBUTTON : '.currentstampbutton',
|
||||
DIALOGUE : '.' + CSS.DIALOGUE
|
||||
},
|
||||
|
@ -3097,6 +3098,15 @@ EDITOR.prototype = {
|
|||
*/
|
||||
dialogue : null,
|
||||
|
||||
/**
|
||||
* The panel used for all action menu displays.
|
||||
*
|
||||
* @property type
|
||||
* @type Y.Node
|
||||
* @protected
|
||||
*/
|
||||
panel : null,
|
||||
|
||||
/**
|
||||
* The number of pages in the pdf.
|
||||
*
|
||||
|
@ -3258,11 +3268,24 @@ EDITOR.prototype = {
|
|||
link.on('click', this.link_handler, this);
|
||||
link.on('key', this.link_handler, 'down:13', this);
|
||||
|
||||
this.currentedit.start = false;
|
||||
this.currentedit.end = false;
|
||||
if (!this.get('readonly')) {
|
||||
this.quicklist = new M.assignfeedback_editpdf.quickcommentlist(this);
|
||||
}
|
||||
// We call the amd module to see if we can take control of the review panel.
|
||||
require(['mod_assign/grading_review_panel'], function(ReviewPanelManager) {
|
||||
var panelManager = new ReviewPanelManager();
|
||||
|
||||
var panel = panelManager.getReviewPanel('assignfeedback_editpdf');
|
||||
if (panel) {
|
||||
panel = Y.one(panel);
|
||||
panel.empty();
|
||||
link.ancestor('.fitem').hide();
|
||||
this.open_in_panel(panel);
|
||||
}
|
||||
this.currentedit.start = false;
|
||||
this.currentedit.end = false;
|
||||
if (!this.get('readonly')) {
|
||||
this.quicklist = new M.assignfeedback_editpdf.quickcommentlist(this);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -3341,6 +3364,36 @@ EDITOR.prototype = {
|
|||
return newpoint;
|
||||
},
|
||||
|
||||
/**
|
||||
* Open the edit-pdf editor in the panel in the page instead of a popup.
|
||||
* @method open_in_panel
|
||||
*/
|
||||
open_in_panel : function(panel) {
|
||||
var drawingcanvas, drawingregion;
|
||||
|
||||
this.panel = panel;
|
||||
panel.append(this.get('body'));
|
||||
panel.addClass(CSS.DIALOGUE);
|
||||
|
||||
this.loadingicon = this.get_dialogue_element(SELECTOR.LOADINGICON);
|
||||
|
||||
drawingcanvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS);
|
||||
this.graphic = new Y.Graphic({render : drawingcanvas});
|
||||
|
||||
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
|
||||
drawingregion.on('scroll', this.move_canvas, this);
|
||||
|
||||
if (!this.get('readonly')) {
|
||||
drawingcanvas.on('gesturemovestart', this.edit_start, null, this);
|
||||
drawingcanvas.on('gesturemove', this.edit_move, null, this);
|
||||
drawingcanvas.on('gesturemoveend', this.edit_end, null, this);
|
||||
|
||||
this.refresh_button_state();
|
||||
}
|
||||
|
||||
this.load_all_pages();
|
||||
},
|
||||
|
||||
/**
|
||||
* Called to open the pdf editing dialogue.
|
||||
* @method link_handler
|
||||
|
@ -3496,14 +3549,18 @@ EDITOR.prototype = {
|
|||
try {
|
||||
data = Y.JSON.parse(responsetext);
|
||||
if (data.error || !data.pagecount) {
|
||||
this.dialogue.hide();
|
||||
if (this.dialogue) {
|
||||
this.dialogue.hide();
|
||||
}
|
||||
// Display alert dialogue.
|
||||
error = new M.core.alert({ message: M.util.get_string('cannotopenpdf', 'assignfeedback_editpdf') });
|
||||
error.show();
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
this.dialogue.hide();
|
||||
if (this.dialogue) {
|
||||
this.dialogue.hide();
|
||||
}
|
||||
// Display alert dialogue.
|
||||
error = new M.core.alert({ title: M.util.get_string('cannotopenpdf', 'assignfeedback_editpdf')});
|
||||
error.show();
|
||||
|
@ -3734,7 +3791,11 @@ EDITOR.prototype = {
|
|||
* @method get_dialogue_element
|
||||
*/
|
||||
get_dialogue_element : function(selector) {
|
||||
return this.dialogue.get('boundingBox').one(selector);
|
||||
if (this.panel) {
|
||||
return this.panel.one(selector);
|
||||
} else {
|
||||
return this.dialogue.get('boundingBox').one(selector);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -3915,10 +3976,12 @@ EDITOR.prototype = {
|
|||
resize : function() {
|
||||
var drawingregion, drawregionheight;
|
||||
|
||||
if (!this.dialogue.get('visible')) {
|
||||
return;
|
||||
if (this.dialogue) {
|
||||
if (!this.dialogue.get('visible')) {
|
||||
return;
|
||||
}
|
||||
this.dialogue.centerDialogue();
|
||||
}
|
||||
this.dialogue.centerDialogue();
|
||||
|
||||
// Make sure the dialogue box is not bigger than the max height of the viewport.
|
||||
drawregionheight = Y.one('body').get('winHeight') - 120; // Space for toolbar + titlebar.
|
||||
|
@ -3926,7 +3989,9 @@ EDITOR.prototype = {
|
|||
drawregionheight = 100;
|
||||
}
|
||||
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
|
||||
drawingregion.setStyle('maxHeight', drawregionheight +'px');
|
||||
if (this.dialogue) {
|
||||
drawingregion.setStyle('maxHeight', drawregionheight +'px');
|
||||
}
|
||||
this.redraw();
|
||||
return true;
|
||||
},
|
||||
|
@ -3985,8 +4050,16 @@ EDITOR.prototype = {
|
|||
if (jsondata.error) {
|
||||
return new M.core.ajaxException(jsondata);
|
||||
}
|
||||
Y.one('#' + this.get('linkid')).siblings(SELECTOR.UNSAVEDCHANGESDIV)
|
||||
.item(0).addClass('haschanges');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESINPUT).set('value', 'true');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('opacity', 1);
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'inline-block');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).transition({
|
||||
duration: 1,
|
||||
delay: 2,
|
||||
opacity: 0
|
||||
}, function() {
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'none');
|
||||
});
|
||||
} catch (e) {
|
||||
return new M.core.exception(e);
|
||||
}
|
||||
|
@ -4229,7 +4302,8 @@ M.assignfeedback_editpdf.editor = M.assignfeedback_editpdf.editor || {};
|
|||
* @param {Object} params
|
||||
*/
|
||||
M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || function(params) {
|
||||
return new EDITOR(params);
|
||||
M.assignfeedback_editpdf.instance = new EDITOR(params);
|
||||
return M.assignfeedback_editpdf.instance;
|
||||
};
|
||||
|
||||
|
||||
|
@ -4243,6 +4317,7 @@ M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || f
|
|||
"json",
|
||||
"event-move",
|
||||
"event-resize",
|
||||
"transition",
|
||||
"querystring-stringify-simple",
|
||||
"moodle-core-notification-dialog",
|
||||
"moodle-core-notification-exception",
|
||||
|
|
|
@ -42,6 +42,15 @@ EDITOR.prototype = {
|
|||
*/
|
||||
dialogue : null,
|
||||
|
||||
/**
|
||||
* The panel used for all action menu displays.
|
||||
*
|
||||
* @property type
|
||||
* @type Y.Node
|
||||
* @protected
|
||||
*/
|
||||
panel : null,
|
||||
|
||||
/**
|
||||
* The number of pages in the pdf.
|
||||
*
|
||||
|
@ -203,11 +212,24 @@ EDITOR.prototype = {
|
|||
link.on('click', this.link_handler, this);
|
||||
link.on('key', this.link_handler, 'down:13', this);
|
||||
|
||||
this.currentedit.start = false;
|
||||
this.currentedit.end = false;
|
||||
if (!this.get('readonly')) {
|
||||
this.quicklist = new M.assignfeedback_editpdf.quickcommentlist(this);
|
||||
}
|
||||
// We call the amd module to see if we can take control of the review panel.
|
||||
require(['mod_assign/grading_review_panel'], function(ReviewPanelManager) {
|
||||
var panelManager = new ReviewPanelManager();
|
||||
|
||||
var panel = panelManager.getReviewPanel('assignfeedback_editpdf');
|
||||
if (panel) {
|
||||
panel = Y.one(panel);
|
||||
panel.empty();
|
||||
link.ancestor('.fitem').hide();
|
||||
this.open_in_panel(panel);
|
||||
}
|
||||
this.currentedit.start = false;
|
||||
this.currentedit.end = false;
|
||||
if (!this.get('readonly')) {
|
||||
this.quicklist = new M.assignfeedback_editpdf.quickcommentlist(this);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -286,6 +308,36 @@ EDITOR.prototype = {
|
|||
return newpoint;
|
||||
},
|
||||
|
||||
/**
|
||||
* Open the edit-pdf editor in the panel in the page instead of a popup.
|
||||
* @method open_in_panel
|
||||
*/
|
||||
open_in_panel : function(panel) {
|
||||
var drawingcanvas, drawingregion;
|
||||
|
||||
this.panel = panel;
|
||||
panel.append(this.get('body'));
|
||||
panel.addClass(CSS.DIALOGUE);
|
||||
|
||||
this.loadingicon = this.get_dialogue_element(SELECTOR.LOADINGICON);
|
||||
|
||||
drawingcanvas = this.get_dialogue_element(SELECTOR.DRAWINGCANVAS);
|
||||
this.graphic = new Y.Graphic({render : drawingcanvas});
|
||||
|
||||
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
|
||||
drawingregion.on('scroll', this.move_canvas, this);
|
||||
|
||||
if (!this.get('readonly')) {
|
||||
drawingcanvas.on('gesturemovestart', this.edit_start, null, this);
|
||||
drawingcanvas.on('gesturemove', this.edit_move, null, this);
|
||||
drawingcanvas.on('gesturemoveend', this.edit_end, null, this);
|
||||
|
||||
this.refresh_button_state();
|
||||
}
|
||||
|
||||
this.load_all_pages();
|
||||
},
|
||||
|
||||
/**
|
||||
* Called to open the pdf editing dialogue.
|
||||
* @method link_handler
|
||||
|
@ -441,14 +493,18 @@ EDITOR.prototype = {
|
|||
try {
|
||||
data = Y.JSON.parse(responsetext);
|
||||
if (data.error || !data.pagecount) {
|
||||
this.dialogue.hide();
|
||||
if (this.dialogue) {
|
||||
this.dialogue.hide();
|
||||
}
|
||||
// Display alert dialogue.
|
||||
error = new M.core.alert({ message: M.util.get_string('cannotopenpdf', 'assignfeedback_editpdf') });
|
||||
error.show();
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
this.dialogue.hide();
|
||||
if (this.dialogue) {
|
||||
this.dialogue.hide();
|
||||
}
|
||||
// Display alert dialogue.
|
||||
error = new M.core.alert({ title: M.util.get_string('cannotopenpdf', 'assignfeedback_editpdf')});
|
||||
error.show();
|
||||
|
@ -679,7 +735,11 @@ EDITOR.prototype = {
|
|||
* @method get_dialogue_element
|
||||
*/
|
||||
get_dialogue_element : function(selector) {
|
||||
return this.dialogue.get('boundingBox').one(selector);
|
||||
if (this.panel) {
|
||||
return this.panel.one(selector);
|
||||
} else {
|
||||
return this.dialogue.get('boundingBox').one(selector);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -860,10 +920,12 @@ EDITOR.prototype = {
|
|||
resize : function() {
|
||||
var drawingregion, drawregionheight;
|
||||
|
||||
if (!this.dialogue.get('visible')) {
|
||||
return;
|
||||
if (this.dialogue) {
|
||||
if (!this.dialogue.get('visible')) {
|
||||
return;
|
||||
}
|
||||
this.dialogue.centerDialogue();
|
||||
}
|
||||
this.dialogue.centerDialogue();
|
||||
|
||||
// Make sure the dialogue box is not bigger than the max height of the viewport.
|
||||
drawregionheight = Y.one('body').get('winHeight') - 120; // Space for toolbar + titlebar.
|
||||
|
@ -871,7 +933,9 @@ EDITOR.prototype = {
|
|||
drawregionheight = 100;
|
||||
}
|
||||
drawingregion = this.get_dialogue_element(SELECTOR.DRAWINGREGION);
|
||||
drawingregion.setStyle('maxHeight', drawregionheight +'px');
|
||||
if (this.dialogue) {
|
||||
drawingregion.setStyle('maxHeight', drawregionheight +'px');
|
||||
}
|
||||
this.redraw();
|
||||
return true;
|
||||
},
|
||||
|
@ -930,8 +994,16 @@ EDITOR.prototype = {
|
|||
if (jsondata.error) {
|
||||
return new M.core.ajaxException(jsondata);
|
||||
}
|
||||
Y.one('#' + this.get('linkid')).siblings(SELECTOR.UNSAVEDCHANGESDIV)
|
||||
.item(0).addClass('haschanges');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESINPUT).set('value', 'true');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('opacity', 1);
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'inline-block');
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).transition({
|
||||
duration: 1,
|
||||
delay: 2,
|
||||
opacity: 0
|
||||
}, function() {
|
||||
Y.one(SELECTOR.UNSAVEDCHANGESDIV).setStyle('display', 'none');
|
||||
});
|
||||
} catch (e) {
|
||||
return new M.core.exception(e);
|
||||
}
|
||||
|
@ -1174,5 +1246,6 @@ M.assignfeedback_editpdf.editor = M.assignfeedback_editpdf.editor || {};
|
|||
* @param {Object} params
|
||||
*/
|
||||
M.assignfeedback_editpdf.editor.init = M.assignfeedback_editpdf.editor.init || function(params) {
|
||||
return new EDITOR(params);
|
||||
M.assignfeedback_editpdf.instance = new EDITOR(params);
|
||||
return M.assignfeedback_editpdf.instance;
|
||||
};
|
||||
|
|
|
@ -40,6 +40,7 @@ var AJAXBASE = M.cfg.wwwroot + '/mod/assign/feedback/editpdf/ajax.php',
|
|||
ANNOTATIONCOLOURBUTTON : '.annotationcolourbutton',
|
||||
DELETEANNOTATIONBUTTON : '.deleteannotationbutton',
|
||||
UNSAVEDCHANGESDIV : '.assignfeedback_editpdf_unsavedchanges',
|
||||
UNSAVEDCHANGESINPUT : 'input[name="assignfeedback_editpdf_haschanges"]',
|
||||
STAMPSBUTTON : '.currentstampbutton',
|
||||
DIALOGUE : '.' + CSS.DIALOGUE
|
||||
},
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"json",
|
||||
"event-move",
|
||||
"event-resize",
|
||||
"transition",
|
||||
"querystring-stringify-simple",
|
||||
"moodle-core-notification-dialog",
|
||||
"moodle-core-notification-exception",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue