Gitlab CSE Unil

Commit 0945bd1e authored by M. Chardon's avatar M. Chardon
Browse files

affochage des bars d'outils dispo

parent ba66ae6e
This diff is collapsed.
...@@ -145,6 +145,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f ...@@ -145,6 +145,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
} }
currentTool.order = $("#order").val(); currentTool.order = $("#order").val();
initCanevas(); initCanevas();
initToolDisplay();
}; };
// //
var getTypeTool = function (toolid) { var getTypeTool = function (toolid) {
...@@ -384,6 +385,16 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f ...@@ -384,6 +385,16 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
currentTool.enabled = $("#enabled").val(); currentTool.enabled = $("#enabled").val();
currentTool.reply = $("#reply").val(); currentTool.reply = $("#reply").val();
currentTool.order = $("#order").val(); currentTool.order = $("#order").val();
$("#typetool").on("change", function () {
currentTool.typetool = $("#typetool").val();
var typetoolEntity = getTypeTool(currentTool.typetool);
currentTool.color = typetoolEntity.color;
currentTool.catridgecolor = typetoolEntity.cartridge_color;
$("#color").val(currentTool.color);
$("#cartridgecolor").val(currentTool.catridgecolor);
initToolDisplay();
initCanevas();
});
$("#toolFormSubmit").on("click", function () { $("#toolFormSubmit").on("click", function () {
var res = ""; var res = "";
$("input[name^='text[']").each(function () { $("input[name^='text[']").each(function () {
...@@ -592,6 +603,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f ...@@ -592,6 +603,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
currentTool.catridgecolor = typetoolEntity.cartridge_color; currentTool.catridgecolor = typetoolEntity.cartridge_color;
$("#color").val(currentTool.color); $("#color").val(currentTool.color);
$("#cartridgecolor").val(currentTool.catridgecolor); $("#cartridgecolor").val(currentTool.catridgecolor);
initToolDisplay();
}); });
$("#typetool").change(); $("#typetool").change();
} }
......
...@@ -59,13 +59,14 @@ class widget_admin implements renderable, templatable { ...@@ -59,13 +59,14 @@ class widget_admin implements renderable, templatable {
* @param tool[] $toolbars - the different tool to display * @param tool[] $toolbars - the different tool to display
* @param axis[] $axis - the different axis to display * @param axis[] $axis - the different axis to display
*/ */
public function __construct($context, $course, $userid, $toolbars, $axis, $typetools) { public function __construct($context, $course, $userid, $toolbars, $axis, $typetools, $toolbarsDispo) {
$this->context = $context; $this->context = $context;
$this->course = $course; $this->course = $course;
$this->userid = $userid; $this->userid = $userid;
$this->toolbars = $toolbars; $this->toolbars = $toolbars;
$this->axis = $axis; $this->axis = $axis;
$this->toollibs = json_encode($typetools); $this->toollibs = json_encode($typetools);
$this->toolbarsDispo = $toolbarsDispo;
} }
public function export_for_template(\renderer_base $output) { public function export_for_template(\renderer_base $output) {
......
...@@ -28,7 +28,6 @@ use \assignfeedback_editpdfplus\page_editor; ...@@ -28,7 +28,6 @@ use \assignfeedback_editpdfplus\page_editor;
use \assignfeedback_editpdfplus\widget_admin; use \assignfeedback_editpdfplus\widget_admin;
use \assignfeedback_editpdfplus\form\axis_form; use \assignfeedback_editpdfplus\form\axis_form;
use \assignfeedback_editpdfplus\form\axis_del_form; use \assignfeedback_editpdfplus\form\axis_del_form;
use \assignfeedback_editpdfplus\form\tool_form;
use \assignfeedback_editpdfplus\admin_editor; use \assignfeedback_editpdfplus\admin_editor;
class assign_feedback_editpdfplus_admin { class assign_feedback_editpdfplus_admin {
...@@ -162,7 +161,7 @@ class assign_feedback_editpdfplus_admin { ...@@ -162,7 +161,7 @@ class assign_feedback_editpdfplus_admin {
$obj->text = substr($obj->text, 1); $obj->text = substr($obj->text, 1);
} }
if (substr($obj->text, -1) == '"') { if (substr($obj->text, -1) == '"') {
$obj->text = substr($obj->text,0, -1); $obj->text = substr($obj->text, 0, -1);
} }
$obj->index = $compteur; $obj->index = $compteur;
$data->tool->textsarray[] = $obj; $data->tool->textsarray[] = $obj;
...@@ -186,12 +185,39 @@ class assign_feedback_editpdfplus_admin { ...@@ -186,12 +185,39 @@ class assign_feedback_editpdfplus_admin {
global $USER; global $USER;
// get the costum toolbars // get the costum toolbars
$toolbars = array();
$coursecontext = context::instance_by_id($this->context->id); $coursecontext = context::instance_by_id($this->context->id);
$coursecontexts = array_filter(explode('/', $coursecontext->path), 'strlen'); $coursecontexts = array_filter(explode('/', $coursecontext->path), 'strlen');
$tools = page_editor::get_tools($coursecontexts); $tools = page_editor::get_tools($coursecontexts);
$typetools = page_editor::get_typetools(null); $typetools = page_editor::get_typetools(null);
$axis = page_editor::get_axis(array($this->context->id)); $axis = page_editor::get_axis(array($this->context->id));
$toolbars = $this->prepareToolbar($axis, $tools);
// get all accessibled toolbars
$courses = get_courses();
$contextListToCheck = array();
foreach ($courses as $course) {
$contextid = context_course::instance($course->id);
$coursecontextsTmp = array_filter(explode('/', $contextid->path), 'strlen');
foreach ($coursecontextsTmp as $value) {
if ($value != $this->context->id && !in_array($value, $contextListToCheck)) {
$contextListToCheck[] = $value;
}
}
}
$axisDispo = array();
$toolDispo = page_editor::get_tools($contextListToCheck);
foreach ($contextListToCheck as $value) {
$axistmp = page_editor::get_axis(array($value));
if ($axistmp && sizeof($axistmp) > 0) {
$axisDispo = array_merge($axisDispo, $axistmp);
}
}
$toolbarsDispo = $this->prepareToolbar($axisDispo, $toolDispo);
$widget = new widget_admin($this->context, $this->course, $USER, $toolbars, $axis, $typetools, $toolbarsDispo);
return $widget;
}
private function prepareToolbar($axis, $tools) {
$toolbars = array();
foreach ($axis as $ax) { foreach ($axis as $ax) {
$ax->children = 0; $ax->children = 0;
$toolbar = new stdClass(); $toolbar = new stdClass();
...@@ -219,8 +245,7 @@ class assign_feedback_editpdfplus_admin { ...@@ -219,8 +245,7 @@ class assign_feedback_editpdfplus_admin {
} }
$toolbars[] = $toolbar; $toolbars[] = $toolbar;
} }
$widget = new widget_admin($this->context, $this->course, $USER, $toolbars, $axis, $typetools); return $toolbars;
return $widget;
} }
} }
...@@ -5,6 +5,41 @@ ...@@ -5,6 +5,41 @@
<div class="assignfeedback_editpdfplus_widget_admin"> <div class="assignfeedback_editpdfplus_widget_admin">
<h5>{{# str }} adminsubtitle, assignfeedback_editpdfplus {{/ str }}</h5> <h5>{{# str }} adminsubtitle, assignfeedback_editpdfplus {{/ str }}</h5>
<div class="panel panel-default">
<div class="panel-heading">
Importation axe
</div>
<div class="panel-body">
Axes disponibles à l'importation
<table class='table table-bordered table-striped'>
<thead>
<tr>
<!--th>Cours / activité</th-->
<th>Nom</th>
<th>Outils</th>
<th>Importer</th>
</tr>
</thead>
<tbody>
{{# toolbarsDispo }}
<tr>
<!--td></td-->
<td>{{axis.label}}</td>
<td>
{{# tools }}
<button class="btn btn-default" style="{{style}}">
{{label}}
</button>
{{/ tools }}
</td>
<td><button class='btn btn-primary btn-sm' class='btnimport' data-axis='{{axis.id}}'><i class='fa fa-download'></i></button></td>
</tr>
{{/ toolbarsDispo }}
</tbody>
</table>
</div>
</div>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
{{# str }} admincurrenttoolbar, assignfeedback_editpdfplus {{/ str }} {{# str }} admincurrenttoolbar, assignfeedback_editpdfplus {{/ str }}
...@@ -62,7 +97,7 @@ ...@@ -62,7 +97,7 @@
<div class="alert col-sm-5" id="message_edit_tool" style="margin-top: 10px;margin-bottom: 0px;display: none;"></div> <div class="alert col-sm-5" id="message_edit_tool" style="margin-top: 10px;margin-bottom: 0px;display: none;"></div>
<div id="editpdlplus_tool_item" class="alert col-sm-12" style="margin-top: 0px;"></div> <div id="editpdlplus_tool_item" class="alert col-sm-12" style="margin-top: 0px;"></div>
</div> </div>
<div class='col-sm-10'> <div class='col-sm-10'>
<div id="assignfeedback_editpdfplus_widget_admin_div_addaxis" style="display:none;"> <div id="assignfeedback_editpdfplus_widget_admin_div_addaxis" style="display:none;">
......
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