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
5abe70d6
Commit
5abe70d6
authored
Oct 05, 2016
by
M. Chardon
Browse files
pdf : texte des annotations + feedback global
parent
55774e24
Changes
3
Hide whitespace changes
Inline
Side-by-side
classes/document_services.php
View file @
5abe70d6
...
...
@@ -680,10 +680,43 @@ EOD;
foreach
(
$annotations
as
$annotation
)
{
$pdf
->
add_annotation
(
$annotation
,
$annotation
->
path
,
$stamptmpdir
,
$compteur
);
$annotation_index
[
$compteur
]
=
$annotation
->
id
;
$compteur
++
;
if
(
$annotation
->
textannot
&&
!
$annotation
->
parent_annot
)
{
$annotation_index
[
$annotation
->
id
]
=
$compteur
;
$compteur
++
;
}
}
}
$pdf
->
AddPage
();
$pdf
->
SetTextColor
(
0
,
0
,
0
);
$pdf
->
Write
(
10
,
""
,
''
,
false
,
'L'
,
true
);
$pdf
->
SetFontSize
(
14
);
$pdf
->
SetLeftMargin
(
20
);
$pdf
->
Write
(
5
,
"Références des annotations"
,
''
,
false
,
'L'
,
true
);
$pdf
->
Write
(
10
,
""
,
''
,
false
,
'L'
,
true
);
$pdf
->
SetFontSize
(
10
);
foreach
(
$annotation_index
as
$id
=>
$index
)
{
$annot
=
page_editor
::
get_annotation
(
$id
);
if
(
$annot
->
textannot
&&
!
$annot
->
parent_annot
)
{
$pdf
->
Write
(
5
,
$index
.
" : "
,
''
,
false
,
'L'
,
false
);
if
(
$annot
->
answerrequested
)
{
$pdf
->
SetTextColor
(
255
,
0
,
0
);
$pdf
->
Write
(
5
,
"[réponse attendue] "
,
''
,
false
,
'L'
,
true
);
$pdf
->
SetTextColor
(
0
,
0
,
0
);
}
$pdf
->
Write
(
5
,
$annot
->
textannot
,
''
,
false
,
'L'
,
true
);
$pdf
->
Write
(
0
,
""
,
''
,
false
,
'L'
,
true
);
}
}
$pdf
->
AddPage
();
$pdf
->
SetTextColor
(
0
,
0
,
0
);
$pdf
->
Write
(
10
,
""
,
''
,
false
,
'L'
,
true
);
$pdf
->
SetFontSize
(
14
);
$pdf
->
SetLeftMargin
(
20
);
$pdf
->
Write
(
5
,
"Feedback global"
,
''
,
false
,
'L'
,
true
);
$pdf
->
Write
(
10
,
""
,
''
,
false
,
'L'
,
true
);
$pdf
->
SetFontSize
(
10
);
$finalcomment
=
page_editor
::
get_feedback_comments
(
$grade
->
id
);
$pdf
->
writeHTMLCell
(
0
,
0
,
20
,
50
,
$finalcomment
->
commenttext
);
fulldelete
(
$stamptmpdir
);
...
...
classes/page_editor.php
View file @
5abe70d6
...
...
@@ -538,4 +538,16 @@ class page_editor {
return
$result
;
}
/**
* Get the feedback comment from the database.
*
* @param int $gradeid
* @return stdClass|false The feedback comments for the given grade if it exists.
* False if it doesn't.
*/
public
function
get_feedback_comments
(
$gradeid
)
{
global
$DB
;
return
$DB
->
get_record
(
'assignfeedback_comments'
,
array
(
'grade'
=>
$gradeid
));
}
}
classes/pdf.php
View file @
5abe70d6
...
...
@@ -346,7 +346,7 @@ class pdf extends \FPDI {
* @param string $imagefolder - Folder containing stamp images.
* @return bool true if successful (always)
*/
public
function
add_annotation
(
annotation
$annotation
,
$path
,
$imagefolder
,
$annotation_index
)
{
public
function
add_annotation
(
annotation
$annotation
,
$path
,
$imagefolder
,
$annotation_index
)
{
global
$CFG
;
if
(
!
$this
->
filename
)
{
return
false
;
...
...
@@ -464,7 +464,7 @@ class pdf extends \FPDI {
$scartx
=
(
$annotation
->
cartridgex
+
$annotation
->
x
)
*
$this
->
scale
;
$scarty
=
(
$annotation
->
cartridgey
+
$annotation
->
y
)
*
$this
->
scale
;
$this
->
SetXY
(
$scartx
,
$scarty
);
$this
->
Write
(
5
,
$toolObject
->
cartridge
.
' ['
.
$annotation_index
.
']'
);
//
$this->Write(5, $toolObject->cartridge . ' [' . $annotation_index . ']');
//$this->writeHTML("<span style=border:solid;>".$toolObject->cartridge . ' [' . $annotation->id . ']'.'</span>',false);
//$this->SetLineWidth(1);
//$this->Cell(10, 5, $toolObject->cartridge . ' [' . $annotation->id . ']',1);
...
...
@@ -475,7 +475,7 @@ class pdf extends \FPDI {
$scartx
=
(
$annotation
->
cartridgex
+
$annotation
->
x
)
*
$this
->
scale
;
$scarty
=
(
$annotation
->
cartridgey
+
$annotation
->
y
)
*
$this
->
scale
;
$this
->
SetXY
(
$scartx
,
$scarty
);
$this
->
Write
(
5
,
$toolObject
->
cartridge
.
' ['
.
$annotation_index
.
']'
);
//
$this->Write(5, $toolObject->cartridge . ' [' . $annotation_index . ']');
break
;
case
'frame'
:
$w
=
abs
(
$sx
-
$ex
);
...
...
@@ -493,11 +493,11 @@ class pdf extends \FPDI {
$this
->
Rect
(
$sx
,
$sy
,
$w
,
$h
);
if
(
!
$annotation
->
parent_annot
)
{
$scartx
=
(
$annotation
->
cartridgex
)
*
$this
->
scale
;
$scartx
=
max
(
(
$annotation
->
cartridgex
)
*
$this
->
scale
,
0
)
;
$scarty
=
(
$annotation
->
cartridgey
+
$annotation
->
y
)
*
$this
->
scale
;
$this
->
SetXY
(
$scartx
,
$scarty
);
$this
->
SetTextColorArray
(
$colourarray
);
$this
->
Write
(
5
,
$toolObject
->
cartridge
.
' ['
.
$annotation_index
.
']'
);
//
$this->Write(5, $toolObject->cartridge . ' [' . $annotation_index . ']');
}
break
;
case
'stampcomment'
:
...
...
@@ -524,7 +524,7 @@ class pdf extends \FPDI {
$scartx
=
(
$annotation
->
cartridgex
+
$annotation
->
x
)
*
$this
->
scale
;
$scarty
=
(
$annotation
->
cartridgey
+
$annotation
->
y
)
*
$this
->
scale
;
$this
->
SetXY
(
$scartx
,
$scarty
);
$this
->
Write
(
5
,
$toolObject
->
cartridge
.
' ['
.
$annotation_index
.
']'
);
//
$this->Write(5, $toolObject->cartridge . ' [' . $annotation_index . ']');
break
;
case
'commentplus'
:
$imgfile
=
$CFG
->
dirroot
.
'/mod/assign/feedback/editpdfplus/pix/comment.png'
;
...
...
@@ -534,8 +534,7 @@ class pdf extends \FPDI {
$sy
=
min
(
$sy
,
$ey
);
//debugging('commentplus ' . $annotation->id . ' - ' . $sx . ':' . $sy . ' - ' . $imgfile);
$this
->
SetXY
(
$sx
+
$w
+
2
,
$sy
);
$this
->
Write
(
5
,
$toolObject
->
cartridge
.
' ['
.
$annotation_index
.
']'
);
//$this->Write(5, $toolObject->cartridge . ' [' . $annotation_index . ']');
// Stamp is always more than 40px, so no need to check width/height.
$this
->
Image
(
$imgfile
,
$sx
,
$sy
,
$w
,
$h
);
break
;
...
...
@@ -553,13 +552,21 @@ class pdf extends \FPDI {
$h
=
self
::
MIN_ANNOTATION_HEIGHT
;
}
$this
->
SetXY
(
$sx
,
$sy
);
$this
->
Write
(
5
,
$toolObject
->
cartridge
);
//
$this->Write(5, $toolObject->cartridge);
//$this->Rect($sx, $sy, $w, $h);
break
;
default
:
// Line.
$this
->
Line
(
$sx
,
$sy
,
$ex
,
$ey
);
break
;
}
if
(
$type
==
'stampplus'
||
$type
==
'commentplus'
||
$type
==
'stampcomment'
||
(
$type
==
'frame'
&&
!
$annotation
->
parent_annot
)
||
$type
==
'verticalline'
||
$type
==
'highlightplus'
)
{
$cartouche
=
$toolObject
->
cartridge
;
if
(
$annotation
->
textannot
)
{
$cartouche
.
=
' ['
.
$annotation_index
.
']'
;
}
$this
->
Write
(
5
,
$cartouche
);
}
$this
->
SetDrawColor
(
0
,
0
,
0
);
$this
->
SetLineWidth
(
1.0
*
$this
->
scale
);
...
...
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