Gitlab CSE Unil

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

correct moodle analyse issues

parent 494ac893
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
......@@ -31,7 +30,7 @@ namespace assignfeedback_editpdfplus\bdd;
* @author kury
*/
class axis {
/** @var int unique id for this annotation */
public $id = 0;
......@@ -41,7 +40,7 @@ class axis {
/** @var int axis for this annotation */
public $label = '';
/** @var int order in toolbar */
/** @var int order in toolbar */
public $order_axis = 1000;
/**
......@@ -62,5 +61,5 @@ class axis {
}
}
}
}
<?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/>.
/**
* This file contains the comment class for the assignfeedback_editpdfplus plugin
*
* @package assignfeedback_editpdfplus
* @copyright 2016 Université de Lausanne
* The code is based on mod/assign/feedback/editpdf/classes/comment.php by Davo Smith.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since version 2017051600
*/
namespace assignfeedback_editpdfplus\bdd;
/**
* @deprecated since version 2016101700
*/
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;
}
}
}
}
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
......@@ -121,7 +120,7 @@ class tool {
* Get text proposals and transform it into an array
* @return \assignfeedback_editpdfplus\stdClass
*/
public function initToolTextsArray() {
public function init_tool_texts_array() {
if (!$this->texts) {
$this->textsarray = null;
} else {
......@@ -152,16 +151,16 @@ class tool {
/**
* Set Style and replace label with format symbol for display purpose
*/
public function setDesign() {
$this->label = $this->getButtonLabel();
$this->style = $this->getStyleButton();
public function set_design() {
$this->label = $this->get_button_label();
$this->style = $this->get_style_button();
}
/**
* Calculate a label with format symbol, according to its type
* @return string
*/
private function getButtonLabel() {
private function get_button_label() {
if ($this->type == "4") {
return '| ' . $this->label . ' |';
}
......@@ -175,15 +174,15 @@ class tool {
* Calculate a sytle for a display in a button, according to its type
* @return string
*/
private function getStyleButton() {
$styleTmp = "";
private function get_style_button() {
$style_tmp = "";
if ($this->enabled == "0") {
$styleTmp .= "background-image:none;background-color:#CCCCCC;";
$style_tmp .= "background-image:none;background-color:#CCCCCC;";
}
if ($this->type == "4" || $this->type == "1") {
$styleTmp .= "text-decoration: underline;";
$style_tmp .= "text-decoration: underline;";
}
return $styleTmp;
return $style_tmp;
}
/**
......@@ -191,8 +190,8 @@ class tool {
* @param bool $disabled if the button must be disabled
* @return array
*/
public function getRendererBoutonHTMLDisplay($disabled = false) {
$iconhtml = $this->getButtonLabel();
public function get_renderer_bouton_html_display($disabled = false) {
$iconhtml = $this->get_button_label();
$tooltiptext = get_string('typetool_' . $this->typeObject->label, 'assignfeedback_editpdfplus');
$iconhtml .= "<span class='assignfeedback_editpdfplus_tooltiptext'>" . $tooltiptext . "</span>";
if (!$this->typeObject) {
......@@ -206,7 +205,7 @@ class tool {
'class' => $this->typeObject->label . ' costumtoolbarbutton btn btn-light',
'id' => 'ctbutton' . $this->id,
'type' => 'button',
'style' => $this->getStyleButton());
'style' => $this->get_style_button());
if ($disabled) {
$iconparams['disabled'] = 'true';
}
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
......@@ -51,7 +50,7 @@ class tool_generic extends tool {
* @param bool $disabled if the button must be disabled
* @return array
*/
public function getRendererBoutonHTMLDisplay($disabled = false) {
public function get_renderer_bouton_html_display($disabled = false) {
$iconhtml = \html_writer::tag("i", "", array('class' => self::DISPLAY_CLASS_BUTTON[$this->label], 'aria-hidden' => 'true'));
$iconparams = array(
'data-tool' => $this->label,
......
......@@ -94,7 +94,7 @@ class type_tool {
* Init color of the type tool, and control the value before affected it (null, size...)
* @param string $color
*/
public function setColor($color) {
public function set_color($color) {
if (isset($color) && strlen($color) > 4) {
$this->color = $color;
}
......@@ -102,31 +102,31 @@ class type_tool {
/**
* Init cartridge color of the type tool, and control the value before affected it (null, size...)
* @param string $cartridge_color
* @param string $cartridgecolor
*/
public function setCartridgeColor($cartridge_color) {
if (isset($cartridge_color) && strlen($cartridge_color) > 4) {
$this->cartridge_color = $cartridge_color;
public function set_cartridge_color($cartridgecolor) {
if (isset($cartridgecolor) && strlen($cartridgecolor) > 4) {
$this->cartridge_color = $cartridgecolor;
}
}
/**
* Init the cartridge X position of the type tool, and control the value before affected it (null, intval...)
* @param string $cartridge_x
* @param string $cartridgex
*/
public function setCartridgeX($cartridge_x) {
if (isset($cartridge_x) && intval($cartridge_x)) {
$this->cartridge_x = intval($cartridge_x);
public function set_cartridge_x($cartridgex) {
if (isset($cartridgex) && intval($cartridgex)) {
$this->cartridge_x = intval($cartridgex);
}
}
/**
* Init the cartridge Y position of the type tool, and control the value before affected it (null, intval...)
* @param string $cartridge_y
* @param string $cartridgey
*/
public function setCartridgeY($cartridge_y) {
if (isset($cartridge_y) && intval($cartridge_y)) {
$this->cartridge_y = intval($cartridge_y);
public function set_cartridge_y($cartridgey) {
if (isset($cartridgey) && intval($cartridgey)) {
$this->cartridge_y = intval($cartridgey);
}
}
......
......@@ -521,38 +521,38 @@ class page_editor {
global $CFG;
switch ($newToolType->label) {
case 'highlightplus':
$newToolType->setColor($CFG->highlightplus_color);
$newToolType->setCartridgeColor($CFG->highlightplus_cartridge_color);
$newToolType->setCartridgeX($CFG->highlightplus_cartridge_x);
$newToolType->setCartridgeY($CFG->highlightplus_cartridge_y);
$newToolType->set_color($CFG->highlightplus_color);
$newToolType->set_cartridge_color($CFG->highlightplus_cartridge_color);
$newToolType->set_cartridge_x($CFG->highlightplus_cartridge_x);
$newToolType->set_cartridge_y($CFG->highlightplus_cartridge_y);
break;
case 'stampplus':
$newToolType->setColor($CFG->stampplus_color);
$newToolType->set_color($CFG->stampplus_color);
break;
case 'frame':
$newToolType->setCartridgeX($CFG->frame_cartridge_x);
$newToolType->setCartridgeY($CFG->frame_cartridge_y);
$newToolType->set_cartridge_x($CFG->frame_cartridge_x);
$newToolType->set_cartridge_y($CFG->frame_cartridge_y);
break;
case 'verticalline':
$newToolType->setColor($CFG->verticalline_color);
$newToolType->setCartridgeColor($CFG->verticalline_cartridge_color);
$newToolType->setCartridgeX($CFG->verticalline_cartridge_x);
$newToolType->setCartridgeY($CFG->verticalline_cartridge_y);
$newToolType->set_color($CFG->verticalline_color);
$newToolType->set_cartridge_color($CFG->verticalline_cartridge_color);
$newToolType->set_cartridge_x($CFG->verticalline_cartridge_x);
$newToolType->set_cartridge_y($CFG->verticalline_cartridge_y);
break;
case 'stampcomment':
$newToolType->setCartridgeColor($CFG->stampcomment_cartridge_color);
$newToolType->setCartridgeX($CFG->stampcomment_cartridge_x);
$newToolType->setCartridgeY($CFG->stampcomment_cartridge_y);
$newToolType->set_cartridge_color($CFG->stampcomment_cartridge_color);
$newToolType->set_cartridge_x($CFG->stampcomment_cartridge_x);
$newToolType->set_cartridge_y($CFG->stampcomment_cartridge_y);
break;
case 'commentplus':
$newToolType->setCartridgeColor($CFG->commentplus_cartridge_color);
$newToolType->setCartridgeX($CFG->commentplus_cartridge_x);
$newToolType->setCartridgeY($CFG->commentplus_cartridge_y);
$newToolType->set_cartridge_color($CFG->commentplus_cartridge_color);
$newToolType->set_cartridge_x($CFG->commentplus_cartridge_x);
$newToolType->set_cartridge_y($CFG->commentplus_cartridge_y);
break;
default:
......
......@@ -49,7 +49,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
* @return string
*/
private function render_toolbar_button_tool(assignfeedback_editpdfplus\bdd\tool $fulltool, $disabled = false) {
$displayArray = $fulltool->getRendererBoutonHTMLDisplay($disabled);
$displayArray = $fulltool->get_renderer_bouton_html_display($disabled);
return $this->render_toolbar_button_html($displayArray["content"], $displayArray["parameters"]);
}
......
......@@ -478,7 +478,7 @@ class assignfeedback_editpdfplus_external extends external_api {
$toolsNew = admin_editor::get_tools_by_axis($axeNew);
if (sizeof($toolsNew) > 0) {
foreach ($toolsNew as $tool) {
$tool->setDesign();
$tool->set_design();
$res[] = array('modelid' => $model, self::AXEID => $axeNew, self::AXELIB => $validateddata->label, self::MESSAGELIB => "", self::ENABLETOOL => $tool->enabled, self::TOOLID => $tool->id, self::TOOLTYPE => $tool->type, self::BOUTONLIBTOOL => $tool->label, 'style' => $tool->style);
}
} else {
......
......@@ -185,7 +185,7 @@ class assign_feedback_editpdfplus_admin {
} else {
$tool->init(array("contextid" => $this->context->id, "axisid" => $axisid));
}
$tool->initToolTextsArray();
$tool->init_tool_texts_array();
$data->tool = $tool;
$data->tools = admin_editor::get_typetools();
foreach ($data->tools as $toolRef) {
......@@ -224,7 +224,7 @@ class assign_feedback_editpdfplus_admin {
}
$tooltmp = page_editor::get_tools_by_axis($model->axis);
foreach ($tooltmp as $tool) {
$tool->setDesign();
$tool->set_design();
}
$tmp = new stdClass();
$tmp->model = $model;
......@@ -260,7 +260,7 @@ class assign_feedback_editpdfplus_admin {
$nbannotation = admin_editor::getNbAnnotationsForTool($tool->id);
$ax->canbedelete &= $nbannotation == 0;
}
$tool->setDesign();
$tool->set_design();
$toolbar->tools[] = $tool;
$ax->children++;
}
......
Markdown is supported
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