Gitlab CSE Unil

Commit 5abe70d6 authored by M. Chardon's avatar M. Chardon
Browse files

pdf : texte des annotations + feedback global

parent 55774e24
......@@ -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);
......
......@@ -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));
}
}
......@@ -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);
......
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