Gitlab CSE Unil

Commit d6f57803 authored by M. Chardon's avatar M. Chardon
Browse files

mise en place des axes

parent 00328255
...@@ -97,8 +97,10 @@ if ($action == 'loadallpages') { ...@@ -97,8 +97,10 @@ if ($action == 'loadallpages') {
$tools = page_editor::get_tools(); $tools = page_editor::get_tools();
$typetools = page_editor::get_typetools(); $typetools = page_editor::get_typetools();
$axis = page_editor::get_axis();
$response->tools = $tools; $response->tools = $tools;
$response->typetools = $typetools; $response->typetools = $typetools;
$response->axis = $axis;
echo json_encode($response); echo json_encode($response);
die(); die();
......
...@@ -205,7 +205,7 @@ class page_editor { ...@@ -205,7 +205,7 @@ class page_editor {
* Get all tools for a page. * Get all tools for a page.
* @param int $contextid * @param int $contextid
* @param int $axis * @param int $axis
* @return tool[] * @return axis[]
*/ */
public static function get_axis($contextidlist) { public static function get_axis($contextidlist) {
global $DB; global $DB;
...@@ -216,7 +216,7 @@ class page_editor { ...@@ -216,7 +216,7 @@ class page_editor {
$records = $DB->get_records('assignfeedback_editpp_axis'); $records = $DB->get_records('assignfeedback_editpp_axis');
} }
foreach ($records as $record) { foreach ($records as $record) {
array_push($axis, new tool($record)); array_push($axis, new axis($record));
} }
usort($axis, function($a, $b) { usort($axis, function($a, $b) {
$al = $a->order; $al = $a->order;
......
...@@ -142,6 +142,12 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base { ...@@ -142,6 +142,12 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
return html_writer::tag('button', $iconhtml, $iconparams); return html_writer::tag('button', $iconhtml, $iconparams);
} }
private function render_toolbar_axis(assignfeedback_editpdfplus\axis $axis) {
$iconhtml = $axis->label;
$iconparams = array('type' => 'checkbox', 'class' => 'axis', 'id' => 'ctaxis' . $axis->id, 'value' => $axis->id);
return html_writer::tag('input', $iconhtml, $iconparams);
}
/** /**
* Render the editpdf widget in the grading form. * Render the editpdf widget in the grading form.
* *
...@@ -168,7 +174,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base { ...@@ -168,7 +174,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$body = ''; $body = '';
// Create the page navigation. // Create the page navigation.
$navigation1 = ''; $navigation1 = '';
$navigation2 = ''; //$navigation2 = '';
//$divToolbar; //$divToolbar;
// Pick the correct arrow icons for right to left mode. // Pick the correct arrow icons for right to left mode.
if (right_to_left()) { if (right_to_left()) {
...@@ -193,13 +199,15 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base { ...@@ -193,13 +199,15 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$divnavigation1 = html_writer::div($navigation1, 'navigation', array('role' => 'navigation')); $divnavigation1 = html_writer::div($navigation1, 'navigation', array('role' => 'navigation'));
$navigation2 .= $this->render_toolbar_button('comment_search', 'searchcomments', null, $this->get_shortcut('searchcomments')); //$navigation2 .= $this->render_toolbar_button('comment_search', 'searchcomments', null, $this->get_shortcut('searchcomments'));
$divnavigation2 = html_writer::div($navigation2, 'navigation-search', array('role' => 'navigation')); //$divnavigation2 = html_writer::div($navigation2, 'navigation-search', array('role' => 'navigation'));
$toolbar001 = ''; $toolbar001 = '';
$toolbar002 = ''; $toolbar002 = '';
$toolbarCostumdiv = ''; $toolbarCostumdiv = '';
$toolbaraxis = '';
$clearfix = html_writer::div('', 'clearfix'); $clearfix = html_writer::div('', 'clearfix');
if (!$widget->readonly) { if (!$widget->readonly) {
/** Toolbar n°0 : basic tools * */ /** Toolbar n°0 : basic tools * */
...@@ -237,21 +245,28 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base { ...@@ -237,21 +245,28 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
return ($al > $bl) ? +1 : -1; return ($al > $bl) ? +1 : -1;
}); });
$axischoice = html_writer::div(html_writer::select($axis, 'axisselection', 0, FALSE), 'toolbar ', array('role' => 'toolbar')); $axischoice = html_writer::div(html_writer::select($axis, 'axisselection', 0, FALSE), 'toolbar ', array('role' => 'toolbar'));
foreach ($toolbarCostum as $toolbarCostumUnit) { foreach ($toolbarCostum as $toolbarCostumUnit) {
$toolbarCostumdiv.= $toolbarCostumUnit; $toolbarCostumdiv.= $toolbarCostumUnit;
} }
$toolbarCostumdiv.= $axischoice; $toolbarCostumdiv.= $axischoice;
} else {
$toolbaraxis = "<div class='navigation' style='padding-left:10px;margin-left:10px;'><div style='display:inline;margin-right:5px;text-align:left;'>";
$axis = $widget->axis;
$compteur = 0;
foreach ($axis as $ax) {
$toolbaraxis .= $this->render_toolbar_axis($ax);
$toolbaraxis .= "</div><div style='display:inline;margin-left:5px;margin-right:5px;text-align:left;'>";
}
$toolbaraxis .= "</div></div>";
} }
// Toobars written in reverse order because they are floated right. // Toobars written in reverse order because they are floated right.
$pageheader = html_writer::div($divnavigation1 . $pageheader = html_writer::div($divnavigation1 .
// $divnavigation2 .
$toolbar002 . $toolbar002 .
$toolbaraxis .
$toolbarCostumdiv . $toolbarCostumdiv .
$toolbar001 . $toolbar001 .
$clearfix, 'pageheader'); $clearfix, 'pageheader');
//debugging($pageheader);
$body .= $pageheader; $body .= $pageheader;
...@@ -287,8 +302,6 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base { ...@@ -287,8 +302,6 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
'readonly' => $widget->readonly, 'readonly' => $widget->readonly,
'pagetotal' => $widget->pagetotal)); 'pagetotal' => $widget->pagetotal));
//$this->page->requires->js_call_amd('assignfeedback_editpdfplus/toolbar', 'setup');
$this->page->requires->yui_module('moodle-assignfeedback_editpdfplus-editor', 'M.assignfeedback_editpdfplus.editor.init', $editorparams); $this->page->requires->yui_module('moodle-assignfeedback_editpdfplus-editor', 'M.assignfeedback_editpdfplus.editor.init', $editorparams);
$this->page->requires->strings_for_js(array( $this->page->requires->strings_for_js(array(
......
...@@ -57,8 +57,11 @@ class assignfeedback_editpdfplus_widget implements renderable { ...@@ -57,8 +57,11 @@ class assignfeedback_editpdfplus_widget implements renderable {
/** @var integer $pagetotal */ /** @var integer $pagetotal */
public $pagetotal = 0; public $pagetotal = 0;
/** @var string[] $toolbars */ /** @var tool[] $toolbars */
public $toolbars = array(); public $toolbars = array();
/** @var axis[] $toolbars */
public $axis = array();
/** /**
* Constructor * Constructor
...@@ -71,7 +74,7 @@ class assignfeedback_editpdfplus_widget implements renderable { ...@@ -71,7 +74,7 @@ class assignfeedback_editpdfplus_widget implements renderable {
* @param bool $readonly - Show the readonly interface (no tools). * @param bool $readonly - Show the readonly interface (no tools).
* @param integer $pagetotal - The total number of pages. * @param integer $pagetotal - The total number of pages.
*/ */
public function __construct($assignment, $userid, $attemptnumber, $downloadurl, $downloadfilename, $stampfiles, $readonly, $pagetotal, $toolbars) { public function __construct($assignment, $userid, $attemptnumber, $downloadurl, $downloadfilename, $stampfiles, $readonly, $pagetotal, $toolbars, $axis) {
$this->assignment = $assignment; $this->assignment = $assignment;
$this->userid = $userid; $this->userid = $userid;
$this->attemptnumber = $attemptnumber; $this->attemptnumber = $attemptnumber;
...@@ -81,6 +84,7 @@ class assignfeedback_editpdfplus_widget implements renderable { ...@@ -81,6 +84,7 @@ class assignfeedback_editpdfplus_widget implements renderable {
$this->readonly = $readonly; $this->readonly = $readonly;
$this->pagetotal = $pagetotal; $this->pagetotal = $pagetotal;
$this->toolbars = $toolbars; $this->toolbars = $toolbars;
$this->axis = $axis;
} }
} }
...@@ -99,5 +99,6 @@ $string['tool'] = 'Tool'; ...@@ -99,5 +99,6 @@ $string['tool'] = 'Tool';
$string['viewfeedbackonline'] = 'View annotated PDF...'; $string['viewfeedbackonline'] = 'View annotated PDF...';
$string['white'] = 'White'; $string['white'] = 'White';
$string['yellow'] = 'Yellow'; $string['yellow'] = 'Yellow';
$string['yellowlemon'] = 'Lemon yellow';
$string['draftchangessaved'] = 'Draft annotations saved'; $string['draftchangessaved'] = 'Draft annotations saved';
$string['preparesubmissionsforannotation'] = 'Prepare submissions for annotation'; $string['preparesubmissionsforannotation'] = 'Prepare submissions for annotation';
...@@ -84,12 +84,6 @@ class assign_feedback_editpdfplus extends assign_feedback_plugin { ...@@ -84,12 +84,6 @@ class assign_feedback_editpdfplus extends assign_feedback_plugin {
} }
} }
} }
/*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. // Copy any new stamps to this instance.
if ($files = $fs->get_area_files($syscontext->id, 'assignfeedback_editpdfplus', 'stamps', 0, "filename", false)) { if ($files = $fs->get_area_files($syscontext->id, 'assignfeedback_editpdfplus', 'stamps', 0, "filename", false)) {
foreach ($files as $file) { foreach ($files as $file) {
...@@ -128,7 +122,7 @@ class assign_feedback_editpdfplus extends assign_feedback_plugin { ...@@ -128,7 +122,7 @@ class assign_feedback_editpdfplus extends assign_feedback_plugin {
// Retrieve total number of pages. // Retrieve total number of pages.
$pagetotal = document_services::page_number_for_attempt($this->assignment->get_instance()->id, $userid, $attempt, $readonly); $pagetotal = document_services::page_number_for_attempt($this->assignment->get_instance()->id, $userid, $attempt, $readonly);
$widget = new assignfeedback_editpdfplus_widget($this->assignment->get_instance()->id, $userid, $attempt, $url, $filename, $stampfiles, $readonly, $pagetotal, $toolbars); $widget = new assignfeedback_editpdfplus_widget($this->assignment->get_instance()->id, $userid, $attempt, $url, $filename, $stampfiles, $readonly, $pagetotal, $toolbars, $axis);
return $widget; return $widget;
} }
......
...@@ -5765,7 +5765,7 @@ EDITOR.prototype = { ...@@ -5765,7 +5765,7 @@ EDITOR.prototype = {
* @method all_pages_loaded * @method all_pages_loaded
*/ */
all_pages_loaded: function (responsetext) { all_pages_loaded: function (responsetext) {
var data, i, j, k, comment, error; var data, i, j, comment, error;
try { try {
data = Y.JSON.parse(responsetext); data = Y.JSON.parse(responsetext);
if (data.error || !data.pagecount) { if (data.error || !data.pagecount) {
...@@ -5803,6 +5803,13 @@ EDITOR.prototype = { ...@@ -5803,6 +5803,13 @@ EDITOR.prototype = {
this.typetools[typetooltmp.id] = typetooltmp; this.typetools[typetooltmp.id] = typetooltmp;
} }
this.axis = [];
for (i = 0; i < data.axis.length; i++) {
var axistmp = data.axis[i];
axistmp.visibility = true;
this.axis[axistmp.id] = axistmp;
}
for (i = 0; i < this.pages.length; i++) { for (i = 0; i < this.pages.length; i++) {
for (j = 0; j < this.pages[i].comments.length; j++) { for (j = 0; j < this.pages[i].comments.length; j++) {
comment = this.pages[i].comments[j]; comment = this.pages[i].comments[j];
...@@ -5861,6 +5868,10 @@ EDITOR.prototype = { ...@@ -5861,6 +5868,10 @@ EDITOR.prototype = {
return fullurl; return fullurl;
}, },
handle_axis_button: function (edit, axis, axe) {
axis.visibility = axe.get('checked');
this.redraw();
},
/** /**
* Attach listeners and enable the color picker buttons. * Attach listeners and enable the color picker buttons.
* @protected * @protected
...@@ -5872,6 +5883,13 @@ EDITOR.prototype = { ...@@ -5872,6 +5883,13 @@ EDITOR.prototype = {
picker; picker;
if (this.get('readonly')) { if (this.get('readonly')) {
// Setup the tool buttons.
for (var i = 1; i < this.axis.length; i++) {
var axis = this.axis[i];
var axe = this.get_dialogue_element('#ctaxis' + axis.id);
axe.set('checked', 'true');
axe.on('click', this.handle_axis_button, this, axis, axe);
}
return; return;
} }
...@@ -6458,8 +6476,12 @@ EDITOR.prototype = { ...@@ -6458,8 +6476,12 @@ EDITOR.prototype = {
} }
for (i = 0; i < page.annotations.length; i++) { for (i = 0; i < page.annotations.length; i++) {
this.drawables.push(page.annotations[i].draw()); var annot = page.annotations[i];
this.drawablesannotations.push(page.annotations[i]); var tool = annot.tooltype;
if (this.get('readonly') && tool.axis && this.axis[tool.axis] && this.axis[tool.axis].visibility || !this.get('readonly')) {
this.drawables.push(annot.draw());
this.drawablesannotations.push(annot);
}
} }
for (i = 0; i < page.comments.length; i++) { for (i = 0; i < page.comments.length; i++) {
this.drawables.push(page.comments[i].draw(false)); this.drawables.push(page.comments[i].draw(false));
......
...@@ -5761,7 +5761,7 @@ EDITOR.prototype = { ...@@ -5761,7 +5761,7 @@ EDITOR.prototype = {
* @method all_pages_loaded * @method all_pages_loaded
*/ */
all_pages_loaded: function (responsetext) { all_pages_loaded: function (responsetext) {
var data, i, j, k, comment, error; var data, i, j, comment, error;
try { try {
data = Y.JSON.parse(responsetext); data = Y.JSON.parse(responsetext);
if (data.error || !data.pagecount) { if (data.error || !data.pagecount) {
...@@ -5799,6 +5799,13 @@ EDITOR.prototype = { ...@@ -5799,6 +5799,13 @@ EDITOR.prototype = {
this.typetools[typetooltmp.id] = typetooltmp; this.typetools[typetooltmp.id] = typetooltmp;
} }
this.axis = [];
for (i = 0; i < data.axis.length; i++) {
var axistmp = data.axis[i];
axistmp.visibility = true;
this.axis[axistmp.id] = axistmp;
}
for (i = 0; i < this.pages.length; i++) { for (i = 0; i < this.pages.length; i++) {
for (j = 0; j < this.pages[i].comments.length; j++) { for (j = 0; j < this.pages[i].comments.length; j++) {
comment = this.pages[i].comments[j]; comment = this.pages[i].comments[j];
...@@ -5857,6 +5864,10 @@ EDITOR.prototype = { ...@@ -5857,6 +5864,10 @@ EDITOR.prototype = {
return fullurl; return fullurl;
}, },
handle_axis_button: function (edit, axis, axe) {
axis.visibility = axe.get('checked');
this.redraw();
},
/** /**
* Attach listeners and enable the color picker buttons. * Attach listeners and enable the color picker buttons.
* @protected * @protected
...@@ -5868,6 +5879,13 @@ EDITOR.prototype = { ...@@ -5868,6 +5879,13 @@ EDITOR.prototype = {
picker; picker;
if (this.get('readonly')) { if (this.get('readonly')) {
// Setup the tool buttons.
for (var i = 1; i < this.axis.length; i++) {
var axis = this.axis[i];
var axe = this.get_dialogue_element('#ctaxis' + axis.id);
axe.set('checked', 'true');
axe.on('click', this.handle_axis_button, this, axis, axe);
}
return; return;
} }
...@@ -6451,8 +6469,12 @@ EDITOR.prototype = { ...@@ -6451,8 +6469,12 @@ EDITOR.prototype = {
} }
for (i = 0; i < page.annotations.length; i++) { for (i = 0; i < page.annotations.length; i++) {
this.drawables.push(page.annotations[i].draw()); var annot = page.annotations[i];
this.drawablesannotations.push(page.annotations[i]); var tool = annot.tooltype;
if (this.get('readonly') && tool.axis && this.axis[tool.axis] && this.axis[tool.axis].visibility || !this.get('readonly')) {
this.drawables.push(annot.draw());
this.drawablesannotations.push(annot);
}
} }
for (i = 0; i < page.comments.length; i++) { for (i = 0; i < page.comments.length; i++) {
this.drawables.push(page.comments[i].draw(false)); this.drawables.push(page.comments[i].draw(false));
......
...@@ -476,7 +476,7 @@ EDITOR.prototype = { ...@@ -476,7 +476,7 @@ EDITOR.prototype = {
* @method all_pages_loaded * @method all_pages_loaded
*/ */
all_pages_loaded: function (responsetext) { all_pages_loaded: function (responsetext) {
var data, i, j, k, comment, error; var data, i, j, comment, error;
try { try {
data = Y.JSON.parse(responsetext); data = Y.JSON.parse(responsetext);
if (data.error || !data.pagecount) { if (data.error || !data.pagecount) {
...@@ -514,6 +514,13 @@ EDITOR.prototype = { ...@@ -514,6 +514,13 @@ EDITOR.prototype = {
this.typetools[typetooltmp.id] = typetooltmp; this.typetools[typetooltmp.id] = typetooltmp;
} }
this.axis = [];
for (i = 0; i < data.axis.length; i++) {
var axistmp = data.axis[i];
axistmp.visibility = true;
this.axis[axistmp.id] = axistmp;
}
for (i = 0; i < this.pages.length; i++) { for (i = 0; i < this.pages.length; i++) {
for (j = 0; j < this.pages[i].comments.length; j++) { for (j = 0; j < this.pages[i].comments.length; j++) {
comment = this.pages[i].comments[j]; comment = this.pages[i].comments[j];
...@@ -572,6 +579,10 @@ EDITOR.prototype = { ...@@ -572,6 +579,10 @@ EDITOR.prototype = {
return fullurl; return fullurl;
}, },
handle_axis_button: function (edit, axis, axe) {
axis.visibility = axe.get('checked');
this.redraw();
},
/** /**
* Attach listeners and enable the color picker buttons. * Attach listeners and enable the color picker buttons.
* @protected * @protected
...@@ -583,6 +594,13 @@ EDITOR.prototype = { ...@@ -583,6 +594,13 @@ EDITOR.prototype = {
picker; picker;
if (this.get('readonly')) { if (this.get('readonly')) {
// Setup the tool buttons.
for (var i = 1; i < this.axis.length; i++) {
var axis = this.axis[i];
var axe = this.get_dialogue_element('#ctaxis' + axis.id);
axe.set('checked', 'true');
axe.on('click', this.handle_axis_button, this, axis, axe);
}
return; return;
} }
...@@ -1169,8 +1187,12 @@ EDITOR.prototype = { ...@@ -1169,8 +1187,12 @@ EDITOR.prototype = {
} }
for (i = 0; i < page.annotations.length; i++) { for (i = 0; i < page.annotations.length; i++) {
this.drawables.push(page.annotations[i].draw()); var annot = page.annotations[i];
this.drawablesannotations.push(page.annotations[i]); var tool = annot.tooltype;
if (this.get('readonly') && tool.axis && this.axis[tool.axis] && this.axis[tool.axis].visibility || !this.get('readonly')) {
this.drawables.push(annot.draw());
this.drawablesannotations.push(annot);
}
} }
for (i = 0; i < page.comments.length; i++) { for (i = 0; i < page.comments.length; i++) {
this.drawables.push(page.comments[i].draw(false)); this.drawables.push(page.comments[i].draw(false));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment