Gitlab CSE Unil

Commit 786c5007 authored by M. Chardon's avatar M. Chardon
Browse files

tool6 : fleche + cartouche

parent b1fac9eb
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace assignfeedback_editpdfplus;
/**
* Description of axis
*
* @author kury
*/
class axis {
/** @var int unique id for this annotation */
public $id = 0;
/** @var int contextid for this annotation */
public $contextid = 0;
/** @var int axis for this annotation */
public $label = '';
public $order = 1000;
/**
* Convert a compatible stdClass into an instance of this class.
* @param stdClass $record
*/
public function __construct(\stdClass $record = null) {
if ($record) {
$intcols = array('reply');
foreach ($this as $key => $value) {
if (isset($record->$key)) {
if (in_array($key, $intcols)) {
$this->$key = intval($record->$key);
} else {
$this->$key = $record->$key;
}
}
}
}
}
}
......@@ -159,6 +159,34 @@ class page_editor {
return $tools;
}
/**
* Get all tools for a page.
* @param int $contextid
* @param int $axis
* @return tool[]
*/
public static function get_axis($contextidlist) {
global $DB;
$axis = array();
if ($contextidlist) {
$records = $DB->get_records_list('assignfeedback_editpp_axis', 'contextid', $contextidlist);
} else {
$records = $DB->get_records('assignfeedback_editpp_axis');
}
foreach ($records as $record) {
array_push($axis, new tool($record));
}
usort($axis, function($a, $b) {
$al = $a->order;
$bl = $b->order;
if ($al == $bl) {
return 0;
}
return ($al > $bl) ? +1 : -1;
});
return $axis;
}
/**
* Get all annotations for a page.
* @param int $gradeid
......
......@@ -214,26 +214,12 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$toolbarCostum = array();
$axis = array();
foreach ($widget->toolbars as $toolbar) {
$compteur = 0;
if (sizeof($toolbar) > 0) {
$toolbartmp = '';
foreach ($toolbar as $tool) {
$toolbartmp .= $this->render_toolbar_button('', '', $tool);
}
$toolbarCostum[] = html_writer::div($toolbartmp, 'toolbar customtoolbar', array('role' => 'toolbar', 'id' => 'toolbaraxis' . $tool->axis, 'style' => 'display:none;'));
switch ($tool->axis) {
case 1:
$axis[1] = 'Axe 1 : rectitude';
break;
case 2:
$axis[2] = 'Axe 2 : structure/contenu';
break;
case 3:
$axis[3] = 'Axe 3 : instance corr.';
break;
}
$compteur++;
$axis[] = $toolbar['label'];
$toolbartmp = '';
foreach ($toolbar['tool'] as $tool) {
$toolbartmp .= $this->render_toolbar_button('', '', $tool);
}
$toolbarCostum[] = html_writer::div($toolbartmp, 'toolbar customtoolbar', array('role' => 'toolbar', 'id' => 'toolbaraxis' . $tool->axis, 'style' => 'display:none;'));
}
usort($axis, function($a, $b) {
$al = substr($a, 4, 5);
......
......@@ -98,6 +98,7 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="contextid" TYPE="foreign" FIELDS="contextid" REFTABLE="context" REFFIELDS="id"/>
<KEY NAME="axis" TYPE="foreign" FIELDS="axis" REFTABLE="editpdfpp_axis" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
......
......@@ -75,11 +75,20 @@ class assign_feedback_editpdfplus extends assign_feedback_plugin {
$coursecontext = context::instance_by_id($this->assignment->get_context()->id);
$coursecontexts = array_filter(explode('/', $coursecontext->path), 'strlen');
$tools = page_editor::get_tools($coursecontexts);
foreach ($tools as $tool) {
$axis = page_editor::get_axis($coursecontexts);
foreach ($axis as $ax) {
$toolbars[$ax->id]['label'] = $ax->label;
foreach ($tools as $tool) {
if ($tool->axis == $ax->id) {
$toolbars[$ax->id]['tool'][$tool->id] = $tool;
}
}
}
/*foreach ($tools as $tool) {
if ($tool->axis > 0) {
$toolbars[$tool->axis - 1][] = $tool;
}
}
}*/
//debugging(sizeof($toolbars[0]) . ' ' . sizeof($toolbars[1]) . ' ' . sizeof($toolbars[2]));
// Copy any new stamps to this instance.
if ($files = $fs->get_area_files($syscontext->id, 'assignfeedback_editpdfplus', 'stamps', 0, "filename", false)) {
......
File added
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="-0.1 -3.1 16 16"
preserveAspectRatio="xMinYMid meet"
overflow="visible"
id="svg2"
version="1.1"
inkscape:version="0.91 r"
sodipodi:docname="twoway.svg">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1053"
id="namedview6"
showgrid="false"
inkscape:object-paths="false"
inkscape:snap-center="false"
inkscape:snap-object-midpoints="false"
inkscape:snap-midpoints="false"
inkscape:zoom="14.75"
inkscape:cx="8.1355932"
inkscape:cy="8"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<path
d="M 15.432203,7.9644068 14.108475,5.6237288 C 13.830007,5.1313305 13.277443,3.1818391 12.866102,3.6186441 L 11.442373,5.1305085 C 8.3731068,2.8062019 7.991888,2.7769111 4.2220339,5.3338983 L 2.7983051,3.7542373 C 2.4635586,3.3828281 2.2096084,4.748161 2.0305085,5.2847458 L 1.1813559,7.8288136 C 1.002256,8.3653983 1.2258552,8.8856784 1.7915254,8.8898305 L 6.640678,8.9254237 C 7.2063482,8.9295758 6.4068484,8.4994724 6.0525424,8.0152542 L 5.4423729,7.1813559 c 2.2808096,-2.1375303 2.8839643,-2.0836114 5.1864411,0 L 10.086441,7.9474576 C 9.7975322,8.3555408 8.8648357,8.8614091 9.4305085,8.8576271 l 5.3237285,-0.035593 c 0.4,-0.3 0.956433,-0.3652288 0.677966,-0.8576271 z"
id="path4"
inkscape:connector-curvature="0"
style="fill:#999999"
sodipodi:nodetypes="sssccssssssccsscs" />
</svg>
File added
......@@ -347,7 +347,8 @@ ul.assignfeedback_editpdfplus_menu {
/*** add editpdfplus ***/
.assignfeedback_editpdfplus_hightlightplus,
.assignfeedback_editpdfplus_frame,
.assignfeedback_editpdfplus_verticalline {
.assignfeedback_editpdfplus_verticalline,
.assignfeedback_editpdfplus_stampcomment {
position:absolute;
border:2px solid;
border-radius: 10px;
......@@ -355,7 +356,8 @@ ul.assignfeedback_editpdfplus_menu {
}
.assignfeedback_editpdfplus_hightlightplus_cartridge,
.assignfeedback_editpdfplus_frame_cartridge,
.assignfeedback_editpdfplus_verticalline_cartridge {
.assignfeedback_editpdfplus_verticalline_cartridge,
.assignfeedback_editpdfplus_stampcomment_cartridge {
display:inline;
border-right:2px solid;
padding-left:2px;
......@@ -364,20 +366,23 @@ ul.assignfeedback_editpdfplus_menu {
}
.assignfeedback_editpdfplus_hightlightplus_conteneur,
.assignfeedback_editpdfplus_frame_conteneur,
.assignfeedback_editpdfplus_verticalline_conteneur {
.assignfeedback_editpdfplus_verticalline_conteneur,
.assignfeedback_editpdfplus_stampcomment_conteneur {
display:inline;
margin-right:4px;
}
.assignfeedback_editpdfplus_hightlightplus_conteneur > button,
.assignfeedback_editpdfplus_frame_conteneur > button,
.assignfeedback_editpdfplus_verticalline_conteneur > button {
.assignfeedback_editpdfplus_verticalline_conteneur > button,
.assignfeedback_editpdfplus_stampcomment_conteneur > button {
margin:0;
margin-left:2px;
padding:0;
}
.assignfeedback_editpdfplus_hightlightplus_input,
.assignfeedback_editpdfplus_frame_input,
.assignfeedback_editpdfplus_verticalline_input {
.assignfeedback_editpdfplus_verticalline_input,
.assignfeedback_editpdfplus_stampcomment_input {
display:inline;
padding-left:2px;
padding-right:2px;
......@@ -385,19 +390,22 @@ ul.assignfeedback_editpdfplus_menu {
}
.assignfeedback_editpdfplus_hightlightplus_edition,
.assignfeedback_editpdfplus_frame_edition,
.assignfeedback_editpdfplus_verticalline_edition {
.assignfeedback_editpdfplus_verticalline_edition,
.assignfeedback_editpdfplus_stampcomment_edition {
padding-left:2px;
padding-right:2px;
font-size:12px;
}
.assignfeedback_editpdfplus_hightlightplus_edition > div,
.assignfeedback_editpdfplus_frame_edition > div,
.assignfeedback_editpdfplus_verticalline_edition > div {
.assignfeedback_editpdfplus_verticalline_edition > div,
.assignfeedback_editpdfplus_stampcomment_edition > div {
width:220px;
}
.assignfeedback_editpdfplus_hightlightplus_edition > div > p,
.assignfeedback_editpdfplus_frame_edition > div > p,
.assignfeedback_editpdfplus_verticalline_edition > div > p {
.assignfeedback_editpdfplus_verticalline_edition > div > p,
.assignfeedback_editpdfplus_stampcomment_edition > div > p {
margin:0;
width:195px;
}
\ No newline at end of file
......@@ -129,7 +129,9 @@ TOOLTYPEDEFAULTCOLOR = {
'STAMPPLUS': 'red',
'FRAME': '#FF0000',
'VERTICALLINE': '#0000FF',
'VERTICALLINECARTRIDGE': '#0000FF'
'VERTICALLINECARTRIDGE': '#0000FF',
'STAMPCOMMENT': '#000099',
'STAMPCOMMENTCARTRIDGE': '#000099'
},
STROKEWEIGHT = 4;// This file is part of Moodle - http://moodle.org/
//
......@@ -2422,6 +2424,313 @@ M.assignfeedback_editpdfplus.annotationstampplus = ANNOTATIONSTAMPPLUS;
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides an in browser PDF editor.
*
* @module moodle-assignfeedback_editpdfplus-editor
*/
/**
* Class representing a stampcomment.
*
* @namespace M.assignfeedback_editpdfplus
* @class annotationstampcomment
* @extends M.assignfeedback_editpdfplus.annotation
*/
var ANNOTATIONSTAMPCOMMENT = function (config) {
ANNOTATIONSTAMPCOMMENT.superclass.constructor.apply(this, [config]);
};
ANNOTATIONSTAMPCOMMENT.NAME = "annotationstampcomment";
ANNOTATIONSTAMPCOMMENT.ATTRS = {};
Y.extend(ANNOTATIONSTAMPCOMMENT, M.assignfeedback_editpdfplus.annotation, {
/**
* Draw a stampcomment annotation
* @protected
* @method draw
* @return M.assignfeedback_editpdfplus.drawable
*/
draw: function () {
var drawable = new M.assignfeedback_editpdfplus.drawable(this.editor),
drawingcanvas = this.editor.get_dialogue_element(SELECTOR.DRAWINGCANVAS),
node,
position;
position = this.editor.get_window_coordinates(new M.assignfeedback_editpdfplus.point(this.x, this.y));
node = Y.Node.create('<div/>');
node.setStyles({
'position': 'absolute',
'display': 'inline-block',
'backgroundImage': 'url(' + M.util.image_url('twoway_h', 'assignfeedback_editpdfplus') + ')',
'width': (this.endx - this.x),
'height': (this.endy - this.y),
'backgroundSize': '100% 100%',
'zIndex': 50
});
drawingcanvas.append(node);
node.setX(position.x);
node.setY(position.y);
drawable.store_position(node, position.x, position.y);
drawable.nodes.push(node);
this.drawable = drawable;
this.draw_catridge();
return ANNOTATIONSTAMPCOMMENT.superclass.draw.apply(this);
},
/**
* Draw the in progress edit.
*
* @public
* @method draw_current_edit
* @param M.assignfeedback_editpdfplus.edit edit
*/
draw_current_edit: function (edit) {
var bounds = new M.assignfeedback_editpdfplus.rect(),
drawable = new M.assignfeedback_editpdfplus.drawable(this.editor),
drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION),
node,
position;
bounds.bound([edit.start, edit.end]);
position = this.editor.get_window_coordinates(new M.assignfeedback_editpdfplus.point(bounds.x, bounds.y));
node = Y.Node.create('<div/>');
node.setStyles({
'position': 'absolute',
'display': 'inline-block',
'backgroundImage': 'url(' + M.util.image_url('twoway_h', 'assignfeedback_editpdfplus') + ')',
'width': bounds.width,
'height': bounds.height,
'backgroundSize': '100% 100%',
'zIndex': 50
});
drawingregion.append(node);
node.setX(position.x);
node.setY(position.y);
drawable.store_position(node, position.x, position.y);
drawable.nodes.push(node);
return drawable;
},
/**
* Promote the current edit to a real annotation.
*
* @public
* @method init_from_edit
* @param M.assignfeedback_editpdfplus.edit edit
* @return bool if width/height is more than min. required.
*/
init_from_edit: function (edit) {
var bounds = new M.assignfeedback_editpdfplus.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.stampcomment;
// Min width and height is always more than 40px.
return true;
},get_color_cartridge: function () {
var highlightcolour = ANNOTATIONCOLOUR[this.tooltype.cartridge_color];
if (!highlightcolour) {
highlightcolour = this.tooltype.cartridge_color;
} else {
// Add an alpha channel to the rgb colour.
highlightcolour = highlightcolour.replace('rgb', 'rgba');
highlightcolour = highlightcolour.replace(')', ',0.5)');
}
if (highlightcolour === '') {
return TOOLTYPEDEFAULTCOLOR.STAMPCOMMENTCARTRIDGE;
}
//Y.log('get_color_cartridge : ' + highlightcolour);
return highlightcolour;
},
draw_catridge: function (edit) {
var offsetcanvas = this.editor.get_dialogue_element(SELECTOR.DRAWINGCANVAS).getXY();
if (this.divcartridge === '') {
var date = (new Date().toJSON()).replace(/:/g, '').replace(/\./g, '');
this.divcartridge = 'ct_' + this.tooltype.id + '_' + date;
var drawingregion = this.editor.get_dialogue_element(SELECTOR.DRAWINGREGION);
var cartridge = this.tooltype.cartridge;
//Y.log('draw_catridge : ' + cartridge);
var colorcartridge = this.get_color_cartridge();
var div = "<div ";
div += "id='" + this.divcartridge + "' ";
div += "class='assignfeedback_editpdfplus_stampcomment' ";
div += "style='border-color: " + colorcartridge + ";'> ";
div += "</div>";
var divdisplay = Y.Node.create(div);
// inscription entete
var divcartridge = "<div ";
divcartridge += "class='assignfeedback_editpdfplus_stampcomment_cartridge' ";
divcartridge += "style='border-right-color: " + colorcartridge + ";color:" + colorcartridge + ";'> ";
divcartridge += cartridge;
divcartridge += "</div>";
divdisplay.append(Y.Node.create(divcartridge));
//creation input
var divconteneur = "<div ";
divconteneur += "class='assignfeedback_editpdfplus_stampcomment_conteneur' >";
divconteneur += "</div>";
var divconteneurdisplay = Y.Node.create(divconteneur);
var divinput = "<div ";
divinput += "id='" + this.divcartridge + "_display' ";
divinput += "class='assignfeedback_editpdfplus_stampcomment_input' ";
divinput += "style='color:" + colorcartridge + ";'> ";
if (this.textannot && this.textannot.length > 0) {
divinput += this.textannot.substr(0, 20);
} else {
divinput += '&nbsp;&nbsp;';
}
divinput += "</div>";
var onof = 0;
if (this.displaylock === '1') {
onof = 1;
}
var divinputdisplay = Y.Node.create(divinput);
var inputvalref = Y.Node.create("<input type='hidden' id='" + this.divcartridge + "_valref' value=\"" + this.textannot + "\"/>");
var inputonof = Y.Node.create("<input type='hidden' id='" + this.divcartridge + "_onof' value=" + onof + " />");
var lockvalue = 0;
if (this.displaylock > 0) {
lockvalue = 1;
}
var inputlockdisplay = Y.Node.create("<input type='hidden' id='" + this.divcartridge + "_lockdisplay' value=" + lockvalue + " />");
divinputdisplay.on('click', this.edit_annot, this);
var buttonvisibility = "<button id='" + this.divcartridge + "_buttonedit' ";
if (lockvalue > 0) {
buttonvisibility += "style='display:none;' ";
}
buttonvisibility += "><img src='";
if (this.displaylock === 1) {
buttonvisibility += M.util.image_url('t/left', 'core');
} else {
buttonvisibility += M.util.image_url('t/right', 'core');
}
buttonvisibility += "' /></button>";
var buttonvisibilitydisplay = Y.Node.create(buttonvisibility);
buttonvisibilitydisplay.on('click', this.change_visibility_annot, this);
var buttonsave = "<button id='" + this.divcartridge + "_buttonsave' style='display:none;margin-left:110px;'><img src='" + M.util.image_url('t/check', 'core') + "' /></button>";
var buttonsavedisplay = Y.Node.create(buttonsave);
buttonsavedisplay.on('click', this.save_annot, this);
var buttoncancel = "<button id='" + this.divcartridge + "_buttoncancel' style='display:none;'><img src='" + M.util.image_url('t/delete', 'core') + "' /></button>";
var buttoncanceldisplay = Y.Node.create(buttoncancel);
buttoncanceldisplay.on('click', this.hide_edit, this);
//var buttonlock = "<button id='" + this.divcartridge + "_buttonlock'><img src='";
//if (this.displaylock > 0) {
// buttonlock += M.util.image_url('t/locked', 'core');
//} else {
// buttonlock += M.util.image_url('t/lock', 'core');
//}
//buttonlock += "' /></button>";
//var buttonlockdisplay = Y.Node.create(buttonlock);
//buttonlockdisplay.on('click', this.lock_display, this);
divconteneurdisplay.append(divinputdisplay);
divconteneurdisplay.append(inputvalref);
divconteneurdisplay.append(inputonof);
divconteneurdisplay.append(inputlockdisplay);
divconteneurdisplay.append(buttonvisibilitydisplay);
divconteneurdisplay.append(buttonsavedisplay);
divconteneurdisplay.append(buttoncanceldisplay);
//divconteneurdisplay.append(buttonlockdisplay);
divdisplay.append(divconteneurdisplay);
//creation de la div d'edition
var divedition = "<div ";
divedition += "id='" + this.divcartridge + "_edit' ";
divedition += "class='assignfeedback_editpdfplus_stampcomment_edition' ";
divedition += "style='display:none;'> ";
divedition += "<input id='" + this.divcartridge + "_editinput' type='text' value=\"" + this.textannot + "\" />";
divedition += "</div>";
var diveditiondisplay = Y.Node.create(divedition);
divconteneurdisplay.append(diveditiondisplay);
var propositions = this.tooltype.texts;
//Y.log('draw_catridge : ' + propositions);
var divproposition = "<div></div>";
var divpropositiondisplay = Y.Node.create(divproposition);
if (propositions && propositions.length > 0) {
var propositionarray = propositions.split('","');
for (i = 0; i < propositionarray.length; i++) {
var buttontmp = "<p class='btn btn-default'>" + propositionarray[i].replace('"', '') + "</p>";
var buttontmpdisplay = Y.Node.create(buttontmp);
buttontmpdisplay.on('click', this.fill_input_edition, this, propositionarray[i].replace('"', ''));
divpropositiondisplay.append(buttontmpdisplay);
}
}
diveditiondisplay.append(divpropositiondisplay);
//positionnement de la div par rapport a l'annotation
divdisplay.setX(offsetcanvas[0] + this.x + 40);
divdisplay.setY(this.y + 12);
drawingregion.append(divdisplay);
//this.apply_visibility_annot();
} else {
var divid = '#' + this.divcartridge;
//Y.log('draw_catridge : ' + divid);
var divdisplay = this.editor.get_dialogue_element(divid);
divdisplay.setX(offsetcanvas[0] + this.x+40);
divdisplay.setY(offsetcanvas[1] + this.y + 12);
}
return true;
},
/**
* Move an annotation to a new location.