Gitlab CSE Unil

Commit 537eddf0 authored by M. Chardon's avatar M. Chardon
Browse files

noettoyage et optimisation code avec sonarqube

parent 1ffa90b3
/.old/
\ No newline at end of file
/.old/
/.scannerwork/
\ No newline at end of file
......@@ -177,30 +177,29 @@ if ($action === 'pollconversions') {
$modulename = get_string('modulename', 'assign');
$assignmentname = $assignment->get_instance()->name;
$formatparams = array('context' => $contextb->get_course_context());
$flecheHtml = ' → ';
$retourChariot = "\n";
$body = format_string($course->shortname, true, $formatparams)
. ' -> '
. $flecheHtml
. $modulename
. ' -> '
. format_string($assignmentname, true, $formatparams) . "\n"
. "\n---------------------------------------------------------------------\n"
. $flecheHtml
. format_string($assignmentname, true, $formatparams) . $retourChariot
. $retourChariot . "---------------------------------------------------------------------" . $retourChariot
. "La correction du devoir a été mise à jour. Vous pouvez accéder au document en suivant ce lien : "
. $response->url
. "\n\nCeci est un mail automatique.";
. $retourChariot . $retourChariot . "Ceci est un mail automatique.";
$bodyhtml = '<p><font face="sans-serif">'
. '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">'
. format_string($course->shortname, true, $formatparams)
. '</a> ->'
. '<a href="' . $CFG->wwwroot . '/mod/assign/index.php?id=' . $course->id . '">'
. $modulename
. '</a> ->'
. '<a href="' . $CFG->wwwroot . '/mod/assign/view.php?id=' . $coursemodule->id . '">'
. format_string($assignmentname, true, $formatparams)
. '</a></font></p>'
. '<hr /><font face="sans-serif">'
. getHtmlLink($CFG->wwwroot . '/course/view.php?id=' . $course->id, format_string($course->shortname, true, $formatparams))
. $flecheHtml
. getHtmlLink($CFG->wwwroot . '/mod/assign/index.php?id=' . $course->id, $modulename)
. $flecheHtml
. getHtmlLink($CFG->wwwroot . '/mod/assign/view.php?id=' . $coursemodule->id, format_string($assignmentname, true, $formatparams))
. '</font></p>'
. '<hr/><font face="sans-serif">'
. "<b>Information Moodle</b><br/>"
. "<p>La correction du devoir a été mise à jour. Vous pouvez accéder au document en suivant ce <a href='"
. $response->url
. "'>lien</a></p>"
. "<p>La correction du devoir a été mise à jour. Vous pouvez accéder au document en suivant ce "
. getHtmlLink($response->url, "lien")
. "</p>"
. "<i>Ceci est un mail automatique, merci de ne pas y répondre.</i>";
foreach ($teachers as $teacher) {
$res = email_to_user($teacher, $USER, "[Moodle] Mise à jour devoir", $body, $bodyhtml);
......@@ -247,3 +246,6 @@ if ($action === 'pollconversions') {
die();
}
function getHtmlLink($url, $text) {
return '<a href="' . $url . '">' . $text . '</a>';
}
......@@ -38,6 +38,26 @@ use assignfeedback_editpdfplus\axis;
*/
class admin_editor {
const BDDTABLETOOL = "assignfeedback_editpp_tool";
const BDDTABLEAXE = "assignfeedback_editpp_axis";
const BDDTABLETOOLTYPE = "assignfeedback_editpp_typet";
const CONTEXTIDLIB = "contextid";
/**
* Make an SQL moodle select request from the 3 arguments
* @param string $select the select part
* @param string $table the moodle table
* @param string $where the where part
* @return string the string request
*/
public static function makeSqlRequestSelect($select, $table, $where = null) {
$request = 'SELECT ' . $select . ' FROM {' . $table . '} ';
if ($where) {
$request .= " WHERE " . $where;
}
return $request;
}
/**
* Add an axis
* @global type $DB
......@@ -48,7 +68,8 @@ class admin_editor {
public static function add_axis($axisLabel, $context) {
global $DB;
$record = $DB->get_record_sql('SELECT max(order_axis) as order_max FROM {assignfeedback_editpp_axis} WHERE contextid = :contextid', array('contextid' => $context));
$record = $DB->get_record_sql(self::makeSqlRequestSelect("max(order_axis) as order_max", self::BDDTABLEAXE, self::CONTEXTIDLIB . ' = :' . self::CONTEXTIDLIB)
, array(self::CONTEXTIDLIB => $context));
$axis = new axis();
$axis->contextid = $context;
......@@ -59,7 +80,7 @@ class admin_editor {
$axis->order_axis = $record->order_max + 1;
}
return $DB->insert_record('assignfeedback_editpp_axis', $axis);
return $DB->insert_record(self::BDDTABLEAXE, $axis);
}
/**
......@@ -97,7 +118,7 @@ class admin_editor {
$tool->order_tool = $maxindice + 1;
}
$toolid = $DB->insert_record('assignfeedback_editpp_tool', $tool);
$toolid = $DB->insert_record(self::BDDTABLETOOL, $tool);
if ($toolid > 0) {
if ($reorder) {
......@@ -110,17 +131,17 @@ class admin_editor {
public static function edit_tool_order($data) {
global $DB;
$record = $DB->get_record('assignfeedback_editpp_tool', array('id' => $data->toolid), '*', MUST_EXIST);
$record = $DB->get_record(self::BDDTABLETOOL, array('id' => $data->toolid), '*', MUST_EXIST);
$toolCurrent = new tool($record);
$previousorder = -1;
$toolPrevious = null;
$toolNext = null;
if ($data->previoustoolid) {
$record = $DB->get_record('assignfeedback_editpp_tool', array('id' => $data->previoustoolid), '*', MUST_EXIST);
$record = $DB->get_record(self::BDDTABLETOOL, array('id' => $data->previoustoolid), '*', MUST_EXIST);
$toolPrevious = new tool($record);
$previousorder = $toolPrevious->order_tool + 1;
} elseif ($data->nexttoolid) {
$record = $DB->get_record('assignfeedback_editpp_tool', array('id' => $data->nexttoolid), '*', MUST_EXIST);
$record = $DB->get_record(self::BDDTABLETOOL, array('id' => $data->nexttoolid), '*', MUST_EXIST);
$toolNext = new tool($record);
$previousorder = $toolNext->order_tool - 1;
}
......@@ -130,7 +151,7 @@ class admin_editor {
}
$toolCurrent->order_tool = $previousorder;
debugging($previousorder);
if ($DB->update_record('assignfeedback_editpp_tool', $toolCurrent)) {
if ($DB->update_record(self::BDDTABLETOOL, $toolCurrent)) {
admin_editor::reorder_tool($toolCurrent->axis, $data->toolid);
}
}
......@@ -147,7 +168,8 @@ class admin_editor {
global $DB;
$tools = array();
$records = $DB->get_records_sql('SELECT * FROM {assignfeedback_editpp_tool} WHERE axis = :axisid ORDER BY order_tool ASC', array('axisid' => $axisid));
$records = $DB->get_records_sql(self::makeSqlRequestSelect("*", self::BDDTABLETOOL, "axis = :axisid ORDER BY order_tool ASC")
, array('axisid' => $axisid));
foreach ($records as $record) {
array_push($tools, new tool($record));
}
......@@ -164,11 +186,11 @@ class admin_editor {
if ($toolid && $tool->id == $toolid) {
$tool->order_tool = $lastTool->order_tool;
$lastTool->order_tool = $compteurPrecedent + 1;
$DB->update_record('assignfeedback_editpp_tool', $tool);
$DB->update_record('assignfeedback_editpp_tool', $lastTool);
$DB->update_record(self::BDDTABLETOOL, $tool);
$DB->update_record(self::BDDTABLETOOL, $lastTool);
} else {
$tool->order_tool = $compteurPrecedent + $decalage;
$DB->update_record('assignfeedback_editpp_tool', $tool);
$DB->update_record(self::BDDTABLETOOL, $tool);
$lastTool = $tool;
}
//$decalage++;
......@@ -191,9 +213,9 @@ class admin_editor {
public static function edit_axis($axeid, $axisLabel) {
global $DB;
$axis = $DB->get_record('assignfeedback_editpp_axis', array('id' => $axeid), '*', MUST_EXIST);
$axis = $DB->get_record(self::BDDTABLEAXE, array('id' => $axeid), '*', MUST_EXIST);
$axis->label = $axisLabel;
return $DB->update_record('assignfeedback_editpp_axis', $axis);
return $DB->update_record(self::BDDTABLEAXE, $axis);
}
/**
......@@ -204,7 +226,7 @@ class admin_editor {
*/
public static function del_axis($axeid) {
global $DB;
return $DB->delete_records('assignfeedback_editpp_axis', array('id' => $axeid));
return $DB->delete_records(self::BDDTABLEAXE, array('id' => $axeid));
}
/**
......@@ -215,7 +237,7 @@ class admin_editor {
*/
public static function del_tool($tool) {
global $DB;
return $DB->delete_records('assignfeedback_editpp_tool', array('id' => $tool->toolid));
return $DB->delete_records(self::BDDTABLETOOL, array('id' => $tool->toolid));
}
/**
......@@ -227,7 +249,7 @@ class admin_editor {
public static function get_tools_by_axis($axisid) {
global $DB;
$tools = array();
$records = $DB->get_records('assignfeedback_editpp_tool', array('axis' => $axisid));
$records = $DB->get_records(self::BDDTABLETOOL, array('axis' => $axisid));
foreach ($records as $record) {
array_push($tools, new tool($record));
}
......@@ -249,7 +271,7 @@ class admin_editor {
*/
public static function get_all_different_contexts() {
global $DB;
$records = $DB->get_records_sql("SELECT DISTINCT(contextid) FROM `mdl_assignfeedback_editpp_axis`");
$records = $DB->get_records_sql(self::makeSqlRequestSelect("DISTINCT(" . self::CONTEXTIDLIB . ")", self::BDDTABLEAXE));
return $records;
}
......@@ -262,7 +284,7 @@ class admin_editor {
public static function edit_tool($toolJson) {
global $DB;
$record = $DB->get_record('assignfeedback_editpp_tool', array('id' => $toolJson->toolid), '*', MUST_EXIST);
$record = $DB->get_record(self::BDDTABLETOOL, array('id' => $toolJson->toolid), '*', MUST_EXIST);
$tool = new tool($record);
$tool->axis = $toolJson->toolaxis;
$tool->type = $toolJson->typetool;
......@@ -282,7 +304,7 @@ class admin_editor {
$tool->order_tool = $toolJson->order;
$reorder = true;
}
if ($DB->update_record('assignfeedback_editpp_tool', $tool)) {
if ($DB->update_record(self::BDDTABLETOOL, $tool)) {
if ($reorder) {
admin_editor::reorder_tool($tool->axis, $tool->id);
}
......@@ -298,7 +320,7 @@ class admin_editor {
public static function get_typetools() {
global $DB;
$typetools = array();
$records = $DB->get_records('assignfeedback_editpp_typet', array('configurable' => 1));
$records = $DB->get_records(self::BDDTABLETOOLTYPE, array('configurable' => 1));
foreach ($records as $record) {
$newTypeTool = page_editor::custom_type_tool(new type_tool($record));
if ($newTypeTool->configurable > 0) {
......@@ -316,7 +338,7 @@ class admin_editor {
*/
public static function getAxisById($axeid) {
global $DB;
$axis = $DB->get_record('assignfeedback_editpp_axis', array('id' => $axeid), '*', MUST_EXIST);
$axis = $DB->get_record(self::BDDTABLEAXE, array('id' => $axeid), '*', MUST_EXIST);
return $axis;
}
......@@ -329,7 +351,8 @@ class admin_editor {
*/
public static function import_axis($axisOrigin, $context) {
global $DB;
$record = $DB->get_record_sql('SELECT max(order_axis) as order_max FROM {assignfeedback_editpp_axis} WHERE contextid = :contextid', array('contextid' => $context));
$record = $DB->get_record_sql(self::makeSqlRequestSelect("max(order_axis) as order_max", self::BDDTABLEAXE, self::CONTEXTIDLIB . ' = :' . self::CONTEXTIDLIB)
, array(self::CONTEXTIDLIB => $context));
$axis = new axis();
$axis->contextid = $context;
......@@ -340,7 +363,7 @@ class admin_editor {
$axis->order_axis = $record->order_max + 1;
}
return $DB->insert_record('assignfeedback_editpp_axis', $axis);
return $DB->insert_record(self::BDDTABLEAXE, $axis);
}
/**
......@@ -353,7 +376,8 @@ class admin_editor {
*/
public static function import_tool($toolToImport, $axeNew, $context) {
global $DB;
$record = $DB->get_record_sql('SELECT max(order_tool) as order_max FROM {assignfeedback_editpp_tool} WHERE contextid = :contextid', array('axis' => $axeNew->id, 'contextid' => $context));
$record = $DB->get_record_sql(self::makeSqlRequestSelect("max(order_tool) as order_max", self::BDDTABLETOOL, self::CONTEXTIDLIB . ' = :' . self::CONTEXTIDLIB)
, array('axis' => $axeNew->id, self::CONTEXTIDLIB => $context));
$tool = new tool();
$tool->axis = $axeNew;
......@@ -371,7 +395,7 @@ class admin_editor {
} else {
$tool->order_tool = $record->order_max + 1;
}
return $DB->insert_record('assignfeedback_editpp_tool', $tool);
return $DB->insert_record(self::BDDTABLETOOL, $tool);
}
}
......@@ -54,11 +54,11 @@ class annotation {
/** @var int ending location in pixels. Image resolution is 100 pixels per inch */
public $endy = 0;
/** @var int starting location of cartridge in pixels. Image resolution is 100 pixels per inch */
/** @var int starting location of cartridge in pixels. Image resolution is 100 pixels per inch */
public $cartridgex = 0;
/** @var int ending location of cartridge in pixels. Image resolution is 100 pixels per inch */
/** @var int ending location of cartridge in pixels. Image resolution is 100 pixels per inch */
public $cartridgey = 0;
/** @var string path information for drawing the annotation. */
......@@ -84,13 +84,13 @@ class annotation {
/** @var int parent_annot */
public $parent_annot = 0;
/** @var int answerrequested */
public $answerrequested = 0;
/** @var int studentstatus */
public $studentstatus = 0;
/** @var string studentanswer */
public $studentanswer = "";
......@@ -113,4 +113,13 @@ class annotation {
}
}
/**
* Check if the annotation has a real text which can be printed of displayed
* If the annotation has a parent, it will be always no : the parent will give the text for all of its children
* @return boolean
*/
public function hasReadableComment() {
return $this->textannot && !$this->parent_annot;
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
......@@ -110,6 +111,8 @@ class combined_document {
case \core_files\conversion::STATUS_FAILED:
return self::STATUS_FAILED;
default :
break;
}
}
}
......@@ -119,6 +122,7 @@ class combined_document {
return self::STATUS_READY;
}
}
/**
* Set the completed combined file.
*
......@@ -394,12 +398,13 @@ class combined_document {
*/
protected function get_stored_file_record($contextid, $itemid) {
return (object) [
'contextid' => $contextid,
'component' => 'assignfeedback_editpdfplus',
'filearea' => document_services::COMBINED_PDF_FILEAREA,
'itemid' => $itemid,
'filepath' => '/',
'filename' => document_services::COMBINED_PDF_FILENAME,
'contextid' => $contextid,
'component' => 'assignfeedback_editpdfplus',
'filearea' => document_services::COMBINED_PDF_FILEAREA,
'itemid' => $itemid,
'filepath' => '/',
'filename' => document_services::COMBINED_PDF_FILENAME,
];
}
}
......@@ -86,6 +86,8 @@ IFsgPEJDN0REQUQwRDQyOTQ1OTQ2OUU4NzJCMjI1ODUyNkU4Pgo8QkM3RERBRDBENDI5NDU5NDY5
RTg3MkIyMjU4NTI2RTg+IF0KL0RvY0NoZWNrc3VtIC9BNTYwMEZCMDAzRURCRTg0MTNBNTk3RTZF
MURDQzJBRgo+PgpzdGFydHhyZWYKNzM2CiUlRU9GCg==
EOD;
const NOPERMISSIONMESSAGE = "nopermission";
const PLUGIN_NAME = "assignfeedback_editpdfplus";
/**
* This function will take an int or an assignment instance and
......@@ -160,13 +162,13 @@ EOD;
* @return combined_document
*/
protected static function list_compatible_submission_files_for_attempt($assignment, $userid, $attemptnumber) {
global $USER, $DB;
global $DB;
$assignment = self::get_assignment_from_param($assignment);
// Capability checks.
if (!$assignment->can_view_submission($userid)) {
print_error('nopermission');
print_error(self::NOPERMISSIONMESSAGE);
}
$files = array();
......@@ -183,53 +185,33 @@ EOD;
return new combined_document();
}
$fs = get_file_storage();
$converter = new \core_files\converter();
// Ask each plugin for it's list of files.
foreach ($assignment->get_submission_plugins() as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$pluginfiles = $plugin->get_files($submission, $user);
foreach ($pluginfiles as $filename => $file) {
if ($file instanceof \stored_file) {
if ($file->get_mimetype() === 'application/pdf') {
$files[$filename] = $file;
} else if ($convertedfile = $converter->start_conversion($file, 'pdf')) {
$files[$filename] = $convertedfile;
}
} 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.
$file = self::strip_images($file);
$record = new \stdClass();
$record->contextid = $assignment->get_context()->id;
$record->component = 'assignfeedback_editpdfplus';
$record->filearea = self::IMPORT_HTML_FILEAREA;
$record->itemid = $submission->id;
$record->filepath = '/';
$record->filename = $plugin->get_type() . '-' . $filename;
//$htmlfile = $fs->create_file_from_string($record, $file);
$htmlfile = $fs->get_file($record->contextid, $record->component, $record->filearea, $record->itemid, $record->filepath, $record->filename);
$newhash = sha1($file);
// If the file exists, and the content hash doesn't match, remove it.
if ($htmlfile && $newhash !== $htmlfile->get_contenthash()) {
$htmlfile->delete();
$htmlfile = false;
}
// If the file doesn't exist, or if it was removed above, create a new one.
if (!$htmlfile) {
$htmlfile = $fs->create_file_from_string($record, $file);
}
$convertedfile = $converter->start_conversion($htmlfile, 'pdf');
if ($convertedfile) {
$files[$filename] = $convertedfile;
}
if (!$plugin->is_enabled() || !$plugin->is_visible()) {
continue;
}
$pluginfiles = $plugin->get_files($submission, $user);
foreach ($pluginfiles as $filename => $file) {
if ($file instanceof \stored_file) {
if ($file->get_mimetype() === 'application/pdf') {
$files[$filename] = $file;
} else if ($convertedfile = $converter->start_conversion($file, 'pdf')) {
$files[$filename] = $convertedfile;
}
} else if ($converter->can_convert_format_to('html', 'pdf')) {
$record = new \stdClass();
$record->contextid = $assignment->get_context()->id;
$record->component = self::PLUGIN_NAME;
$record->filearea = self::IMPORT_HTML_FILEAREA;
$record->itemid = $submission->id;
$record->filepath = '/';
$record->filename = $plugin->get_type() . '-' . $filename;
$convertedfile = self::convertDocHtmlToPdf($converter, $file, $record);
if ($convertedfile) {
$files[$filename] = $convertedfile;
}
}
}
......@@ -240,6 +222,40 @@ EOD;
return $combineddocument;
}
/**
* Create a PDF file from a HTML file
* @param \core_files\converter $converter
* @param string $file Html file
* @param \stdClass $fileProperties
* @return conversion PDF file
*/
protected static function convertDocHtmlToPdf(\core_files\converter $converter, $file, \stdClass $fileProperties) {
// Create a tmp stored_file from this html string.
$file = reset($file);
// Strip image tags, because they will not be resolvable.
$file = self::strip_images($file);
$fs = get_file_storage();
$htmlfile = $fs->get_file($fileProperties->contextid, $fileProperties->component, $fileProperties->filearea, $fileProperties->itemid, $fileProperties->filepath, $fileProperties->filename);
$newhash = sha1($file);
// If the file exists, and the content hash doesn't match, remove it.
if ($htmlfile && $newhash !== $htmlfile->get_contenthash()) {
$htmlfile->delete();
$htmlfile = false;
}
// If the file doesn't exist, or if it was removed above, create a new one.
if (!$htmlfile) {
$htmlfile = $fs->create_file_from_string($fileProperties, $file);
}
$convertedfile = $converter->start_conversion($htmlfile, 'pdf');
return $convertedfile;
}
/**
* Fetch the current combined document ready for state checking.
*
......@@ -255,7 +271,7 @@ EOD;
// Capability checks.
if (!$assignment->can_view_submission($userid)) {
print_error('nopermission');
print_error(self::NOPERMISSIONMESSAGE);
}
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
......@@ -266,7 +282,7 @@ EOD;
}
$contextid = $assignment->get_context()->id;
$component = 'assignfeedback_editpdfplus';
$component = self::PLUGIN_NAME;
$filearea = self::COMBINED_PDF_FILEAREA;
$itemid = $grade->id;
$filepath = '/';
......@@ -333,7 +349,7 @@ EOD;
$assignment = self::get_assignment_from_param($assignment);
if (!$assignment->can_view_submission($userid)) {
print_error('nopermission');
print_error(self::NOPERMISSIONMESSAGE);
}
// When in readonly we can return the number of images in the DB because they should already exist,
......@@ -341,7 +357,7 @@ EOD;
if ($readonly) {
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$fs = get_file_storage();
$files = $fs->get_directory_files($assignment->get_context()->id, 'assignfeedback_editpdfplus', self::PAGE_IMAGE_READONLY_FILEAREA, $grade->id, '/');
$files = $fs->get_directory_files($assignment->get_context()->id, self::PLUGIN_NAME, self::PAGE_IMAGE_READONLY_FILEAREA, $grade->id, '/');
$pagecount = count($files);
if ($pagecount > 0) {
return $pagecount;
......@@ -368,7 +384,7 @@ EOD;
$assignment = self::get_assignment_from_param($assignment);
if (!$assignment->can_view_submission($userid)) {
print_error('nopermission');
print_error(self::NOPERMISSIONMESSAGE);
}
// Need to generate the page images - first get a combined pdf.
......@@ -395,7 +411,7 @@ EOD;
$record = new \stdClass();
$record->contextid = $assignment->get_context()->id;
$record->component = 'assignfeedback_editpdfplus';
$record->component = self::PLUGIN_NAME;
$record->filearea = self::PAGE_IMAGE_FILEAREA;
$record->itemid = $grade->id;
$record->filepath = '/';
......@@ -445,12 +461,11 @@ EOD;
* @return array(stored_file)
*/
public static function get_page_images_for_attempt($assignment, $userid, $attemptnumber, $readonly = false) {
global $DB;
$assignment = self::get_assignment_from_param($assignment);
if (!$assignment->can_view_submission($userid)) {
print_error('nopermission');
print_error(self::NOPERMISSIONMESSAGE);
}
if ($assignment->get_instance()->teamsubmission) {
......@@ -461,7 +476,7 @@ EOD;
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$contextid = $assignment->get_context()->id;
$component = 'assignfeedback_editpdfplus';
$component = self::PLUGIN_NAME;
$itemid = $grade->id;
$filepath = '/';
$filearea = self::PAGE_IMAGE_FILEAREA;
......@@ -491,13 +506,10 @@ EOD;
if (!$readonly && count($files) == 1) {
$pdfarea = self::COMBINED_PDF_FILEAREA;
$pdfname = self::COMBINED_PDF_FILENAME;
if ($pdf = $fs->get_file($contextid, $component, $pdfarea, $itemid, $filepath, $pdfname)) {
// The combined pdf may have a different hash if it has been regenerated since the page
// image was created. However if this is the case the page image will be stale anyway.
if ($pdf->get_contenthash() == self::BLANK_PDF_HASH || $pagemodified < $pdf->get_timemodified()) {
$blankpage = true;
}
}
$pdf = $fs->get_file($contextid, $component, $pdfarea, $itemid, $filepath, $pdfname);
// The combined pdf may have a different hash if it has been regenerated since the page
// image was created. However if this is the case the page image will be stale anyway.
$blankpage = $pdf && ($pdf->get_contenthash() == self::BLANK_PDF_HASH || $pagemodified < $pdf->get_timemodified());
}
if (!$readonly && ($pagemodified < $submission->timemodified || $blankpage)) {
// Image files are stale, we need to regenerate them, except in readonly mode.
......@@ -592,10 +604,10 @@ EOD;
$assignment = self::get_assignment_from_param($assignment);
if (!$refresh && !$assignment->can_view_submission($userid)) {
print_error('nopermission');