Gitlab CSE Unil
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
M. Chardon
moodle-assignfeedback_editpdfplus
Commits
3b7a0879
Commit
3b7a0879
authored
Jun 25, 2017
by
M. Chardon
Browse files
outil modification
parent
f45584a8
Changes
13
Hide whitespace changes
Inline
Side-by-side
amd/build/admin_panel.min.js
View file @
3b7a0879
define
([
"
jquery
"
,
"
core/notification
"
,
"
core/templates
"
,
"
core/fragment
"
],
function
(
a
,
b
,
c
,
d
){
var
e
=
null
,
f
=
function
(
a
){
this
.
init
(),
e
=
a
};
return
f
.
prototype
.
selectTool
=
null
,
f
.
prototype
.
init
=
function
(){
a
(
"
#editpdlplus_axes
"
).
on
(
"
change
"
,
function
(){
a
(
"
.toolbar
"
).
hide
();
var
b
=
a
(
"
#editpdlplus_axes
"
).
val
();
a
(
"
#editpdlplus_toolbar_
"
+
b
).
show
();
var
c
=
a
(
"
#editpdlplus_axes option:selected
"
).
data
(
"
delete
"
);
c
&&
parseInt
(
c
)
>
0
?
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_delaxis
"
).
addClass
(
"
disabled
"
):
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_delaxis
"
).
removeClass
(
"
disabled
"
)}),
a
(
"
#editpdlplus_axes
"
).
change
(),
a
(
"
.editpdlplus_tool
"
).
on
(
"
click
"
,
function
(){
var
b
=
a
(
this
).
val
();
a
(
"
.editpdlplus_tool
"
).
each
(
function
(){
a
(
this
).
removeClass
(
"
btn-primary
"
),
a
(
this
).
removeClass
(
"
btn-default
"
);
var
c
=
a
(
this
).
data
(
"
enable
"
);
1
===
c
&&
a
(
this
).
val
()
!==
b
&&
a
(
this
).
addClass
(
"
btn-default
"
)}),
a
(
this
).
addClass
(
"
btn-primary
"
)}),
this
.
selectTool
=
a
(
"
.editpdlplus_tool
"
).
first
(),
this
.
initTool
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_addaxis
"
).
on
(
"
click
"
,
this
.
openDivAddAxis
),
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_editaxis
"
).
on
(
"
click
"
,
this
.
openDivEditAxis
),
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_delaxis
"
).
on
(
"
click
"
,
this
.
openDivDelAxis
)},
f
.
prototype
.
initTool
=
function
(){
a
(
this
.
selectTool
).
removeClass
(
"
btn-default
"
),
a
(
this
.
selectTool
).
addClass
(
"
btn-primary
"
)},
f
.
prototype
.
openDivAddAxis
=
function
(){
a
(
"
#axistool
"
).
hide
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_addaxis
"
).
show
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body
"
).
html
(
""
);
var
f
=
{};
d
.
loadFragment
(
"
assignfeedback_editpdfplus
"
,
"
axisadd
"
,
e
,
f
).
done
(
function
(
a
,
b
){
c
.
appendNodeContents
(
"
#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body
"
,
a
,
b
)}.
bind
(
this
)).
fail
(
b
.
exception
)},
f
.
prototype
.
openDivEditAxis
=
function
(){
a
(
"
#axistool
"
).
hide
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_editaxis
"
).
show
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body
"
).
html
(
""
);
var
f
=
a
(
"
#editpdlplus_axes option:selected
"
).
val
(),
g
=
{
axeid
:
f
};
d
.
loadFragment
(
"
assignfeedback_editpdfplus
"
,
"
axisedit
"
,
e
,
g
).
done
(
function
(
a
,
b
){
c
.
appendNodeContents
(
"
#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body
"
,
a
,
b
)}.
bind
(
this
)).
fail
(
b
.
exception
)},
f
.
prototype
.
openDivDelAxis
=
function
(){
a
(
"
#axistool
"
).
hide
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_delaxis
"
).
show
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body
"
).
html
(
""
);
var
f
=
a
(
"
#editpdlplus_axes option:selected
"
).
val
(),
g
=
{
axeid
:
f
};
d
.
loadFragment
(
"
assignfeedback_editpdfplus
"
,
"
axisdel
"
,
e
,
g
).
done
(
function
(
a
,
b
){
c
.
appendNodeContents
(
"
#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body
"
,
a
,
b
)}.
bind
(
this
)).
fail
(
b
.
exception
)},
f
});
\ No newline at end of file
define
([
"
jquery
"
,
"
core/notification
"
,
"
core/templates
"
,
"
core/fragment
"
,
"
core/ajax
"
],
function
(
a
,
b
,
c
,
d
,
e
){
var
f
=
null
,
g
=
function
(
a
){
this
.
init
(),
f
=
a
};
g
.
prototype
.
selectTool
=
null
,
g
.
prototype
.
init
=
function
(){
a
(
"
#editpdlplus_axes
"
).
on
(
"
change
"
,
function
(){
a
(
"
.toolbar
"
).
hide
();
var
b
=
a
(
"
#editpdlplus_axes
"
).
val
();
a
(
"
#editpdlplus_toolbar_
"
+
b
).
show
();
var
c
=
a
(
"
#editpdlplus_axes option:selected
"
).
data
(
"
delete
"
);
c
&&
parseInt
(
c
)
>
0
?
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_delaxis
"
).
addClass
(
"
disabled
"
):
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_delaxis
"
).
removeClass
(
"
disabled
"
)}),
a
(
"
#editpdlplus_axes
"
).
change
(),
a
(
"
.editpdlplus_tool
"
).
on
(
"
click
"
,
i
),
this
.
selectTool
=
a
(
"
.editpdlplus_tool
"
).
first
(),
this
.
initTool
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_addaxis
"
).
on
(
"
click
"
,
this
.
openDivAddAxis
),
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_editaxis
"
).
on
(
"
click
"
,
this
.
openDivEditAxis
),
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_delaxis
"
).
on
(
"
click
"
,
this
.
openDivDelAxis
)},
g
.
prototype
.
test
=
function
(){
alert
(
"
test
"
),
i
()},
g
.
prototype
.
initTool
=
function
(){
a
(
this
.
selectTool
).
removeClass
(
"
btn-default
"
),
a
(
this
.
selectTool
).
addClass
(
"
btn-primary
"
)},
g
.
prototype
.
openDivAddAxis
=
function
(){
a
(
"
#axistool
"
).
hide
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_addaxis
"
).
show
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body
"
).
html
(
""
);
var
e
=
{};
d
.
loadFragment
(
"
assignfeedback_editpdfplus
"
,
"
axisadd
"
,
f
,
e
).
done
(
function
(
a
,
b
){
c
.
appendNodeContents
(
"
#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body
"
,
a
,
b
)}.
bind
(
this
)).
fail
(
b
.
exception
)},
g
.
prototype
.
openDivEditAxis
=
function
(){
a
(
"
#axistool
"
).
hide
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_editaxis
"
).
show
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body
"
).
html
(
""
);
var
e
=
a
(
"
#editpdlplus_axes option:selected
"
).
val
(),
g
=
{
axeid
:
e
};
d
.
loadFragment
(
"
assignfeedback_editpdfplus
"
,
"
axisedit
"
,
f
,
g
).
done
(
function
(
a
,
b
){
c
.
appendNodeContents
(
"
#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body
"
,
a
,
b
)}.
bind
(
this
)).
fail
(
b
.
exception
)},
g
.
prototype
.
openDivDelAxis
=
function
(){
a
(
"
#axistool
"
).
hide
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_delaxis
"
).
show
(),
a
(
"
#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body
"
).
html
(
""
);
var
e
=
a
(
"
#editpdlplus_axes option:selected
"
).
val
(),
g
=
{
axeid
:
e
};
d
.
loadFragment
(
"
assignfeedback_editpdfplus
"
,
"
axisdel
"
,
f
,
g
).
done
(
function
(
a
,
b
){
c
.
appendNodeContents
(
"
#assignfeedback_editpdfplus_widget_admin_div_delaxis > .panel-body
"
,
a
,
b
)}.
bind
(
this
)).
fail
(
b
.
exception
)};
var
h
=
function
(
b
,
d
,
e
){
var
f
=
a
.
Deferred
();
return
b
.
fadeOut
(
"
fast
"
,
function
(){
c
.
replaceNodeContents
(
b
,
d
,
e
),
b
.
fadeIn
(
"
fast
"
,
function
(){
f
.
resolve
()})}),
f
.
promise
()},
i
=
function
(){
var
c
=
a
(
this
).
val
();
a
(
"
.editpdlplus_tool
"
).
each
(
function
(){
a
(
this
).
removeClass
(
"
btn-primary
"
),
a
(
this
).
removeClass
(
"
btn-default
"
);
var
b
=
a
(
this
).
data
(
"
enable
"
);
1
===
b
&&
a
(
this
).
val
()
!==
c
&&
a
(
this
).
addClass
(
"
btn-default
"
)}),
a
(
this
).
addClass
(
"
btn-primary
"
),
a
(
"
#editpdlplus_tool_item
"
).
html
(
""
);
var
g
=
{
toolid
:
c
};
d
.
loadFragment
(
"
assignfeedback_editpdfplus
"
,
"
tooledit
"
,
f
,
g
).
done
(
function
(
c
,
d
){
h
(
a
(
"
#editpdlplus_tool_item
"
),
c
,
d
).
done
(
function
(){
a
(
"
#toolFormSubmit
"
).
on
(
"
click
"
,
function
(){
var
c
=
a
(
"
#assignfeedback_editpdfplus_edit_tool
"
),
d
=
c
.
serialize
();
e
.
call
([{
methodname
:
"
assignfeedback_editpdfplus_submit_tool_edit_form
"
,
args
:{
jsonformdata
:
JSON
.
stringify
(
d
)}}])[
0
].
done
(
function
(
b
){
if
(
""
===
b
[
0
].
message
){
a
(
"
#message_edit_tool
"
).
html
(
"
Modifications enregistrées
"
),
a
(
"
#message_edit_tool
"
).
addClass
(
"
alert-success
"
),
a
(
"
#message_edit_tool
"
).
removeClass
(
"
alert-danger
"
),
a
(
"
#editpdlplus_toolbar_
"
+
b
[
0
].
axeid
).
html
(
""
);
for
(
var
c
=
0
;
c
<
b
.
length
;
c
++
){
var
d
=
"
btn-default
"
;
1
!==
b
[
c
].
enable
&&
(
d
=
""
),
b
[
c
].
toolid
===
b
[
c
].
selecttool
&&
(
d
=
"
btn-primary
"
);
var
e
=
""
;
4
!==
b
[
c
].
typetool
&&
1
!==
b
[
c
].
typetool
||
(
e
=
"
text-decoration: underline;
"
);
var
f
=
b
[
c
].
button
;
4
!==
b
[
c
].
typetool
&&
5
!==
b
[
c
].
typetool
||
(
f
=
"
|
"
+
f
,
4
===
b
[
c
].
typetool
&&
(
f
+=
"
|
"
));
var
g
=
"
<button class='btn
"
+
d
+
"
editpdlplus_tool' id='editpdlplus_tool_
"
+
b
[
c
].
toolid
+
"
' style='
"
+
e
+
"
' value='
"
+
b
[
c
].
toolid
+
"
' data-enable='
"
+
b
[
c
].
enable
+
"
'>
"
+
f
+
"
</button>
"
;
a
(
"
#editpdlplus_toolbar_
"
+
b
[
0
].
axeid
).
append
(
g
)}
a
(
"
.editpdlplus_tool
"
).
on
(
"
click
"
,
i
)}
else
a
(
"
#message_edit_tool
"
).
html
(
b
[
0
].
message
),
a
(
"
#message_edit_tool
"
).
addClass
(
"
alert-danger
"
),
a
(
"
#message_edit_tool
"
).
removeClass
(
"
alert-success
"
)}).
fail
(
b
.
exception
)})}.
bind
(
this
)).
fail
(
b
.
exception
)}.
bind
(
this
)).
fail
(
b
.
exception
)};
return
g
});
\ No newline at end of file
amd/src/admin_panel.js
View file @
3b7a0879
...
...
@@ -20,12 +20,11 @@
/**
* @module mod_assignfeedback_editpdfplus/admin_panel
*/
define
([
'
jquery
'
/*, 'core/yui'*/
,
'
core/notification
'
,
'
core/templates
'
,
'
core/fragment
'
/*
,
'core/ajax', 'core/str', 'mod_assign/grading_form_change_checker'*/
],
function
(
$
/*, Y*/
,
notification
,
templates
,
fragment
/*
, ajax, str, checker*/
)
{
define
([
'
jquery
'
/*, 'core/yui'*/
,
'
core/notification
'
,
'
core/templates
'
,
'
core/fragment
'
,
'
core/ajax
'
/*
, 'core/str', 'mod_assign/grading_form_change_checker'*/
],
function
(
$
/*, Y*/
,
notification
,
templates
,
fragment
,
ajax
/*
, str, checker*/
)
{
var
contextid
=
null
;
/**
* AdminPanel class.
*
...
...
@@ -55,18 +54,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
});
$
(
"
#editpdlplus_axes
"
).
change
();
//
$
(
"
.editpdlplus_tool
"
).
on
(
"
click
"
,
function
()
{
var
selectid
=
$
(
this
).
val
();
$
(
"
.editpdlplus_tool
"
).
each
(
function
()
{
$
(
this
).
removeClass
(
"
btn-primary
"
);
$
(
this
).
removeClass
(
"
btn-default
"
);
var
enabled
=
$
(
this
).
data
(
'
enable
'
);
if
(
enabled
===
1
&&
$
(
this
).
val
()
!==
selectid
)
{
$
(
this
).
addClass
(
"
btn-default
"
);
}
});
$
(
this
).
addClass
(
"
btn-primary
"
);
});
$
(
"
.editpdlplus_tool
"
).
on
(
"
click
"
,
refreshToolView
);
this
.
selectTool
=
$
(
"
.editpdlplus_tool
"
).
first
();
this
.
initTool
();
$
(
"
#assignfeedback_editpdfplus_widget_admin_button_addaxis
"
).
on
(
"
click
"
,
this
.
openDivAddAxis
);
...
...
@@ -74,6 +62,11 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
$
(
"
#assignfeedback_editpdfplus_widget_admin_button_delaxis
"
).
on
(
"
click
"
,
this
.
openDivDelAxis
);
};
//
AdminPanel
.
prototype
.
test
=
function
()
{
alert
(
"
test
"
);
refreshToolView
();
};
//
AdminPanel
.
prototype
.
initTool
=
function
()
{
$
(
this
.
selectTool
).
removeClass
(
"
btn-default
"
);
$
(
this
.
selectTool
).
addClass
(
"
btn-primary
"
);
...
...
@@ -125,6 +118,111 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
html
,
js
);
}.
bind
(
this
)).
fail
(
notification
.
exception
);
};
/**
* Fade the dom node out, update it, and fade it back.
*
* @private
* @method _hello
* @param {JQuery} node
* @param {String} html
* @param {String} js
* @return {Deferred} promise resolved when the animations are complete.
*/
var
hello
=
function
(
node
,
html
,
js
)
{
//alert("tutu");
//alert(html+js);
var
promise
=
$
.
Deferred
();
node
.
fadeOut
(
"
fast
"
,
function
()
{
templates
.
replaceNodeContents
(
node
,
html
,
js
);
node
.
fadeIn
(
"
fast
"
,
function
()
{
promise
.
resolve
();
});
});
return
promise
.
promise
();
//return true;
};
//
var
refreshToolView
=
function
()
{
var
selectid
=
$
(
this
).
val
();
$
(
"
.editpdlplus_tool
"
).
each
(
function
()
{
$
(
this
).
removeClass
(
"
btn-primary
"
);
$
(
this
).
removeClass
(
"
btn-default
"
);
var
enabled
=
$
(
this
).
data
(
'
enable
'
);
if
(
enabled
===
1
&&
$
(
this
).
val
()
!==
selectid
)
{
$
(
this
).
addClass
(
"
btn-default
"
);
}
});
$
(
this
).
addClass
(
"
btn-primary
"
);
//load proprieties
$
(
'
#editpdlplus_tool_item
'
).
html
(
""
);
var
params
=
{
toolid
:
selectid
};
//this.test();
fragment
.
loadFragment
(
'
assignfeedback_editpdfplus
'
,
'
tooledit
'
,
contextid
,
params
)
.
done
(
function
(
html
,
js
)
{
hello
(
$
(
'
#editpdlplus_tool_item
'
),
html
,
js
)
.
done
(
function
()
{
$
(
"
#toolFormSubmit
"
).
on
(
"
click
"
,
function
()
{
var
form
=
$
(
'
#assignfeedback_editpdfplus_edit_tool
'
);
var
data
=
form
.
serialize
();
ajax
.
call
([
{
methodname
:
'
assignfeedback_editpdfplus_submit_tool_edit_form
'
,
args
:
{
jsonformdata
:
JSON
.
stringify
(
data
)}
}
])[
0
].
done
(
function
(
toolbar
)
{
if
(
toolbar
[
0
].
message
===
""
)
{
//mise à jour du message
$
(
"
#message_edit_tool
"
).
html
(
"
Modifications enregistrées
"
);
$
(
"
#message_edit_tool
"
).
addClass
(
"
alert-success
"
);
$
(
"
#message_edit_tool
"
).
removeClass
(
"
alert-danger
"
);
//mise à jour bar d'outils
$
(
"
#editpdlplus_toolbar_
"
+
toolbar
[
0
].
axeid
).
html
(
""
);
for
(
var
i
=
0
;
i
<
toolbar
.
length
;
i
++
)
{
var
classButton
=
"
btn-default
"
;
if
(
toolbar
[
i
].
enable
!==
1
)
{
classButton
=
""
;
}
if
(
toolbar
[
i
].
toolid
===
toolbar
[
i
].
selecttool
)
{
classButton
=
"
btn-primary
"
;
}
var
style
=
""
;
if
(
toolbar
[
i
].
typetool
===
4
||
toolbar
[
i
].
typetool
===
1
)
{
style
=
"
text-decoration: underline;
"
;
}
var
label
=
toolbar
[
i
].
button
;
if
(
toolbar
[
i
].
typetool
===
4
||
toolbar
[
i
].
typetool
===
5
)
{
label
=
"
|
"
+
label
;
if
(
toolbar
[
i
].
typetool
===
4
)
{
label
+=
"
|
"
;
}
}
var
buttonTmp
=
"
<button class='btn
"
+
classButton
+
"
editpdlplus_tool' id='editpdlplus_tool_
"
+
toolbar
[
i
].
toolid
+
"
' style='
"
+
style
+
"
' value='
"
+
toolbar
[
i
].
toolid
+
"
' data-enable='
"
+
toolbar
[
i
].
enable
+
"
'>
"
+
label
+
"
</button>
"
;
$
(
"
#editpdlplus_toolbar_
"
+
toolbar
[
0
].
axeid
).
append
(
buttonTmp
);
}
$
(
"
.editpdlplus_tool
"
).
on
(
"
click
"
,
refreshToolView
);
}
else
{
$
(
"
#message_edit_tool
"
).
html
(
toolbar
[
0
].
message
);
$
(
"
#message_edit_tool
"
).
addClass
(
"
alert-danger
"
);
$
(
"
#message_edit_tool
"
).
removeClass
(
"
alert-success
"
);
}
}).
fail
(
notification
.
exception
);
});
}.
bind
(
this
)).
fail
(
notification
.
exception
);
//templates.appendNodeContents('#editpdlplus_tool_item', html, js).done(function () {
//alert("jdikdi");
//$(".editpdlplus_tool").on("click", this.refreshToolView);
//}.bind(this))/*.fail(notification.exception)*/;
}.
bind
(
this
)).
fail
(
notification
.
exception
);
};
return
AdminPanel
;
});
\ No newline at end of file
classes/admin_editor.php
View file @
3b7a0879
...
...
@@ -87,5 +87,57 @@ class admin_editor {
global
$DB
;
return
$DB
->
delete_records
(
'assignfeedback_editpp_axis'
,
array
(
'id'
=>
$axeid
));
}
public
static
function
get_tools_by_axis
(
$tool
)
{
global
$DB
;
$tools
=
array
();
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_tool'
,
array
(
'axis'
=>
$tool
->
axis
));
foreach
(
$records
as
$record
)
{
if
(
$record
->
id
==
$tool
->
id
)
{
array_push
(
$tools
,
$tool
);
}
else
{
array_push
(
$tools
,
new
tool
(
$record
));
}
}
usort
(
$tools
,
function
(
$a
,
$b
)
{
$al
=
$a
->
order_tool
;
$bl
=
$b
->
order_tool
;
if
(
$al
==
$bl
)
{
return
0
;
}
return
(
$al
>
$bl
)
?
+
1
:
-
1
;
});
return
$tools
;
}
/**
*
* @global type $DB
* @param type $axisLabel
* @param type $context
* @return type
*/
public
static
function
edit_tool
(
$toolJson
)
{
global
$DB
;
$record
=
$DB
->
get_record
(
'assignfeedback_editpp_tool'
,
array
(
'id'
=>
$toolJson
->
toolid
),
'*'
,
MUST_EXIST
);
$tool
=
new
tool
(
$record
);
$tool
->
type
=
$toolJson
->
typetool
;
$tool
->
colors
=
$toolJson
->
color
;
$tool
->
cartridge
=
$toolJson
->
libelle
;
$tool
->
cartridge_color
=
$toolJson
->
catridgecolor
;
$tool
->
texts
=
$toolJson
->
texts
;
$tool
->
label
=
$toolJson
->
button
;
if
(
$toolJson
->
reply
)
{
$tool
->
reply
=
$toolJson
->
reply
;
}
else
{
$tool
->
reply
=
0
;
}
$tool
->
order_tool
=
$toolJson
->
order
;
if
(
$DB
->
update_record
(
'assignfeedback_editpp_tool'
,
$tool
))
{
return
$tool
;
}
return
null
;
}
}
classes/form/tool_form.php
0 → 100644
View file @
3b7a0879
<?php
/**
*
*
* @package assignfeedback_editpdfplus
* @copyright 2017 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
assignfeedback_editpdfplus\form
;
require_once
(
"
$CFG->libdir
/formslib.php"
);
use
moodleform
;
/**
* Description of formslib
*
* @author kury
*/
class
tool_form
extends
moodleform
{
protected
function
definition
()
{
$mform
=
$this
->
_form
;
$mform
->
addElement
(
'text'
,
'colors'
,
'Couleur'
);
// Add elements to your form
$mform
->
setType
(
'label'
,
PARAM_TEXT
);
//Set type of element
$mform
->
addElement
(
'hidden'
,
'toolid'
,
''
);
// Add elements to your form
$mform
->
setType
(
'hidden'
,
PARAM_INT
);
//Set type of element
}
//Custom validation should be added here
function
validation
(
$data
,
$files
)
{
return
array
();
}
}
classes/renderer.php
View file @
3b7a0879
...
...
@@ -391,5 +391,9 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
public
function
render_assignfeedback_editpdfplus_widget_admin_axisdelform
(
moodleform
$form
){
return
$this
->
render_from_template
(
'assignfeedback_editpdfplus/axis_del_form'
,
$form
);
}
public
function
render_assignfeedback_editpdfplus_widget_admin_toolform
(
$data
){
return
$this
->
render_from_template
(
'assignfeedback_editpdfplus/tool_form'
,
$data
);
}
}
classes/tool.php
View file @
3b7a0879
...
...
@@ -65,7 +65,7 @@ class tool {
/** @var boolean, if tool is actived or not */
public
$enabled
=
1
;
/** @var
boolean
, order in toolbar */
/** @var
int order_tool
, order in toolbar */
public
$order_tool
=
1000
;
/**
...
...
db/services.php
View file @
3b7a0879
...
...
@@ -55,5 +55,16 @@ $functions = array(
'requiredcapability'
=>
'mod/assignfeedback_editpdfplus:use'
,
'enabled'
=>
1
,
'services'
=>
array
(
MOODLE_OFFICIAL_MOBILE_SERVICE
)
)
),
'assignfeedback_editpdfplus_submit_tool_edit_form'
=>
array
(
'classname'
=>
'assignfeedback_editpdfplus_external'
,
'methodname'
=>
'submit_tool_edit_form'
,
'classpath'
=>
'mod/assign/feedback/editpdfplus/externallib.php'
,
'description'
=>
'Edit a tool'
,
'type'
=>
'write'
,
'ajax'
=>
true
,
'requiredcapability'
=>
'mod/assignfeedback_editpdfplus:use'
,
'enabled'
=>
1
,
'services'
=>
array
(
MOODLE_OFFICIAL_MOBILE_SERVICE
)
),
);
externallib.php
View file @
3b7a0879
...
...
@@ -180,4 +180,91 @@ class assignfeedback_editpdfplus_external extends external_api {
);
}
/**
* Returns description of method parameters
* @return external_function_parameters
*/
public
static
function
submit_tool_edit_form_parameters
()
{
return
new
external_function_parameters
(
array
(
'jsonformdata'
=>
new
external_value
(
PARAM_RAW
,
'The data from the grading form, encoded as a json array'
)
)
);
}
public
static
function
submit_tool_edit_form
(
$jsonformdata
)
{
global
$USER
,
$PAGE
,
$DB
;
$params
=
self
::
validate_parameters
(
self
::
submit_axis_form_parameters
(),
array
(
'jsonformdata'
=>
$jsonformdata
));
$serialiseddata
=
json_decode
(
$params
[
'jsonformdata'
]);
$data
=
array
();
parse_str
(
$serialiseddata
,
$data
);
$warnings
=
array
();
if
(
WS_SERVER
)
{
// Assume form submission if coming from WS.
$USER
->
ignoresesskey
=
true
;
//$data['_qf__mod_assign_grade_form_' . $params['userid']] = 1;
}
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$data
[
'courseid'
]),
'*'
,
MUST_EXIST
);
$context
=
context_course
::
instance
(
$course
->
id
,
MUST_EXIST
);
$PAGE
->
set_context
(
$context
);
$customdata
=
(
object
)
$data
;
$formparams
=
array
(
$customdata
);
$sessionkey
=
sesskey
();
if
(
$sessionkey
==
$customdata
->
sesskey
&&
$customdata
->
toolid
)
{
$tool
=
admin_editor
::
edit_tool
(
$customdata
);
if
(
$tool
)
{
$tools
=
admin_editor
::
get_tools_by_axis
(
$tool
);
$res
=
array
();
foreach
(
$tools
as
$toolTmp
)
{
$res
[]
=
array
(
'axeid'
=>
$tool
->
axis
,
'selecttool'
=>
$tool
->
id
,
'enable'
=>
$toolTmp
->
enabled
,
'toolid'
=>
$toolTmp
->
id
,
'typetool'
=>
$toolTmp
->
type
,
'button'
=>
$toolTmp
->
label
,
'message'
=>
''
);
}
return
$res
;
}
else
{
$warnings
[]
=
array
(
'message'
=>
'erreur à l enregistrement'
);
}
}
else
{
$warnings
[]
=
array
(
'message'
=>
'erreur à l enregistrement'
);
}
/* if ($validateddata) {
if ($validateddata->axeid) {
admin_editor::edit_axis($validateddata->axeid, $validateddata->label);
$axeid = $validateddata->axeid;
return array(array('axeid' => $axeid, 'axelabel' => $validateddata->label));
} else {
$axeid = admin_editor::add_axis($validateddata->label, $context->id);
return array(array('axeid' => $axeid, 'axelabel' => $validateddata->label));
}
} */
return
$warnings
;
}
public
static
function
submit_tool_edit_form_returns
()
{
return
new
external_multiple_structure
(
new
external_single_structure
(
array
(
'axeid'
=>
new
external_value
(
PARAM_INT
,
'axe id'
),
'selecttool'
=>
new
external_value
(
PARAM_INT
,
'tool id'
),
'enable'
=>
new
external_value
(
PARAM_INT
,
'tool enable'
),
'toolid'
=>
new
external_value
(
PARAM_INT
,
'tool id'
),
'typetool'
=>
new
external_value
(
PARAM_INT
,
'tool type'
),
'button'
=>
new
external_value
(
PARAM_TEXT
,
'tool label'
),
'message'
=>
new
external_value
(
PARAM_TEXT
,
'message'
,
VALUE_OPTIONAL
)
)
)
);
}
}
lib.php
View file @
3b7a0879
...
...
@@ -149,3 +149,23 @@ function assignfeedback_editpdfplus_output_fragment_axisdel($args) {
return
null
;
}
function
assignfeedback_editpdfplus_output_fragment_tooledit
(
$args
)
{
global
$DB
;
$context
=
$args
[
'context'
];
$toolid
=
$args
[
'toolid'
];
if
(
$context
->
contextlevel
!=
CONTEXT_COURSE
)
{
return
null
;
}
require_once
(
'locallib_admin.php'
);
if
(
has_capability
(
'mod/assignfeedback_editpdfplus:use'
,
$context
,
null
,
false
))
{
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$context
->
instanceid
),
'*'
,
MUST_EXIST
);
$editpdfplus
=
new
assign_feedback_editpdfplus_admin
(
$context
,
$course
);
return
$editpdfplus
->
getToolForm
(
$toolid
);
}
return
null
;
}
locallib_admin.php
View file @
3b7a0879
...
...
@@ -28,6 +28,7 @@ use \assignfeedback_editpdfplus\page_editor;
use
\
assignfeedback_editpdfplus\widget_admin
;
use
\
assignfeedback_editpdfplus\form\axis_form
;
use
\
assignfeedback_editpdfplus\form\axis_del_form
;
use
\
assignfeedback_editpdfplus\form\tool_form
;
use
\
assignfeedback_editpdfplus\admin_editor
;
class
assign_feedback_editpdfplus_admin
{
...
...
@@ -125,6 +126,25 @@ class assign_feedback_editpdfplus_admin {
return
$html
;
}
public
function
getToolForm
(
$toolid
=
null
)
{
global
$PAGE
,
$DB
;
$html
=
''
;
$data
=
new
stdClass
;
$data
->
courseid
=
$this
->
course
->
id
;
$data
->
sesskey
=
sesskey
();
$data
->
actionurl
=
"http://localhost/moodle33/moodle/lib/ajax/service.php"
;
$data
->
formid
=
"assignfeedback_editpdfplus_edit_tool"
;
if
(
$toolid
!=
null
)
{
$data
->
tool
=
$DB
->
get_record
(
'assignfeedback_editpp_tool'
,
array
(
'id'
=>
$toolid
),
'*'
,
MUST_EXIST
);
}
$data
->
tools
=
page_editor
::
get_typetools
(
null
);
$renderer
=
$PAGE
->
get_renderer
(
'assignfeedback_editpdfplus'
);
//$formTool->courseid = $this->course->id;
$html
.
=
$renderer
->
render_assignfeedback_editpdfplus_widget_admin_toolform
(
$data
);
return
$html
;
}
private
function
get_widget
()
{
global
$USER
;
...
...
templates/admin.mustache
View file @
3b7a0879
...
...
@@ -59,66 +59,8 @@
</div>
{{/
toolbars
}}
<div
id=
"editpdlplus_tool_item"
style=
"margin-top: 10px;"
>
<div
class=
'row'
style=
"margin-bottom: 10px;"
>
<div
class=
'col-sm-1'
>
<div
id=
"editpdlplus_tool_label"
></div>
</div>
<div
class=
'col-sm-offset-2 col-sm-5'
>
<button
type=
"button"
class=
"btn btn-default"
><i
class=
"fa fa-pencil"
aria-hidden=
"true"
></i></button>
<button
type=
"button"
class=
"btn btn-default"
><i
class=
"fa fa-clone"
aria-hidden=
"true"
></i></button>
<button
type=
"button"
class=
"btn btn-default"
><i
class=
"fa fa-eye-slash"
aria-hidden=
"true"
></i></button>
<button
type=
"button"
class=
"btn btn-default"
><i
class=
"fa fa-remove"
aria-hidden=
"true"
></i></button>
</div>
</div>
<div
class=
'row'
>
<div
class=
'col-sm-6'
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-wrench"
aria-hidden=
"true"
></i>
<a
data-toggle=
"collapse"
href=
"#collapse1"
>
Type d'outil
</a>
</div>
<div
id=
"collapse1"
class=
"panel-collapse collapse"
>
<div
class=
"panel-body"
>
yt
</div>
</div>
</div>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-bars"
aria-hidden=
"true"
></i>
<a
data-toggle=
"collapse"
href=
"#collapse2"
>
Affichage barre d'outil
</a>
</div>
<div
id=
"collapse2"
class=
"panel-collapse collapse"
>
<div
class=
"panel-body"
>
fddr
</div>
</div>
</div>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-address-card-o"
aria-hidden=
"true"
></i>
<a
data-toggle=
"collapse"
href=
"#collapse3"
>
Cartouche
</a>
</div>
<div
id=
"collapse3"
class=
"panel-collapse collapse"
>
<div
class=
"panel-body"
>
-
</div>
</div>
</div>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-pencil-square-o"
aria-hidden=
"true"
></i>
<a
data-toggle=
"collapse"
href=
"#collapse4"
>
Annotation
</a>
</div>
<div
id=
"collapse4"
class=
"panel-collapse collapse"
>
<div
class=
"panel-body"
>
-
</div>
</div>
</div>
</div>
<div
class=
'col-sm-6'
>
</div>
</div>
</div>
<div
id=
"editpdlplus_tool_item"
style=
"margin-top: 10px;"
></div>
</div>
</div>
</div>
...
...
templates/tool_form.mustache
0 → 100644
View file @
3b7a0879
{{
!
@template
assignfeedback_editpdfplus
/
tool_form
}}
<div
class=
"alert"
id=
"message_edit_tool"
>
</div>
<div
class=
'row'
style=
"margin-bottom: 10px;"
>
<div
class=
'col-sm-1'
>
<div
id=
"editpdlplus_tool_label"
></div>
</div>
<div
class=
'col-sm-offset-2 col-sm-5'
>
Actions :
<button
type=
"button"
class=
"btn btn-default"
id=
"toolFormSubmit"
><i
class=
"fa fa-pencil"
aria-hidden=
"true"
></i></button>
<button
type=
"button"
class=
"btn btn-default"
><i
class=
"fa fa-clone"
aria-hidden=
"true"
></i></button>
<button
type=
"button"
class=
"btn btn-default"
><i
class=
"fa fa-eye-slash"
aria-hidden=
"true"
></i></button>
<button
type=
"button"
class=
"btn btn-default"
><i
class=
"fa fa-remove"
aria-hidden=
"true"
></i></button>
</div>
</div>
<div
class=
'row'
>
<div
class=
'col-sm-6'
>
<form
id=
"
{{
formid
}}
"
method=
"post"
action=
"
{{
actionurl
}}
"
class=
"form-horizontal"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-wrench"
aria-hidden=
"true"
></i>
<a
data-toggle=
"collapse"
href=
"#collapse1"
>
Type d'outil
</a>
</div>
<div
id=
"collapse1"
class=
"panel-collapse collapse"
>
<div
class=
"panel-body"
style=
"margin-bottom: 20px;"
>
<div
class=
"form-group"
>
<label
class=
"control-label col-sm-3"
for=
"typetool"
>
Type
</label>
<div
class=
"col-sm-9"
>
<select
class=
"form-control"
id=
"typetool"
name=
"typetool"
>
{{#
tools
}}
<option
value=
'
{{
id
}}
'
>
{{
label
}}
</option>
{{/
tools
}}
</select>
</div>
</div>
</div>
</div>
</div>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-bars"
aria-hidden=
"true"
></i>
<a
data-toggle=
"collapse"
href=
"#collapse2"
>
Affichage barre d'outil
</a>