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
202abb9e
Commit
202abb9e
authored
Jul 11, 2017
by
M. Chardon
Browse files
création tool
parent
3b7a0879
Changes
10
Show whitespace changes
Inline
Side-by-side
amd/build/admin_panel.min.js
View file @
202abb9e
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
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
),
a
(
"
#assignfeedback_editpdfplus_widget_admin_button_addtool
"
).
on
(
"
click
"
,
this
.
openDivAddTool
)},
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
.
prototype
.
openDivAddTool
=
function
(){
a
(
"
#editpdlplus_tool_item
"
).
html
(
""
),
a
(
"
.btn-primary
"
).
addClass
(
"
btn-default
"
),
a
(
"
.editpdlplus_tool
"
).
removeClass
(
"
btn-primary
"
);
var
c
=
a
(
"
#editpdlplus_axes option:selected
"
).
val
(),
g
=
{
axisid
:
c
};
d
.
loadFragment
(
"
assignfeedback_editpdfplus
"
,
"
tooladd
"
,
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_add_form
"
,
args
:{
jsonformdata
:
JSON
.
stringify
(
d
)}}])[
0
].
done
(
function
(
b
){
if
(
""
===
b
[
0
].
message
){
a
(
"
#message_edit_tool
"
).
html
(
"
Ajout enregistré
"
),
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
),
a
(
"
#editpdlplus_tool_item
"
).
html
()}
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
)},
g
});
\ No newline at end of file
amd/src/admin_panel.js
View file @
202abb9e
...
...
@@ -60,6 +60,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
$
(
"
#assignfeedback_editpdfplus_widget_admin_button_addaxis
"
).
on
(
"
click
"
,
this
.
openDivAddAxis
);
$
(
"
#assignfeedback_editpdfplus_widget_admin_button_editaxis
"
).
on
(
"
click
"
,
this
.
openDivEditAxis
);
$
(
"
#assignfeedback_editpdfplus_widget_admin_button_delaxis
"
).
on
(
"
click
"
,
this
.
openDivDelAxis
);
$
(
"
#assignfeedback_editpdfplus_widget_admin_button_addtool
"
).
on
(
"
click
"
,
this
.
openDivAddTool
);
};
//
AdminPanel
.
prototype
.
test
=
function
()
{
...
...
@@ -128,7 +129,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
* @param {String} js
* @return {Deferred} promise resolved when the animations are complete.
*/
var
hello
=
function
(
node
,
html
,
js
)
{
var
fillResultAjax
=
function
(
node
,
html
,
js
)
{
//alert("tutu");
//alert(html+js);
var
promise
=
$
.
Deferred
();
...
...
@@ -159,7 +160,7 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
//this.test();
fragment
.
loadFragment
(
'
assignfeedback_editpdfplus
'
,
'
tooledit
'
,
contextid
,
params
)
.
done
(
function
(
html
,
js
)
{
hello
(
$
(
'
#editpdlplus_tool_item
'
),
html
,
js
)
fillResultAjax
(
$
(
'
#editpdlplus_tool_item
'
),
html
,
js
)
.
done
(
function
()
{
$
(
"
#toolFormSubmit
"
).
on
(
"
click
"
,
function
()
{
var
form
=
$
(
'
#assignfeedback_editpdfplus_edit_tool
'
);
...
...
@@ -224,5 +225,76 @@ define(['jquery'/*, 'core/yui'*/, 'core/notification', 'core/templates', 'core/f
//}.bind(this))/*.fail(notification.exception)*/;
}.
bind
(
this
)).
fail
(
notification
.
exception
);
};
//
AdminPanel
.
prototype
.
openDivAddTool
=
function
()
{
$
(
'
#editpdlplus_tool_item
'
).
html
(
""
);
$
(
'
.btn-primary
'
).
addClass
(
"
btn-default
"
);
$
(
'
.editpdlplus_tool
'
).
removeClass
(
"
btn-primary
"
);
var
axeid
=
$
(
"
#editpdlplus_axes option:selected
"
).
val
();
var
params
=
{
axisid
:
axeid
};
fragment
.
loadFragment
(
'
assignfeedback_editpdfplus
'
,
'
tooladd
'
,
contextid
,
params
)
.
done
(
function
(
html
,
js
)
{
fillResultAjax
(
$
(
'
#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_add_form
'
,
args
:
{
jsonformdata
:
JSON
.
stringify
(
data
)}
}
])[
0
].
done
(
function
(
toolbar
)
{
if
(
toolbar
[
0
].
message
===
""
)
{
//mise à jour du message
$
(
"
#message_edit_tool
"
).
html
(
"
Ajout enregistré
"
);
$
(
"
#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
);
$
(
'
#editpdlplus_tool_item
'
).
html
(
""
);
}
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
);
}.
bind
(
this
)).
fail
(
notification
.
exception
);
};
return
AdminPanel
;
});
\ No newline at end of file
classes/admin_editor.php
View file @
202abb9e
...
...
@@ -62,6 +62,94 @@ class admin_editor {
return
$DB
->
insert_record
(
'assignfeedback_editpp_axis'
,
$axis
);
}
/**
*
* @global type $DB
* @param type $axisLabel
* @param type $context
* @return type
*/
public
static
function
add_tool
(
$data
,
$contextid
)
{
global
$DB
;
$tools
=
array
();
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_tool'
,
array
(
'axis'
=>
$data
->
axisid
));
foreach
(
$records
as
$record
)
{
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
;
});
$compteurPrecedent
=
null
;
$decalage
=
1
;
foreach
(
$tools
as
$tool
)
{
if
(
$compteurPrecedent
==
null
)
{
$compteurPrecedent
=
$tool
->
order_tool
;
}
else
{
$compteurCourant
=
$tool
->
order_tool
;
if
(
$compteurCourant
<=
$compteurPrecedent
)
{
$tool
->
order_tool
=
$compteurPrecedent
+
$decalage
;
//$decalage++;
}
$compteurPrecedent
++
;
}
}
$maxindice
=
$compteurPrecedent
;
$tool
=
new
tool
();
$tool
->
axis
=
$data
->
axisid
;
$tool
->
cartridge
=
$data
->
libelle
;
$tool
->
cartridge_color
=
$data
->
cartridgecolor
;
$tool
->
contextid
=
$contextid
;
$tool
->
label
=
$data
->
button
;
if
(
$data
->
reply
==
"on"
)
{
$tool
->
reply
=
1
;
}
else
{
$tool
->
reply
=
0
;
}
$tool
->
texts
=
$data
->
texts
;
$tool
->
type
=
$data
->
typetool
;
if
(
$maxindice
==
null
)
{
$tool
->
order_tool
=
1
;
}
elseif
(
$data
->
order
&&
intval
(
$data
->
order
)
<
1000
)
{
$tool
->
order_tool
=
$data
->
order
;
$compteurPrecedent
=
null
;
$decalage
=
1
;
foreach
(
$tools
as
$toolOr
)
{
if
(
$compteurPrecedent
==
null
&&
$data
->
order
==
$toolOr
->
order_tool
)
{
$compteurPrecedent
=
$toolOr
->
order_tool
;
$toolOr
->
order_tool
++
;
}
else
{
$compteurCourant
=
$toolOr
->
order_tool
;
if
(
$compteurCourant
==
$compteurPrecedent
)
{
$toolOr
->
order_tool
=
$compteurPrecedent
+
$decalage
;
}
}
}
//$this->reorder_tool($data->axisid, 'id', 'desc');
}
else
{
$tool
->
order_tool
=
$maxindice
;
}
$toolid
=
$DB
->
insert_record
(
'assignfeedback_editpp_tool'
,
$tool
);
foreach
(
$tools
as
$toolOr
)
{
$DB
->
update_record
(
'assignfeedback_editpp_tool'
,
$toolOr
);
}
if
(
$toolid
>
0
)
{
//$tool->id = $toolid;
return
$tool
;
}
return
null
;
}
/**
*
* @global type $DB
...
...
@@ -120,7 +208,7 @@ class admin_editor {
public
static
function
edit_tool
(
$toolJson
)
{
global
$DB
;
$record
=
$DB
->
get_record
(
'assignfeedback_editpp_tool'
,
array
(
'id'
=>
$toolJson
->
toolid
),
'*'
,
MUST_EXIST
);
$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
;
...
...
db/services.php
View file @
202abb9e
...
...
@@ -67,4 +67,15 @@ $functions = array(
'enabled'
=>
1
,
'services'
=>
array
(
MOODLE_OFFICIAL_MOBILE_SERVICE
)
),
'assignfeedback_editpdfplus_submit_tool_add_form'
=>
array
(
'classname'
=>
'assignfeedback_editpdfplus_external'
,
'methodname'
=>
'submit_tool_add_form'
,
'classpath'
=>
'mod/assign/feedback/editpdfplus/externallib.php'
,
'description'
=>
'Add a tool'
,
'type'
=>
'write'
,
'ajax'
=>
true
,
'requiredcapability'
=>
'mod/assignfeedback_editpdfplus:use'
,
'enabled'
=>
1
,
'services'
=>
array
(
MOODLE_OFFICIAL_MOBILE_SERVICE
)
),
);
externallib.php
View file @
202abb9e
...
...
@@ -267,4 +267,90 @@ class assignfeedback_editpdfplus_external extends external_api {
);
}
/**
* Returns description of method parameters
* @return external_function_parameters
*/
public
static
function
submit_tool_add_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_add_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
;
$sessionkey
=
sesskey
();
if
(
$sessionkey
==
$customdata
->
sesskey
)
{
$tool
=
admin_editor
::
add_tool
(
$customdata
,
$context
->
id
);
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_add_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 @
202abb9e
...
...
@@ -102,7 +102,7 @@ function assignfeedback_editpdfplus_output_fragment_axisadd($args) {
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
);
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$context
->
instanceid
),
'*'
,
MUST_EXIST
);
$editpdfplus
=
new
assign_feedback_editpdfplus_admin
(
$context
,
$course
);
return
$editpdfplus
->
getAxisForm
();
}
...
...
@@ -122,7 +122,7 @@ function assignfeedback_editpdfplus_output_fragment_axisedit($args) {
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
);
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$context
->
instanceid
),
'*'
,
MUST_EXIST
);
$editpdfplus
=
new
assign_feedback_editpdfplus_admin
(
$context
,
$course
);
return
$editpdfplus
->
getAxisForm
(
$axisid
);
}
...
...
@@ -142,7 +142,7 @@ function assignfeedback_editpdfplus_output_fragment_axisdel($args) {
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
);
$course
=
$DB
->
get_record
(
'course'
,
array
(
'id'
=>
$context
->
instanceid
),
'*'
,
MUST_EXIST
);
$editpdfplus
=
new
assign_feedback_editpdfplus_admin
(
$context
,
$course
);
return
$editpdfplus
->
getAxisDelForm
(
$axisid
);
}
...
...
@@ -162,10 +162,30 @@ function assignfeedback_editpdfplus_output_fragment_tooledit($args) {
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
);
$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
;
}
function
assignfeedback_editpdfplus_output_fragment_tooladd
(
$args
)
{
global
$DB
;
$context
=
$args
[
'context'
];
$axisid
=
$args
[
'axisid'
];
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
(
null
,
$axisid
);
}
return
null
;
}
locallib_admin.php
View file @
202abb9e
...
...
@@ -126,7 +126,7 @@ class assign_feedback_editpdfplus_admin {
return
$html
;
}
public
function
getToolForm
(
$toolid
=
null
)
{
public
function
getToolForm
(
$toolid
=
null
,
$axisid
=
null
)
{
global
$PAGE
,
$DB
;
$html
=
''
;
...
...
@@ -137,6 +137,12 @@ class assign_feedback_editpdfplus_admin {
$data
->
formid
=
"assignfeedback_editpdfplus_edit_tool"
;
if
(
$toolid
!=
null
)
{
$data
->
tool
=
$DB
->
get_record
(
'assignfeedback_editpp_tool'
,
array
(
'id'
=>
$toolid
),
'*'
,
MUST_EXIST
);
}
else
{
$tool
=
new
\
assignfeedback_editpdfplus\tool
();
$tool
->
contextid
=
$this
->
context
->
id
;
$tool
->
enabled
=
true
;
$tool
->
axis
=
$axisid
;
$data
->
tool
=
$tool
;
}
$data
->
tools
=
page_editor
::
get_typetools
(
null
);
$renderer
=
$PAGE
->
get_renderer
(
'assignfeedback_editpdfplus'
);
...
...
templates/admin.mustache
View file @
202abb9e
...
...
@@ -20,7 +20,11 @@
</h6>
</div>
<div
class=
'col-sm-10'
id=
'assignfeedback_editpdfplus_widget_admin_toolheader'
>
<h6>
Outils
<button
type=
"button"
class=
"btn btn-default"
><i
class=
"fa fa-plus"
aria-hidden=
"true"
></i></button></h6>
<h6>
Outils
<button
type=
"button"
class=
"btn btn-default"
id=
"assignfeedback_editpdfplus_widget_admin_button_addtool"
>
<i
class=
"fa fa-plus"
aria-hidden=
"true"
></i>
</button>
</h6>
</div>
</div>
<div
class=
'row'
id=
'assignfeedback_editpdfplus_widget_admin_workspace'
>
...
...
templates/tool_form.mustache
View file @
202abb9e
...
...
@@ -7,15 +7,18 @@
</div>
<div
class=
'row'
style=
"margin-bottom: 10px;"
>
{{^
tool
.
id
}}
<h4>
Ajout d'un nouvel outil
</h4>
{{/
tool
.
id
}}
<div
class=
'col-sm-1'
>
<div
id=
"editpdlplus_tool_label"
></div>
<div
id=
"editpdlplus_tool_label"
>
{{#
tool
.
id
}}{{
tool
.
label
}}{{/
tool
.
id
}}
</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>
Action
{{#
tool
.
id
}}
s
{{/
tool
.
id
}}
:
<button
type=
"button"
class=
"btn btn-default"
id=
"toolFormSubmit"
><i
class=
"fa fa-
{{#
tool
.
id
}}
pencil
{{/
tool
.
id
}}{{^
tool
.
id
}}
save
{{/
tool
.
id
}}
"
aria-hidden=
"true"
></i></button>
{{#
tool
.
id
}}
<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>
{{/
tool
.
id
}}
</div>
</div>
...
...
@@ -110,7 +113,7 @@
<div
class=
"form-group"
>
<label
class=
"control-label col-sm-3"
for=
"reply"
>
Question/réponse
</label>
<div
class=
"col-sm-9"
>
<input
type=
"checkbox"
class=
"form-control"
id=
"reply"
{{#
tool
.
reply
}}
checked
{{/
tool
.
reply
}}
value=
"
{{
tool
.
reply
}}
"
name=
"reply"
/>
<input
type=
"checkbox"
class=
"form-control"
id=
"reply"
{{#
tool
.
reply
}}
checked
{{/
tool
.
reply
}}
name=
"reply"
/>
</div>
</div>
</div>
...
...
@@ -119,6 +122,7 @@
<div
style=
'display:none;'
>
<input
type=
"hidden"
name=
"toolid"
value=
"
{{
tool
.
id
}}
"
/>
<input
type=
"hidden"
name=
"axisid"
value=
"
{{
tool
.
axis
}}
"
/>
<input
type=
"hidden"
name=
"courseid"
value=
"
{{
courseid
}}
"
/>
<input
type=
"hidden"
name=
"sesskey"
value=
"
{{
sesskey
}}
"
/>
</div>
...
...
@@ -132,7 +136,7 @@
{{#
js
}}
require(['jquery','core/ajax','core/notification'], function($,ajax,notification) {
$("#typetool").val(
{{
tool
.
type
}}
);
{{#
tool
.
id
}}
$("#typetool").val(
{{
tool
.
type
}}
);
{{/
tool
.
id
}}
});
{{/
js
}}
\ No newline at end of file
version.php
View file @
202abb9e
...
...
@@ -24,7 +24,7 @@
defined
(
'MOODLE_INTERNAL'
)
||
die
();
$plugin
->
version
=
2017062
3
00
;
$plugin
->
version
=
2017062
4
00
;
$plugin
->
requires
=
2017050500
;
// Requires this Moodle version.
$plugin
->
dependencies
=
array
(
'assignfeedback_editpdf'
=>
2017050500
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment