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
7d0ead4c
Commit
7d0ead4c
authored
May 23, 2018
by
M. Chardon
Browse files
maj plugin pour compatibilité moodle 3.5
parent
80ee5635
Changes
35
Show whitespace changes
Inline
Side-by-side
backup/moodle2/restore_assignfeedback_editpdfplus_subplugin.class.php
View file @
7d0ead4c
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
...
...
@@ -62,13 +63,11 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin {
* @param mixed $data
*/
public
function
process_assignfeedback_editpdfplus_files
(
$data
)
{
$data
=
(
object
)
$data
;
$data
=
(
object
)
$data
;
// In this case the id is the old gradeid which will be mapped.
$this
->
add_related_files
(
'assignfeedback_editpdfplus'
,
\
assignfeedback_editpdfplus\document_services
::
FINAL_PDF_FILEAREA
,
'grade'
,
null
,
$data
->
gradeid
);
$this
->
add_related_files
(
'assignfeedback_editpdfplus'
,
\
assignfeedback_editpdfplus\document_services
::
PAGE_IMAGE_READONLY_FILEAREA
,
'grade'
,
null
,
$data
->
gradeid
);
$this
->
add_related_files
(
'assignfeedback_editpdfplus'
,
\
assignfeedback_editpdfplus\document_services
::
FINAL_PDF_FILEAREA
,
'grade'
,
null
,
$data
->
gradeid
);
$this
->
add_related_files
(
'assignfeedback_editpdfplus'
,
\
assignfeedback_editpdfplus\document_services
::
PAGE_IMAGE_READONLY_FILEAREA
,
'grade'
,
null
,
$data
->
gradeid
);
$this
->
add_related_files
(
'assignfeedback_editpdfplus'
,
'stamps'
,
'grade'
,
null
,
$data
->
gradeid
);
}
...
...
@@ -79,14 +78,13 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin {
public
function
process_assignfeedback_editpdfplus_feedback_editpdfplus_annotation
(
$data
)
{
global
$DB
;
$data
=
(
object
)
$data
;
$data
=
(
object
)
$data
;
$oldgradeid
=
$data
->
gradeid
;
// The mapping is set in the restore for the core assign activity
// when a grade node is processed.
$data
->
gradeid
=
$this
->
get_mappingid
(
'grade'
,
$data
->
gradeid
);
$DB
->
insert_record
(
'assignfeedback_editpp_annot'
,
$data
);
}
}
classes/document_services.php
View file @
7d0ead4c
...
...
@@ -99,7 +99,7 @@ EOD;
require_once
(
$CFG
->
dirroot
.
'/mod/assign/locallib.php'
);
if
(
!
is_object
(
$assignment
))
{
$cm
=
\
get_coursemodule_from_instance
(
'assign'
,
$assignment
,
0
,
false
,
MUST_EXIST
);
$cm
=
get_coursemodule_from_instance
(
'assign'
,
$assignment
,
0
,
false
,
MUST_EXIST
);
$context
=
\
context_module
::
instance
(
$cm
->
id
);
$assignment
=
new
\
assign
(
$context
,
null
,
null
);
...
...
@@ -166,7 +166,7 @@ EOD;
// Capability checks.
if
(
!
$assignment
->
can_view_submission
(
$userid
))
{
\
print_error
(
'nopermission'
);
print_error
(
'nopermission'
);
}
$files
=
array
();
...
...
@@ -196,7 +196,7 @@ EOD;
}
else
if
(
$convertedfile
=
$converter
->
start_conversion
(
$file
,
'pdf'
))
{
$files
[
$filename
]
=
$convertedfile
;
}
}
else
{
}
else
if
(
$converter
->
can_convert_format_to
(
'html'
,
'pdf'
))
{
// Create a tmp stored_file from this html string.
$file
=
reset
(
$file
);
// Strip image tags, because they will not be resolvable.
...
...
@@ -225,7 +225,6 @@ EOD;
$htmlfile
=
$fs
->
create_file_from_string
(
$record
,
$file
);
}
//$convertedfile = $fs->get_converted_document($htmlfile, 'pdf');
$convertedfile
=
$converter
->
start_conversion
(
$htmlfile
,
'pdf'
);
if
(
$convertedfile
)
{
...
...
@@ -315,131 +314,8 @@ EOD;
$document
->
combine_files
(
$assignment
->
get_context
()
->
id
,
$grade
->
id
);
return
$document
;
}
/* global $USER, $DB;
$assignment = self::get_assignment_from_param($assignment);
// Capability checks.
if (!$assignment->can_view_submission($userid)) {
\print_error('nopermission');
}
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
if ($assignment->get_instance()->teamsubmission) {
$submission = $assignment->get_group_submission($userid, 0, false);
} else {
$submission = $assignment->get_user_submission($userid, false);
}
$contextid = $assignment->get_context()->id;
$component = 'assignfeedback_editpdfplus';
$filearea = self::COMBINED_PDF_FILEAREA;
$itemid = $grade->id;
$filepath = '/';
$filename = self::COMBINED_PDF_FILENAME;
$fs = \get_file_storage();
$combinedpdf = $fs->get_file($contextid, $component, $filearea, $itemid, $filepath, $filename);
if (!$combinedpdf ||
($submission && ($combinedpdf->get_timemodified() < $submission->timemodified))) {
return self::generate_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
}
return $combinedpdf; */
}
/**
* This function will take all of the compatible files for a submission
* and combine them into one PDF.
*
* @param int|\assign $assignment
* @param int $userid
* @param int $attemptnumber (-1 means latest attempt)
* @return stored_file
*
* @deprecated since version 31
*/
/* public static function generate_combined_pdf_for_attempt($assignment, $userid, $attemptnumber) {
global $CFG;
require_once($CFG->libdir . '/pdflib.php');
$assignment = self::get_assignment_from_param($assignment);
if (!$assignment->can_view_submission($userid)) {
\print_error('nopermission');
}
$files = self::list_compatible_submission_files_for_attempt($assignment, $userid, $attemptnumber);
$pdf = new pdf();
if ($files) {
// Create a mega joined PDF.
$compatiblepdfs = array();
foreach ($files as $file) {
$compatiblepdf = pdf::ensure_pdf_compatible($file);
if ($compatiblepdf) {
array_push($compatiblepdfs, $compatiblepdf);
}
}
$tmpdir = \make_temp_directory('assignfeedback_editpdfplus/combined/' . self::hash($assignment, $userid, $attemptnumber));
$tmpfile = $tmpdir . '/' . self::COMBINED_PDF_FILENAME;
@unlink($tmpfile);
try {
$pagecount = $pdf->combine_pdfs($compatiblepdfs, $tmpfile);
} catch (\Exception $e) {
debugging('TCPDF could not process the pdf files:' . $e->getMessage(), DEBUG_DEVELOPER);
// TCPDF does not recover from errors so we need to re-initialise the class.
$pagecount = 0;
}
if ($pagecount == 0) {
// We at least want a single blank page.
debugging('TCPDF did not produce a valid pdf:' . $tmpfile . '. Replacing with a blank pdf.', DEBUG_DEVELOPER);
@unlink($tmpfile);
$files = false;
}
}
$pdf->Close(); // No real need to close this pdf, because it has been saved by combine_pdfs(), but for clarity.
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$record = new \stdClass();
$record->contextid = $assignment->get_context()->id;
$record->component = 'assignfeedback_editpdfplus';
$record->filearea = self::COMBINED_PDF_FILEAREA;
$record->itemid = $grade->id;
$record->filepath = '/';
$record->filename = self::COMBINED_PDF_FILENAME;
$fs = \get_file_storage();
$fs->delete_area_files($record->contextid, $record->component, $record->filearea, $record->itemid);
// Detect corrupt generated pdfs and replace with a blank one.
if ($files) {
$verifypdf = new pdf();
$pagecount = $verifypdf->load_pdf($tmpfile);
if ($pagecount <= 0) {
$files = false;
}
$verifypdf->Close(); // PDF loaded and never saved/outputted needs to be closed.
}
if (!$files) {
$file = $fs->create_file_from_string($record, base64_decode(self::BLANK_PDF_BASE64));
} else {
// This was a combined pdf.
$file = $fs->create_file_from_pathname($record, $tmpfile);
@unlink($tmpfile);
// Test the generated file for correctness.
$compatiblepdf = pdf::ensure_pdf_compatible($file);
}
return $file;
} */
/**
* This function will return the number of pages of a pdf.
*
...
...
@@ -457,7 +333,7 @@ EOD;
$assignment
=
self
::
get_assignment_from_param
(
$assignment
);
if
(
!
$assignment
->
can_view_submission
(
$userid
))
{
\
print_error
(
'nopermission'
);
print_error
(
'nopermission'
);
}
// When in readonly we can return the number of images in the DB because they should already exist,
...
...
@@ -475,26 +351,6 @@ EOD;
// Get a combined pdf file from all submitted pdf files.
$document
=
self
::
get_combined_pdf_for_attempt
(
$assignment
,
$userid
,
$attemptnumber
);
return
$document
->
get_page_count
();
/* $file = self::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
if (!$file) {
\print_error('Could not generate combined pdf.');
}
// Store the combined pdf file somewhere to be opened by tcpdf.
$tmpdir = \make_temp_directory('assignfeedback_editpdfplus/pagetotal/'
. self::hash($assignment, $userid, $attemptnumber));
$combined = $tmpdir . '/' . self::COMBINED_PDF_FILENAME;
$file->copy_content_to($combined); // Copy the file.
// Get the total number of pages.
$pdf = new pdf();
$pagecount = $pdf->set_pdf($combined);
$pdf->Close(); // PDF loaded and never saved/outputted needs to be closed.
// Delete temporary folders and files.
@unlink($combined);
@rmdir($tmpdir);
return $pagecount; */
}
/**
...
...
@@ -512,15 +368,11 @@ EOD;
$assignment
=
self
::
get_assignment_from_param
(
$assignment
);
if
(
!
$assignment
->
can_view_submission
(
$userid
))
{
\
print_error
(
'nopermission'
);
print_error
(
'nopermission'
);
}
// Need to generate the page images - first get a combined pdf.
$document
=
self
::
get_combined_pdf_for_attempt
(
$assignment
,
$userid
,
$attemptnumber
);
/* $file = self::get_combined_pdf_for_attempt($assignment, $userid, $attemptnumber);
if (!$file) {
throw new \moodle_exception('Could not generate combined pdf.');
} */
$status
=
$document
->
get_status
();
if
(
$status
===
combined_document
::
STATUS_FAILED
)
{
...
...
@@ -533,7 +385,6 @@ EOD;
$tmpdir
=
\
make_temp_directory
(
'assignfeedback_editpdfplus/pageimages/'
.
self
::
hash
(
$assignment
,
$userid
,
$attemptnumber
));
$combined
=
$tmpdir
.
'/'
.
self
::
COMBINED_PDF_FILENAME
;
$document
->
get_combined_file
()
->
copy_content_to
(
$combined
);
// Copy the file.
//$file->copy_content_to($combined); // Copy the file.
$pdf
=
new
pdf
();
...
...
@@ -561,7 +412,6 @@ EOD;
// We catch only moodle_exception here as other exceptions indicate issue with setup not the pdf.
$image
=
pdf
::
get_error_image
(
$tmpdir
,
$i
);
}
//$image = $pdf->get_image($i);
$record
->
filename
=
basename
(
$image
);
$files
[
$i
]
=
$fs
->
create_file_from_pathname
(
$record
,
$tmpdir
.
'/'
.
$image
);
@
unlink
(
$tmpdir
.
'/'
.
$image
);
...
...
@@ -600,7 +450,7 @@ EOD;
$assignment
=
self
::
get_assignment_from_param
(
$assignment
);
if
(
!
$assignment
->
can_view_submission
(
$userid
))
{
\
print_error
(
'nopermission'
);
print_error
(
'nopermission'
);
}
if
(
$assignment
->
get_instance
()
->
teamsubmission
)
{
...
...
@@ -649,7 +499,6 @@ EOD;
}
}
}
//if (!$readonly && $first->get_timemodified() < $submission->timemodified) {
if
(
!
$readonly
&&
(
$pagemodified
<
$submission
->
timemodified
||
$blankpage
))
{
// Image files are stale, we need to regenerate them, except in readonly mode.
// We also need to remove the draft annotations and comments associated with this attempt.
...
...
classes/page_editor.php
View file @
7d0ead4c
...
...
@@ -46,6 +46,7 @@ class page_editor {
*/
public
static
function
get_tools
(
$contextidlist
)
{
global
$DB
;
$tools
=
array
();
if
(
$contextidlist
)
{
$records
=
$DB
->
get_records_list
(
'assignfeedback_editpp_tool'
,
'contextid'
,
$contextidlist
);
...
...
@@ -285,12 +286,6 @@ class page_editor {
$newid
=
$DB
->
insert_record
(
'assignfeedback_editpp_annot'
,
$record
);
$parentlink
[
$oldid
]
=
$newid
;
}
/* $records = $DB->get_records('assignfeedback_editpp_cmnt', array('gradeid' => $gradeid, 'draft' => 1));
foreach ($records as $record) {
unset($record->id);
$record->draft = 0;
$DB->insert_record('assignfeedback_editpp_cmnt', $record);
} */
return
true
;
}
...
...
@@ -334,12 +329,6 @@ class page_editor {
$record
->
draft
=
0
;
$DB
->
insert_record
(
'assignfeedback_editpp_annot'
,
$record
);
}
/* $records = $DB->get_records('assignfeedback_editpp_cmnt', array('gradeid' => $gradeid, 'draft' => 0));
foreach ($records as $record) {
unset($record->id);
$record->draft = 0;
$DB->insert_record('assignfeedback_editpp_annot', $record);
} */
return
true
;
}
...
...
@@ -384,11 +373,9 @@ class page_editor {
// Delete any existing annotations and comments from current user.
$DB
->
delete_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$grade
->
id
));
//$DB->delete_records('assignfeedback_editpp_cmnt', array('gradeid' => $grade->id));
// Get gradeid, annotations and comments from sourceuserid.
$sourceusergrade
=
$assignment
->
get_user_grade
(
$sourceuserid
,
true
,
$grade
->
attemptnumber
);
$annotations
=
$DB
->
get_records
(
'assignfeedback_editpp_annot'
,
array
(
'gradeid'
=>
$sourceusergrade
->
id
,
'draft'
=>
1
));
//$comments = $DB->get_records('assignfeedback_editpp_cmnt', array('gradeid' => $sourceusergrade->id, 'draft' => 1));
$contextid
=
$assignment
->
get_context
()
->
id
;
$sourceitemid
=
$sourceusergrade
->
id
;
...
...
@@ -397,10 +384,6 @@ class page_editor {
$annotation
->
gradeid
=
$grade
->
id
;
$DB
->
insert_record
(
'assignfeedback_editpp_annot'
,
$annotation
);
}
/* foreach ($comments as $comment) {
$comment->gradeid = $grade->id;
$DB->insert_record('assignfeedback_editpp_cmnt', $comment);
} */
$fs
=
get_file_storage
();
...
...
@@ -472,13 +455,6 @@ class page_editor {
global
$CFG
;
switch
(
$newToolType
->
label
)
{
case
'highlightplus'
:
/*if (isset($CFG->highlightplus_configurable) && (intval($CFG->highlightplus_configurable) == 0 || intval($CFG->highlightplus_configurable) == 1)) {
if (intval($CFG->highlightplus_configurable) == 0) {
$newToolType->configurable = 1;
} else {
$newToolType->configurable = 0;
}
}*/
if
(
isset
(
$CFG
->
highlightplus_color
)
&&
$CFG
->
highlightplus_color
!=
null
&&
strlen
(
$CFG
->
highlightplus_color
)
>
4
)
{
$newToolType
->
color
=
$CFG
->
highlightplus_color
;
}
...
...
@@ -494,26 +470,12 @@ class page_editor {
break
;
case
'stampplus'
:
/*if (isset($CFG->stampplus_configurable) && (intval($CFG->stampplus_configurable) == 0 || intval($CFG->stampplus_configurable) == 1)) {
if (intval($CFG->stampplus_configurable) == 0) {
$newToolType->configurable = 1;
} else {
$newToolType->configurable = 0;
}
}*/
if
(
isset
(
$CFG
->
stampplus_color
)
&&
$CFG
->
stampplus_color
!=
null
&&
strlen
(
$CFG
->
stampplus_color
)
>
4
)
{
$newToolType
->
color
=
$CFG
->
stampplus_color
;
}
break
;
case
'frame'
:
/*if (isset($CFG->frame_configurable) && (intval($CFG->frame_configurable) == 0 || intval($CFG->frame_configurable) == 1)) {
if (intval($CFG->frame_configurable) == 0) {
$newToolType->configurable = 1;
} else {
$newToolType->configurable = 0;
}
}*/
if
(
isset
(
$CFG
->
frame_cartridge_x
)
&&
(
intval
(
$CFG
->
frame_cartridge_x
)
||
$CFG
->
frame_cartridge_x
==
'0'
))
{
$newToolType
->
cartridge_x
=
intval
(
$CFG
->
frame_cartridge_x
);
}
...
...
@@ -523,13 +485,6 @@ class page_editor {
break
;
case
'verticalline'
:
/*if (isset($CFG->verticalline_configurable) && (intval($CFG->verticalline_configurable) == 0 || intval($CFG->verticalline_configurable) == 1)) {
if (intval($CFG->verticalline_configurable) == 0) {
$newToolType->configurable = 1;
} else {
$newToolType->configurable = 0;
}
}*/
if
(
isset
(
$CFG
->
verticalline_color
)
&&
$CFG
->
verticalline_color
!=
null
&&
strlen
(
$CFG
->
verticalline_color
)
>
4
)
{
$newToolType
->
color
=
$CFG
->
verticalline_color
;
}
...
...
@@ -545,16 +500,6 @@ class page_editor {
break
;
case
'stampcomment'
:
/*if (isset($CFG->stampcomment_configurable) && (intval($CFG->stampcomment_configurable) == 0 || intval($CFG->stampcomment_configurable) == 1)) {
if (intval($CFG->stampcomment_configurable) == 0) {
$newToolType->configurable = 1;
} else {
$newToolType->configurable = 0;
}
}*/
/*if (isset($CFG->stampcomment_color) && $CFG->stampcomment_color != null && strlen($CFG->stampcomment_color) > 4) {
$newToolType->color = $CFG->stampcomment_color;
}*/
if
(
isset
(
$CFG
->
stampcomment_cartridge_color
)
&&
$CFG
->
stampcomment_cartridge_color
!=
null
&&
strlen
(
$CFG
->
stampcomment_cartridge_color
)
>
4
)
{
$newToolType
->
cartridge_color
=
$CFG
->
stampcomment_cartridge_color
;
}
...
...
@@ -567,13 +512,6 @@ class page_editor {
break
;
case
'commentplus'
:
/*if (isset($CFG->commentplus_configurable) && (intval($CFG->commentplus_configurable) == 0 || intval($CFG->commentplus_configurable) == 1)) {
if (intval($CFG->commentplus_configurable) == 0) {
$newToolType->configurable = 1;
} else {
$newToolType->configurable = 0;
}
}*/
if
(
isset
(
$CFG
->
commentplus_cartridge_color
)
&&
$CFG
->
commentplus_cartridge_color
!=
null
&&
strlen
(
$CFG
->
commentplus_cartridge_color
)
>
4
)
{
$newToolType
->
cartridge_color
=
$CFG
->
commentplus_cartridge_color
;
}
...
...
classes/pdf.php
View file @
7d0ead4c
...
...
@@ -83,7 +83,7 @@ class pdf extends \FPDI {
const
MIN_ANNOTATION_HEIGHT
=
5
;
/** Blank PDF file used during error. */
const
BLANK_PDF
=
'/mod/assign/feedback/editpdf/fixtures/blank.pdf'
;
const
BLANK_PDF
=
'/mod/assign/feedback/editpdf
plus
/fixtures/blank.pdf'
;
/**
* Combine the given PDF files into a single PDF. Optionally add a coversheet and coversheet fields.
...
...
@@ -558,8 +558,8 @@ class pdf extends \FPDI {
/**
* Generate an image of the specified page in the PDF
* @param int $pageno the page to generate the image of
* @throws moodle_exception
* @throws coding_exception
* @throws
\
moodle_exception
* @throws
\
coding_exception
* @return string the filename of the generated image
*/
public
function
get_image
(
$pageno
)
{
...
...
@@ -621,59 +621,12 @@ class pdf extends \FPDI {
public
static
function
ensure_pdf_compatible
(
\
stored_file
$file
)
{
global
$CFG
;
//
$temparea = make_temp_directory('assignfeedback_editpdfplus');
//
Copy the stored_file to local disk for checking.
$temparea
=
make_request_directory
();
//$hash = $file->get_contenthash(); // Use the contenthash to make sure the temp files have unique names.
//$tempsrc = $temparea . "/src-$hash.pdf";
//$tempdst = $temparea . "/dst-$hash.pdf";
$tempsrc
=
$temparea
.
"/source.pdf"
;
$file
->
copy_content_to
(
$tempsrc
);
// Copy the file.
$file
->
copy_content_to
(
$tempsrc
);
return
self
::
ensure_pdf_file_compatible
(
$tempsrc
);
/* $pdf = new pdf();
$pagecount = 0;
try {
$pagecount = $pdf->load_pdf($tempsrc);
} catch (\Exception $e) {
// PDF was not valid - try running it through ghostscript to clean it up.
$pagecount = 0;
}
$pdf->Close(); // PDF loaded and never saved/outputted needs to be closed.
if ($pagecount > 0) {
// Page is valid and can be read by tcpdf.
return $tempsrc;
}
$gsexec = \escapeshellarg($CFG->pathtogs);
$tempdstarg = \escapeshellarg($tempdst);
$tempsrcarg = \escapeshellarg($tempsrc);
$command = "$gsexec -q -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -sOutputFile=$tempdstarg $tempsrcarg";
exec($command);
@unlink($tempsrc);
if (!file_exists($tempdst)) {
// Something has gone wrong in the conversion.
return false;
}
$pdf = new pdf();
$pagecount = 0;
try {
$pagecount = $pdf->load_pdf($tempdst);
} catch (\Exception $e) {
// PDF was not valid - try running it through ghostscript to clean it up.
$pagecount = 0;
}
$pdf->Close(); // PDF loaded and never saved/outputted needs to be closed.
if ($pagecount <= 0) {
@unlink($tempdst);
// Could not parse the converted pdf.
return false;
}
return $tempdst; */
}
/**
...
...
@@ -771,7 +724,7 @@ class pdf extends \FPDI {
/**
* Test that the configured path to ghostscript is correct and working.
* @param bool $generateimage - If true - a test image will be generated to verify the install.
* @return
bool
* @return
\stdClass
*/
public
static
function
test_gs_path
(
$generateimage
=
true
)
{
global
$CFG
;
...
...
classes/privacy/provider.php
0 → 100644
View file @
7d0ead4c
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy class for requesting user data.
*
* @package assignfeedback_editpdfplus
* @copyright 2018 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
assignfeedback_editpdfplus\privacy
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
require_once
(
$CFG
->
dirroot
.
'/mod/assign/locallib.php'
);
use
\
core_privacy\local\metadata\collection
;
use
\
core_privacy\local\metadata\provider
as
metadataprovider
;
use
\
mod_assign\privacy\assignfeedback_provider
;
use
\
core_privacy\local\request\writer
;
use
\
core_privacy\local\request\contextlist
;
use
\
mod_assign\privacy\assign_plugin_request_data
;
use
\
mod_assign\privacy\useridlist
;
/**
* Privacy class for requesting user data.
*
* @package assignfeedback_editpdfplus
* @copyright 2018 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
provider
implements
metadataprovider
,
assignfeedback_provider
{
/**
* Return meta data about this plugin.
*
* @param collection $collection A list of information to add to.
* @return collection Return the collection after adding to it.
*/
public
static
function
get_metadata
(
collection
$collection
)
:
collection
{
$quickdata
=
[
'userid'
=>
'privacy:metadata:userid'
,
'rawtext'
=>
'privacy:metadata:rawtextpurpose'
,
'colour'
=>
'privacy:metadata:colourpurpose'
];
$collection
->
add_database_table
(
'assignfeedback_editpp_quick'
,
$quickdata
,
'privacy:metadata:tablepurpose'
);
$collection
->
add_subsystem_link
(
'core_files'
,
[],
'privacy:metadata:filepurpose'
);
$collection
->
add_subsystem_link
(
'core_fileconverter'
,
[],
'privacy:metadata:conversionpurpose'
);
return
$collection
;
}
/**
* No need to fill in this method as all information can be acquired from the assign_grades table in the mod assign
* provider.
*
* @param int $userid The user ID.
* @param contextlist $contextlist The context list.
*/
public
static
function
get_context_for_userid_within_feedback
(
int
$userid
,
contextlist
$contextlist
)
{
// This uses the assign_grade table.
}
/**
* This also does not need to be filled in as this is already collected in the mod assign provider.
*
* @param useridlist $useridlist A list of user IDs
*/
public
static
function
get_student_user_ids
(
useridlist
$useridlist
)
{
// Not required.
}
/**
* Export all user data for this plugin.
*
* @param assign_plugin_request_data $exportdata Data used to determine which context and user to export and other useful
* information to help with exporting.
*/
public
static
function
export_feedback_user_data
(
assign_plugin_request_data
$exportdata
)
{
$currentpath
=
$exportdata
->
get_subcontext
();
$currentpath
[]
=
get_string
(
'privacy:path'
,
'assignfeedback_editpdfplus'
);
$assign
=
$exportdata
->
get_assign
();
$plugin
=
$assign
->
get_plugin_by_type
(
'assignfeedback'
,
'editpdfplus'
);
$fileareas
=
$plugin
->
get_file_areas
();
$grade
=
$exportdata
->
get_pluginobject
();
foreach
(
$fileareas
as
$filearea
=>
$notused
)
{
writer
::
with_context
(
$exportdata
->
get_context
())
->
export_area_files
(
$currentpath
,
'assignfeedback_editpdfplus'
,
$filearea
,
$grade
->
id
);
}
}
/**
* Any call to this method should delete all user data for the context defined in the deletion_criteria.
*
* @param assign_plugin_request_data $requestdata Data useful for deleting user data from this sub-plugin.
*/
public
static
function
delete_feedback_for_context
(
assign_plugin_request_data
$requestdata
)
{