mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-45301 assign: Add font options for EditPDF
This commit is contained in:
parent
8503f2cfd8
commit
9e725bc168
19 changed files with 160 additions and 9 deletions
|
@ -645,6 +645,7 @@ EOD;
|
|||
* @return stored_file
|
||||
*/
|
||||
public static function generate_feedback_document($assignment, $userid, $attemptnumber) {
|
||||
global $CFG;
|
||||
|
||||
$assignment = self::get_assignment_from_param($assignment);
|
||||
|
||||
|
@ -674,6 +675,20 @@ EOD;
|
|||
|
||||
$pdf = new pdf();
|
||||
|
||||
// Set fontname from course setting if it's enabled.
|
||||
if (!empty($CFG->enablepdfexportfont)) {
|
||||
$fontlist = $pdf->get_export_fontlist();
|
||||
// Load font from course if it's more than 1.
|
||||
if (count($fontlist) > 1) {
|
||||
$course = $assignment->get_course();
|
||||
if (!empty($course->pdfexportfont)) {
|
||||
$pdf->set_export_font_name($course->pdfexportfont);
|
||||
}
|
||||
} else {
|
||||
$pdf->set_export_font_name(current($fontlist));
|
||||
}
|
||||
}
|
||||
|
||||
$fs = get_file_storage();
|
||||
$stamptmpdir = make_temp_directory('assignfeedback_editpdf/stamps/' . self::hash($assignment, $userid, $attemptnumber));
|
||||
$grade = $assignment->get_user_grade($userid, true, $attemptnumber);
|
||||
|
|
|
@ -50,6 +50,8 @@ class pdf extends TcpdfFpdi {
|
|||
protected $imagefolder = null;
|
||||
/** @var string the path to the PDF currently being processed */
|
||||
protected $filename = null;
|
||||
/** @var string the fontname used when the PDF being processed */
|
||||
protected $fontname = null;
|
||||
|
||||
/** No errors */
|
||||
const GSPATH_OK = 'ok';
|
||||
|
@ -81,15 +83,23 @@ class pdf extends TcpdfFpdi {
|
|||
* @return string
|
||||
*/
|
||||
private function get_export_font_name() {
|
||||
global $CFG;
|
||||
|
||||
$fontname = 'freesans';
|
||||
if (!empty($CFG->pdfexportfont)) {
|
||||
$fontname = $CFG->pdfexportfont;
|
||||
if (!empty($this->fontname)) {
|
||||
$fontname = $this->fontname;
|
||||
}
|
||||
return $fontname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font name.
|
||||
*
|
||||
* @param string $fontname Font name which is
|
||||
* @return void
|
||||
*/
|
||||
public function set_export_font_name($fontname): void {
|
||||
$this->fontname = $fontname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine the given PDF files into a single PDF. Optionally add a coversheet and coversheet fields.
|
||||
* @param string[] $pdflist the filenames of the files to combine
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue