Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
assignfeedback_editpdf\document_services Class Reference

Functions for generating the annotated pdf. More...

Static Public Member Functions

static copy_pages_to_readonly_area ($assignment, $grade)
 Copy the pages image to the readonly area.
 
static delete_feedback_document ($assignment, $userid, $attemptnumber)
 This function deletes the generated pdf for a student.
 
static generate_feedback_document ($assignment, $userid, $attemptnumber)
 This function takes the combined pdf and embeds all the comments and annotations.
 
static get_combined_document_for_attempt ($assignment, $userid, $attemptnumber)
 Fetch the current combined document ready for state checking.
 
static get_combined_pdf_for_attempt ($assignment, $userid, $attemptnumber)
 This function return the combined pdf for all valid submission files.
 
static get_feedback_document ($assignment, $userid, $attemptnumber)
 This function returns the generated pdf (if it exists).
 
static get_page_images_for_attempt ($assignment, $userid, $attemptnumber, $readonly=false)
 This function returns a list of the page images from a pdf.
 
static page_number_for_attempt ($assignment, $userid, $attemptnumber, $readonly=false)
 This function will return the number of pages of a pdf.
 
static rotate_page ($assignment, $userid, $attemptnumber, $index, $rotateleft)
 This function rotate a page, and mark the page as rotated.
 

Public Attributes

const BLANK_PDF_BASE64 =
 Base64 encoded blank pdf.
 
const BLANK_PDF_HASH = '4c803c92c71f21b423d13de570c8a09e0a31c718'
 Hash of blank pdf.
 
const COMBINED_PDF_FILEAREA = 'combined'
 File area for combined pdf.
 
const COMBINED_PDF_FILENAME = 'combined.pdf'
 Filename for combined pdf.
 
const COMPONENT = "assignfeedback_editpdf"
 Compoment name.
 
const FINAL_PDF_FILEAREA = 'download'
 File area for generated pdf.
 
const IMPORT_HTML_FILEAREA = 'importhtml'
 File area for importing html.
 
const PAGE_IMAGE_FILEAREA = 'pages'
 File area for page images.
 
const PAGE_IMAGE_READONLY_FILEAREA = 'readonlypages'
 File area for readonly page images.
 
const PARTIAL_PDF_FILEAREA = 'partial'
 File area for partial combined pdf.
 
const STAMPS_FILEAREA = 'stamps'
 File area for the stamps.
 
const TMP_JPG_TO_PDF_FILEAREA = 'tmp_jpg_to_pdf'
 Temporary place to save JPG Image to PDF file.
 
const TMP_ROTATED_JPG_FILEAREA = 'tmp_rotated_jpg'
 Temporary place to save (Automatically) Rotated JPG FILE.
 

Static Protected Member Functions

static generate_page_images_for_attempt ($assignment, $userid, $attemptnumber, $resetrotation=true)
 This function will generate and return a list of the page images from a pdf.
 
static get_downloadable_feedback_filename ($assignment, $userid, $attemptnumber)
 This function returns sensible filename for a feedback file.
 
static list_compatible_submission_files_for_attempt ($assignment, $userid, $attemptnumber)
 This function will search for all files that can be converted and concatinated into a PDF (1.4) - for any submission plugin for this students attempt.
 
static strip_images ($html)
 Use a DOM parser to accurately replace images with their alt text.
 

Detailed Description

Functions for generating the annotated pdf.

This class controls the ingest of student submission files to a normalised PDF 1.4 document with all submission files concatinated together. It also provides the functions to generate a downloadable pdf with all comments and annotations embedded.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ copy_pages_to_readonly_area()

static assignfeedback_editpdf\document_services::copy_pages_to_readonly_area ( $assignment,
$grade )
static

Copy the pages image to the readonly area.

Parameters
int | assign$assignmentThe assignment.
stdClass$gradeThe grade record.
Return values
void

◆ delete_feedback_document()

static assignfeedback_editpdf\document_services::delete_feedback_document ( $assignment,
$userid,
$attemptnumber )
static

This function deletes the generated pdf for a student.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
Return values
bool

◆ generate_feedback_document()

static assignfeedback_editpdf\document_services::generate_feedback_document ( $assignment,
$userid,
$attemptnumber )
static

