Gitlab CSE Unil
Skip to content
GitLab
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
aa703b4b
Commit
aa703b4b
authored
Jul 26, 2016
by
M. Chardon
Browse files
affichage des barres d'outils customisées, avec choix d'affichage
parent
9e4edd46
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
aa703b4b
/.old/
\ No newline at end of file
classes/annotation.php
View file @
aa703b4b
...
...
@@ -58,7 +58,7 @@ class annotation {
public
$path
=
''
;
/** @var int toolid for this annotation. */
public
$toolid
=
9
;
public
$toolid
=
0
;
/** @var string textannot, contains the text of this annotation */
public
$textannot
=
''
;
...
...
classes/page_editor.php
View file @
aa703b4b
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
...
...
@@ -24,6 +25,8 @@
namespace
assignfeedback_editpdfplus
;
use
assignfeedback_editpdfplus
\
tool
;
/**
* This class performs crud operations on comments and annotations from a page of a response.
*
...
...
@@ -46,7 +49,7 @@ class page_editor {
global
$DB
;
$comments
=
array
();
$params
=
array
(
'gradeid'
=>
$gradeid
,
'pageno'
=>
$pageno
,
'draft'
=>
1
);
$params
=
array
(
'gradeid'
=>
$gradeid
,
'pageno'
=>
$pageno
,
'draft'
=>
1
);
if
(
!
$draft
)
{
$params
[
'draft'
]
=
0
;
}
...
...
@@ -68,7 +71,7 @@ class page_editor {
public
static
function
set_comments
(
$gradeid
,
$pageno
,
$comments
)
{
global
$DB
;
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'pageno'
=>
$pageno
,
'draft'
=>
1
));
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'pageno'
=>
$pageno
,
'draft'
=>
1
));
$added
=
0
;
foreach
(
$comments
as
$record
)
{
...
...
@@ -98,7 +101,7 @@ class page_editor {
* @return comment or false
*/
public
static
function
get_comment
(
$commentid
)
{
$record
=
$DB
->
get_record
(
'assignfeedback_editpp_cmnt'
,
array
(
'id'
=>
$commentid
),
'*'
,
IGNORE_MISSING
);
$record
=
$DB
->
get_record
(
'assignfeedback_editpp_cmnt'
,
array
(
'id'
=>
$commentid
),
'*'
,
IGNORE_MISSING
);
if
(
$record
)
{
return
new
comment
(
$record
);
}
...
...
@@ -123,7 +126,23 @@ class page_editor {
*/
public
static
function
remove_comment
(
$commentid
)
{
global
$DB
;
return
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'id'
=>
$commentid
));
return
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'id'
=>
$commentid
));
}
/**
* Get all tools for a page.
* @param int $contextid
* @param int $axis
* @return tool[]
*/
public
static
function
get_tools
(
$contextidlist
)
{
global
$DB
;
$tools
=
array
();
$records
=
$DB
->
get_records_list
(
'assignfeedback_editpp_tool'
,
'contextid'
,
$contextidlist
);
foreach
(
$records
as
$record
)
{
array_push
(
$tools
,
new
tool
(
$record
));
}
return
$tools
;
}
/**
...
...
@@ -136,7 +155,7 @@ class page_editor {
public
static
function
get_annotations
(
$gradeid
,
$pageno
,
$draft
)
{
global
$DB
;
$params
=
array
(
'gradeid'
=>
$gradeid
,
'pageno'
=>
$pageno
,
'draft'
=>
1
);
$params
=
array
(
'gradeid'
=>
$gradeid
,
'pageno'
=>
$pageno
,
'draft'
=>
1
);
if
(
!
$draft
)
{
$params
[
'draft'
]
=
0
;
}
...
...
@@ -187,7 +206,7 @@ class page_editor {
public
static
function
get_annotation
(
$annotationid
)
{
global
$DB
;
$record
=
$DB
->
get_record
(
'assignfeedback_editpp_annot'
,
array
(
'id'
=>
$annotationid
),
'*'
,
IGNORE_MISSING
);
$record
=
$DB
->
get_record
(
'assignfeedback_editpp_annot'
,
array
(
'id'
=>
$annotationid
),
'*'
,
IGNORE_MISSING
);
if
(
$record
)
{
return
new
annotation
(
$record
);
}
...
...
@@ -203,8 +222,8 @@ class page_editor {
global
$DB
;
// Delete the non-draft annotations and comments.
$result
=
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
$result
=
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
))
&&
$result
;
$result
=
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
$result
=
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
))
&&
$result
;
return
$result
;
}
...
...
@@ -217,17 +236,17 @@ class page_editor {
global
$DB
;
// Delete the previous non-draft annotations and comments.
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
// Copy all the draft annotations and comments to non-drafts.
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
1
));
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
1
));
foreach
(
$records
as
$record
)
{
unset
(
$record
->
id
);
$record
->
draft
=
0
;
$DB
->
insert_record
(
'assignfeedback_editpp_annot'
,
$record
);
}
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
1
));
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
1
));
foreach
(
$records
as
$record
)
{
unset
(
$record
->
id
);
$record
->
draft
=
0
;
...
...
@@ -244,7 +263,7 @@ class page_editor {
*/
public
static
function
has_annotations_or_comments
(
$gradeid
,
$includedraft
)
{
global
$DB
;
$params
=
array
(
'gradeid'
=>
$gradeid
);
$params
=
array
(
'gradeid'
=>
$gradeid
);
if
(
!
$includedraft
)
{
$params
[
'draft'
]
=
0
;
}
...
...
@@ -266,17 +285,17 @@ class page_editor {
global
$DB
;
// Delete the previous non-draft annotations and comments.
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
1
));
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
1
));
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
1
));
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
1
));
// Copy all the draft annotations and comments to non-drafts.
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
foreach
(
$records
as
$record
)
{
unset
(
$record
->
id
);
$record
->
draft
=
0
;
$DB
->
insert_record
(
'assignfeedback_editpp_annot'
,
$record
);
}
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
$records
=
$DB
->
get_records
(
'assignfeedback_editpp_cmnt'
,
array
(
'gradeid'
=>
$gradeid
,
'draft'
=>
0
));
foreach
(
$records
as
$record
)
{
unset
(
$record
->
id
);
$record
->
draft
=
0
;
...
...
@@ -306,7 +325,7 @@ class page_editor {
public
static
function
remove_annotation
(
$annotationid
)
{
global
$DB
;
return
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'id'
=>
$annotationid
));
return
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'id'
=>
$annotationid
));
}
/**
...
...
@@ -368,8 +387,7 @@ class page_editor {
$fs
->
delete_area_files
(
$contextid
,
$component
,
$area
,
$itemid
);
// Copy the files from the source area.
if
(
$files
=
$fs
->
get_area_files
(
$contextid
,
$component
,
$area
,
$sourceitemid
,
"filename"
,
$includesubdirs
))
{
if
(
$files
=
$fs
->
get_area_files
(
$contextid
,
$component
,
$area
,
$sourceitemid
,
"filename"
,
$includesubdirs
))
{
foreach
(
$files
as
$file
)
{
$newrecord
=
new
\
stdClass
();
$newrecord
->
contextid
=
$contextid
;
...
...
@@ -395,4 +413,5 @@ class page_editor {
$result
=
$result
&&
$DB
->
delete_records
(
'assignfeedback_editpp_cmnt'
,
$conditions
);
return
$result
;
}
}
classes/renderer.php
View file @
aa703b4b
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
...
...
@@ -21,7 +22,6 @@
* @copyright 2012 Davo Smith
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
...
...
@@ -72,27 +72,67 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
* @param bool $disabled Optional - Is this button disabled.
* @return string
*/
private
function
render_toolbar_button
(
$icon
,
$tool
,
$accesskey
=
null
,
$disabled
=
false
)
{
// Build button alt text.
$alttext
=
new
stdClass
();
$alttext
->
tool
=
$tool
;
if
(
!
empty
(
$accesskey
))
{
$alttext
->
shortcut
=
'(Alt/Shift-Alt/Ctrl-Option + '
.
$accesskey
.
')'
;
private
function
render_toolbar_button
(
$icon
,
$tool
,
assignfeedback_editpdfplus
\
tool
$fulltool
=
null
,
$accesskey
=
null
,
$disabled
=
false
)
{
if
(
!
$fulltool
)
{
// Build button alt text.
$alttext
=
new
stdClass
();
$alttext
->
tool
=
$tool
;
if
(
!
empty
(
$accesskey
))
{
$alttext
->
shortcut
=
'(Alt/Shift-Alt/Ctrl-Option + '
.
$accesskey
.
')'
;
}
else
{
$alttext
->
shortcut
=
''
;
}
$iconalt
=
get_string
(
'toolbarbutton'
,
'assignfeedback_editpdfplus'
,
$alttext
);
$iconhtml
=
$this
->
pix_icon
(
$icon
,
$iconalt
,
'assignfeedback_editpdfplus'
);
$iconparams
=
array
(
'data-tool'
=>
$tool
,
'class'
=>
$tool
.
'button'
);
if
(
$disabled
)
{
$iconparams
[
'disabled'
]
=
'true'
;
}
}
else
{
$alttext
->
shortcut
=
''
;
$iconalt
=
$fulltool
->
label
;
$iconhtml
=
$fulltool
->
label
;
$datatool
=
''
;
$class
=
''
;
switch
(
$fulltool
->
type
)
{
case
1
:
$datatool
=
'highlightplus'
;
$class
=
'highlightplus'
;
break
;
case
2
:
$datatool
=
'lineplus'
;
$class
=
'lineplus'
;
break
;
case
3
:
$datatool
=
'stampplus'
;
$class
=
'stampplus'
;
break
;
case
4
:
$datatool
=
'frame'
;
$class
=
'frame'
;
break
;
case
5
:
$datatool
=
'verticalline'
;
$class
=
'verticalline'
;
break
;
case
6
:
$datatool
=
'stampcomment'
;
$class
=
'stampcomment'
;
break
;
case
7
:
$datatool
=
'commentplus'
;
$class
=
'commentplus'
;
break
;
default
:
break
;
}
$iconparams
=
array
(
'data-tool'
=>
$datatool
,
'class'
=>
$class
.
'button'
);
}
$iconalt
=
get_string
(
'toolbarbutton'
,
'assignfeedback_editpdfplus'
,
$alttext
);
$iconhtml
=
$this
->
pix_icon
(
$icon
,
$iconalt
,
'assignfeedback_editpdfplus'
);
$iconparams
=
array
(
'data-tool'
=>
$tool
,
'class'
=>
$tool
.
'button'
);
if
(
$disabled
)
{
$iconparams
[
'disabled'
]
=
'true'
;
}
if
(
!
empty
(
$accesskey
))
{
$iconparams
[
'accesskey'
]
=
$accesskey
;
}
return
html_writer
::
tag
(
'button'
,
$iconhtml
,
$iconparams
);
}
...
...
@@ -110,13 +150,9 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$html
.
=
html_writer
::
div
(
get_string
(
'jsrequired'
,
'assignfeedback_editpdfplus'
),
'hiddenifjs'
);
$linkid
=
html_writer
::
random_id
();
if
(
$widget
->
readonly
)
{
$launcheditorlink
=
html_writer
::
tag
(
'a'
,
get_string
(
'viewfeedbackonline'
,
'assignfeedback_editpdfplus'
),
array
(
'id'
=>
$linkid
,
'class'
=>
'btn'
,
'href'
=>
'#'
));
$launcheditorlink
=
html_writer
::
tag
(
'a'
,
get_string
(
'viewfeedbackonline'
,
'assignfeedback_editpdfplus'
),
array
(
'id'
=>
$linkid
,
'class'
=>
'btn'
,
'href'
=>
'#'
));
}
else
{
$launcheditorlink
=
html_writer
::
tag
(
'a'
,
get_string
(
'launcheditor'
,
'assignfeedback_editpdfplus'
),
array
(
'id'
=>
$linkid
,
'class'
=>
'btn'
,
'href'
=>
'#'
));
$launcheditorlink
=
html_writer
::
tag
(
'a'
,
get_string
(
'launcheditor'
,
'assignfeedback_editpdfplus'
),
array
(
'id'
=>
$linkid
,
'class'
=>
'btn'
,
'href'
=>
'#'
));
}
$links
=
$launcheditorlink
;
$html
.
=
'<input type="hidden" name="assignfeedback_editpdfplus_haschanges" value="false"/>'
;
...
...
@@ -127,9 +163,7 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
// Create the page navigation.
$navigation1
=
''
;
$navigation2
=
''
;
$navigation3
=
''
;
//$divToolbar;
// Pick the correct arrow icons for right to left mode.
if
(
right_to_left
())
{
$nav_prev
=
'nav_next'
;
...
...
@@ -141,82 +175,99 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$iconalt
=
get_string
(
'navigateprevious'
,
'assignfeedback_editpdfplus'
);
$iconhtml
=
$this
->
pix_icon
(
$nav_prev
,
$iconalt
,
'assignfeedback_editpdfplus'
);
$navigation1
.
=
html_writer
::
tag
(
'button'
,
$iconhtml
,
array
(
'disabled'
=>
'true'
,
'class'
=>
'navigate-previous-button'
,
'accesskey'
=>
$this
->
get_shortcut
(
'navigate-previous-button'
)));
$navigation1
.
=
html_writer
::
tag
(
'select'
,
null
,
array
(
'disabled'
=>
'true'
,
'aria-label'
=>
get_string
(
'gotopage'
,
'assignfeedback_editpdfplus'
),
'class'
=>
'navigate-page-select'
,
'accesskey'
=>
$this
->
get_shortcut
(
'navigate-page-select'
)));
$navigation1
.
=
html_writer
::
tag
(
'button'
,
$iconhtml
,
array
(
'disabled'
=>
'true'
,
'class'
=>
'navigate-previous-button'
,
'accesskey'
=>
$this
->
get_shortcut
(
'navigate-previous-button'
)));
$navigation1
.
=
html_writer
::
tag
(
'select'
,
null
,
array
(
'disabled'
=>
'true'
,
'aria-label'
=>
get_string
(
'gotopage'
,
'assignfeedback_editpdfplus'
),
'class'
=>
'navigate-page-select'
,
'accesskey'
=>
$this
->
get_shortcut
(
'navigate-page-select'
)));
$iconalt
=
get_string
(
'navigatenext'
,
'assignfeedback_editpdfplus'
);
$iconhtml
=
$this
->
pix_icon
(
$nav_next
,
$iconalt
,
'assignfeedback_editpdfplus'
);
$navigation1
.
=
html_writer
::
tag
(
'button'
,
$iconhtml
,
array
(
'disabled'
=>
'true'
,
'class'
=>
'navigate-next-button'
,
'accesskey'
=>
$this
->
get_shortcut
(
'navigate-next-button'
)));
$navigation1
.
=
html_writer
::
tag
(
'button'
,
$iconhtml
,
array
(
'disabled'
=>
'true'
,
'class'
=>
'navigate-next-button'
,
'accesskey'
=>
$this
->
get_shortcut
(
'navigate-next-button'
)));
$navigation1
=
html_writer
::
div
(
$navigation1
,
'navigation'
,
array
(
'role'
=>
'navigation'
));
$
div
navigation1
=
html_writer
::
div
(
$navigation1
,
'navigation'
,
array
(
'role'
=>
'navigation'
));
$navigation2
.
=
$this
->
render_toolbar_button
(
'comment_search'
,
'searchcomments'
,
$this
->
get_shortcut
(
'searchcomments'
));
$navigation2
=
html_writer
::
div
(
$navigation2
,
'navigation-search'
,
array
(
'role'
=>
'navigation'
));
$navigation2
.
=
$this
->
render_toolbar_button
(
'comment_search'
,
'searchcomments'
,
null
,
$this
->
get_shortcut
(
'searchcomments'
));
$
div
navigation2
=
html_writer
::
div
(
$navigation2
,
'navigation-search'
,
array
(
'role'
=>
'navigation'
));
$toolbar1
=
''
;
$toolbar2
=
''
;
$toolbar3
=
''
;
$toolbar4
=
''
;
$toolbar001
=
''
;
$toolbar002
=
''
;
$clearfix
=
html_writer
::
div
(
''
,
'clearfix'
);
if
(
!
$widget
->
readonly
)
{
// Comments.
$toolbar1
.
=
$this
->
render_toolbar_button
(
'comment'
,
'comment'
,
$this
->
get_shortcut
(
'comment'
));
$toolbar1
.
=
$this
->
render_toolbar_button
(
'background_colour_clear'
,
'commentcolour'
,
$this
->
get_shortcut
(
'commentcolour'
));
$toolbar1
=
html_writer
::
div
(
$toolbar1
,
'toolbar'
,
array
(
'role'
=>
'toolbar'
));
/** Toolbar n°0 : basic tools * */
// Select Tool.
$toolbar
2
.
=
$this
->
render_toolbar_button
(
'drag'
,
'drag'
,
$this
->
get_shortcut
(
'drag'
));
$toolbar
2
.
=
$this
->
render_toolbar_button
(
'select'
,
'select'
,
$this
->
get_shortcut
(
'select'
));
$toolbar
2
=
html_writer
::
div
(
$toolbar
2
,
'toolbar'
,
array
(
'role'
=>
'toolbar'
));
$toolbar
001
.
=
$this
->
render_toolbar_button
(
'drag'
,
'drag'
,
null
,
$this
->
get_shortcut
(
'drag'
));
$toolbar
001
.
=
$this
->
render_toolbar_button
(
'select'
,
'select'
,
null
,
$this
->
get_shortcut
(
'select'
));
$toolbar
001
=
html_writer
::
div
(
$toolbar
001
,
'toolbar'
,
array
(
'role'
=>
'toolbar'
));
// Other Tools.
$toolbar3
.
=
$this
->
render_toolbar_button
(
'pen'
,
'pen'
,
$this
->
get_shortcut
(
'pen'
));
$toolbar3
.
=
$this
->
render_toolbar_button
(
'line'
,
'line'
,
$this
->
get_shortcut
(
'line'
));
$toolbar3
.
=
$this
->
render_toolbar_button
(
'rectangle'
,
'rectangle'
,
$this
->
get_shortcut
(
'rectangle'
));
$toolbar3
.
=
$this
->
render_toolbar_button
(
'oval'
,
'oval'
,
$this
->
get_shortcut
(
'oval'
));
$toolbar3
.
=
$this
->
render_toolbar_button
(
'highlight'
,
'highlight'
,
$this
->
get_shortcut
(
'highlight'
));
$toolbar3
.
=
$this
->
render_toolbar_button
(
'background_colour_clear'
,
'annotationcolour'
,
$this
->
get_shortcut
(
'annotationcolour'
));
$toolbar3
=
html_writer
::
div
(
$toolbar3
,
'toolbar'
,
array
(
'role'
=>
'toolbar'
));
// Stamps.
$toolbar4
.
=
$this
->
render_toolbar_button
(
'stamp'
,
'stamp'
,
'n'
);
$toolbar4
.
=
$this
->
render_toolbar_button
(
'background_colour_clear'
,
'currentstamp'
,
$this
->
get_shortcut
(
'currentstamp'
));
$toolbar4
=
html_writer
::
div
(
$toolbar4
,
'toolbar'
,
array
(
'role'
=>
'toolbar'
));
$toolbar002
.
=
$this
->
render_toolbar_button
(
'pen'
,
'pen'
,
null
,
$this
->
get_shortcut
(
'pen'
));
$toolbar002
.
=
$this
->
render_toolbar_button
(
'line'
,
'line'
,
null
,
$this
->
get_shortcut
(
'line'
));
$toolbar002
.
=
$this
->
render_toolbar_button
(
'rectangle'
,
'rectangle'
,
null
,
$this
->
get_shortcut
(
'rectangle'
));
$toolbar002
.
=
$this
->
render_toolbar_button
(
'oval'
,
'oval'
,
null
,
$this
->
get_shortcut
(
'oval'
));
$toolbar002
.
=
$this
->
render_toolbar_button
(
'highlight'
,
'highlight'
,
null
,
$this
->
get_shortcut
(
'highlight'
));
$toolbar002
.
=
$this
->
render_toolbar_button
(
'background_colour_clear'
,
'annotationcolour'
,
null
,
$this
->
get_shortcut
(
'annotationcolour'
));
$toolbar002
=
html_writer
::
div
(
$toolbar002
,
'toolbar'
,
array
(
'role'
=>
'toolbar'
));
/** Costum toolbars * */
$toolbarCostum
=
array
();
$axis
=
array
();
foreach
(
$widget
->
toolbars
as
$toolbar
)
{
$compteur
=
0
;
if
(
sizeof
(
$toolbar
)
>
0
)
{
$toolbartmp
=
''
;
foreach
(
$toolbar
as
$tool
)
{
$toolbartmp
.
=
$this
->
render_toolbar_button
(
''
,
''
,
$tool
);
}
$toolbarCostum
[]
=
html_writer
::
div
(
$toolbartmp
,
'toolbar customtoolbar'
,
array
(
'role'
=>
'toolbar'
,
'id'
=>
'toolbaraxis'
.
$tool
->
axis
,
'style'
=>
'display:none;'
));
switch
(
$tool
->
axis
)
{
case
1
:
$axis
[
1
]
=
'Axe 1 : rectitude'
;
break
;
case
2
:
$axis
[
2
]
=
'Axe 2 : structure/contenu'
;
break
;
case
3
:
$axis
[
3
]
=
'Axe 3 : instance corr.'
;
break
;
}
$compteur
++
;
}
}
$axischoice
=
html_writer
::
div
(
html_writer
::
select
(
$axis
,
'axisselection'
,
0
,
FALSE
),
'toolbar '
,
array
(
'role'
=>
'toolbar'
));
$toolbarCostumdiv
=
''
;
foreach
(
$toolbarCostum
as
$toolbarCostumUnit
)
{
$toolbarCostumdiv
.
=
$toolbarCostumUnit
;
}
$toolbarCostumdiv
.
=
$axischoice
;
}
// Toobars written in reverse order because they are floated right.
$pageheader
=
html_writer
::
div
(
$navigation1
.
$navigation2
.
//$toolbar4 .
$toolbar3
.
$toolbar2
.
//$toolbar1 .
$clearfix
,
'pageheader'
);
$pageheader
=
html_writer
::
div
(
$divnavigation1
.
$divnavigation2
.
$toolbar002
.
$toolbarCostumdiv
.
$toolbar001
.
$clearfix
,
'pageheader'
);
debugging
(
$pageheader
);
$body
.
=
$pageheader
;
// Loading progress bar.
$progressbar
=
html_writer
::
div
(
''
,
'bar'
,
array
(
'style'
=>
'width: 0%'
));
$progressbar
=
html_writer
::
div
(
$progressbar
,
'progress progress-info progress-striped active'
,
array
(
'title'
=>
get_string
(
'loadingeditor'
,
'assignfeedback_editpdfplus'
),
'role'
=>
'progressbar'
,
'aria-valuenow'
=>
0
,
'aria-valuemin'
=>
0
,
'aria-valuemax'
=>
100
));
$progressbarlabel
=
html_writer
::
div
(
get_string
(
'generatingpdf'
,
'assignfeedback_editpdfplus'
),
'progressbarlabel'
);
$progressbar
=
html_writer
::
div
(
$progressbar
,
'progress progress-info progress-striped active'
,
array
(
'title'
=>
get_string
(
'loadingeditor'
,
'assignfeedback_editpdfplus'
),
'role'
=>
'progressbar'
,
'aria-valuenow'
=>
0
,
'aria-valuemin'
=>
0
,
'aria-valuemax'
=>
100
));
$progressbarlabel
=
html_writer
::
div
(
get_string
(
'generatingpdf'
,
'assignfeedback_editpdfplus'
),
'progressbarlabel'
);
$loading
=
html_writer
::
div
(
$progressbar
.
$progressbarlabel
,
'loading'
);
$canvas
=
html_writer
::
div
(
$loading
,
'drawingcanvas'
);
$canvas
=
html_writer
::
div
(
$canvas
,
'drawingregion'
);
$changesmessage
=
html_writer
::
tag
(
'div'
,
get_string
(
'draftchangessaved'
,
'assignfeedback_editpdfplus'
),
array
(
'class'
=>
'assignfeedback_editpdfplus_unsavedchanges warning label label-info'
));
$changesmessage
=
html_writer
::
tag
(
'div'
,
get_string
(
'draftchangessaved'
,
'assignfeedback_editpdfplus'
),
array
(
'class'
=>
'assignfeedback_editpdfplus_unsavedchanges warning label label-info'
));
$changesmessage
=
html_writer
::
div
(
$changesmessage
,
'unsaved-changes'
);
$canvas
.
=
$changesmessage
;
...
...
@@ -225,22 +276,20 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
$footer
=
''
;
$editorparams
=
array
(
array
(
'header'
=>
$header
,
'body'
=>
$body
,
'footer'
=>
$footer
,
'linkid'
=>
$linkid
,
'assignmentid'
=>
$widget
->
assignment
,
'userid'
=>
$widget
->
userid
,
'attemptnumber'
=>
$widget
->
attemptnumber
,
'stampfiles'
=>
$widget
->
stampfiles
,
'readonly'
=>
$widget
->
readonly
,
'pagetotal'
=>
$widget
->
pagetotal
));
$editorparams
=
array
(
array
(
'header'
=>
$header
,
'body'
=>
$body
,
'footer'
=>
$footer
,
'linkid'
=>
$linkid
,
'assignmentid'
=>
$widget
->
assignment
,
'userid'
=>
$widget
->
userid
,
'attemptnumber'
=>
$widget
->
attemptnumber
,
'stampfiles'
=>
$widget
->
stampfiles
,
'readonly'
=>
$widget
->
readonly
,
'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
(
'yellow'
,
...
...
@@ -263,8 +312,9 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
'stamppicker'
,
'cannotopenpdf'
,
'pagenumber'
),
'assignfeedback_editpdfplus'
);
),
'assignfeedback_editpdfplus'
);
return
$html
;
}
}
classes/tool.php
0 → 100644
View file @
aa703b4b
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace
assignfeedback_editpdfplus
;
/**
* Description of tool
*
* @author kury
*/
class
tool
{
/** @var int unique id for this annotation */
public
$id
=
0
;
/** @var int contextid for this annotation */
public
$contextid
=
0
;
/** @var int axis for this annotation */
public
$axis
=
0
;
/** @var int type */
public
$type
=
0
;
/** @var string colors used */
public
$colors
=
''
;
/** @var string cartridge for drawing the annotation. */
public
$cartridge
=
''
;
/** @var string texts for this annotation. */
public
$texts
=
''
;
/** @var string label of this annotation */
public
$label
=
''
;
/** @var boolean, allow reply or not */
public
$reply
=
0
;
/**
* Convert a compatible stdClass into an instance of this class.
* @param stdClass $record
*/
public
function
__construct
(
\
stdClass
$record
=
null
)
{
if
(
$record
)
{
$intcols
=
array
(
'reply'
);
foreach
(
$this
as
$key
=>
$value
)
{
if
(
isset
(
$record
->
$key
))
{
if
(
in_array
(
$key
,
$intcols
))
{
$this
->
$key
=
intval
(
$record
->
$key
);
}
else
{
$this
->
$key
=
$record
->
$key
;
}
}
}
}
}
}
classes/widget.php
View file @
aa703b4b
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
...
...
@@ -21,7 +22,6 @@
* @copyright 2012 Davo Smith
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
...
...
@@ -35,21 +35,31 @@ class assignfeedback_editpdfplus_widget implements renderable {
/** @var int $assignment - Assignment instance id */
public
$assignment
=
0
;
/** @var int $userid - The user id we are grading */
public
$userid
=
0
;
/** @var mixed $attemptnumber - The attempt number we are grading */
public
$attemptnumber
=
0
;
/** @var moodle_url $downloadurl */
public
$downloadurl
=
null
;
/** @var string $downloadfilename */
public
$downloadfilename
=
null
;
/** @var string[] $stampfiles */
public
$stampfiles
=
array
();
/** @var bool $readonly */
public
$readonly
=
true
;
/** @var integer $pagetotal */
public
$pagetotal
=