This function takes the combined pdf and embeds all the comments and annotations.

This also moves the annotations and comments from drafts to not drafts. And it will copy all the images stored to the readonly area, so that they can be viewed online, and not be overwritten when a new submission is sent.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
Return values
stored_file

◆ generate_page_images_for_attempt()

static assignfeedback_editpdf\document_services::generate_page_images_for_attempt ( $assignment,
$userid,
$attemptnumber,
$resetrotation = true )
staticprotected

This function will generate and return a list of the page images from a pdf.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
bool$resetrotationcheck if need to reset page rotation information
Return values
array(stored_file)

◆ get_combined_document_for_attempt()

static assignfeedback_editpdf\document_services::get_combined_document_for_attempt ( $assignment,
$userid,
$attemptnumber )
static

Fetch the current combined document ready for state checking.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
Return values
combined_document

◆ get_combined_pdf_for_attempt()

static assignfeedback_editpdf\document_services::get_combined_pdf_for_attempt ( $assignment,
$userid,
$attemptnumber )
static

This function return the combined pdf for all valid submission files.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
Return values
combined_document

◆ get_downloadable_feedback_filename()

static assignfeedback_editpdf\document_services::get_downloadable_feedback_filename ( $assignment,
$userid,
$attemptnumber )
staticprotected

This function returns sensible filename for a feedback file.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
Return values
string

◆ get_feedback_document()

static assignfeedback_editpdf\document_services::get_feedback_document ( $assignment,
$userid,
$attemptnumber )
static

This function returns the generated pdf (if it exists).

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
Return values
stored_file

◆ get_page_images_for_attempt()

static assignfeedback_editpdf\document_services::get_page_images_for_attempt ( $assignment,
$userid,
$attemptnumber,
$readonly = false )
static

This function returns a list of the page images from a pdf.

The readonly version is different than the normal one. The readonly version contains a copy of the pages in the state they were when the PDF was annotated, by doing so we prevent the the pages that are displayed to change as soon as the submission changes.

Though there is an edge case, if the PDF was annotated before MDL-45580, then it is possible that we do not find any readonly version of the pages. In that case, we will get the normal pages and copy them to the readonly area. This ensures that the pages will remain in that state until the submission is updated. When the normal files do not exist, we throw an exception because the readonly pages should only ever be displayed after a teacher has annotated the PDF, they would not exist until they do.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
bool$readonlyIf true, then we are requesting the readonly version.
Return values
array(stored_file)

◆ list_compatible_submission_files_for_attempt()

static assignfeedback_editpdf\document_services::list_compatible_submission_files_for_attempt ( $assignment,
$userid,
$attemptnumber )
staticprotected

This function will search for all files that can be converted and concatinated into a PDF (1.4) - for any submission plugin for this students attempt.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
Return values
combined_document

◆ page_number_for_attempt()

static assignfeedback_editpdf\document_services::page_number_for_attempt ( $assignment,
$userid,
$attemptnumber,
$readonly = false )
static

This function will return the number of pages of a pdf.

Parameters
int | assign$assignment
int$userid
int$attemptnumber(-1 means latest attempt)
bool$readonlyWhen true we get the number of pages for the readonly version.
Return values
intnumber of pages

◆ rotate_page()

static assignfeedback_editpdf\document_services::rotate_page ( $assignment,
$userid,
$attemptnumber,
$index,
$rotateleft )
static

This function rotate a page, and mark the page as rotated.

Parameters
int | assign$assignmentAssignment
int$useridUser ID
int$attemptnumberAttempt Number
int$indexIndex of Current Page
bool$rotateleftTo determine whether the page is rotated left or right.
Return values
null|stored_filereturn rotated File
Exceptions
coding_exception
file_exception
moodle_exception
stored_file_creation_exception

◆ strip_images()

static assignfeedback_editpdf\document_services::strip_images ( $html)
staticprotected

Use a DOM parser to accurately replace images with their alt text.

Parameters
string$html
Return values
stringNew html with no image tags.

Member Data Documentation

◆ BLANK_PDF_BASE64

const assignfeedback_editpdf\document_services::BLANK_PDF_BASE64 =

Base64 encoded blank pdf.

This is the most reliable/fastest way to generate a blank pdf.


The documentation for this class was generated from the following file: