Merge branch 'MDL-76495-master' of https://github.com/marinaglancy/moodle

This commit is contained in:
Ilya Tregubov 2022-12-02 13:48:11 +03:00
commit fb27e80566
3 changed files with 34 additions and 2 deletions

View file

@ -884,14 +884,14 @@ class QRcode {
protected function getCode() {
if ($this->count < $this->dataLength) {
$row = $this->count % $this->blocks;
$col = $this->count / $this->blocks;
$col = (int)($this->count / $this->blocks);
if ($col >= $this->rsblocks[0]['dataLength']) {
$row += $this->b1;
}
$ret = $this->rsblocks[$row]['data'][$col];
} elseif ($this->count < $this->dataLength + $this->eccLength) {
$row = ($this->count - $this->dataLength) % $this->blocks;
$col = ($this->count - $this->dataLength) / $this->blocks;
$col = (int)(($this->count - $this->dataLength) / $this->blocks);
$ret = $this->rsblocks[$row]['ecc'][$col];
} else {
return 0;

View file

@ -6,6 +6,8 @@ Description of TCPDF library import
* remove all fonts that were not already present
* visit http://127.0.0.1/lib/tests/other/pdflibtestpage.php and view the pdf
* modify getTCPDFProducer lib/tcpdf/include/tcpdf_static.php to remove the version number
* Check the status of https://github.com/tecnickcom/TCPDF/pull/548 , apply if it is still
not included or delete this entry
Important
---------

View file

@ -36,4 +36,34 @@ class pdflib_test extends \advanced_testcase {
$producer = TCPDF_STATIC::getTCPDFProducer();
$this->assertEquals('TCPDF (http://www.tcpdf.org)', $producer);
}
public function test_qrcode() {
global $CFG;
require_once($CFG->libdir.'/pdflib.php');
$this->resetAfterTest();
$pdf = new \pdf();
$pdf->AddPage('P', [500, 500]);
$pdf->SetMargins(10, 0, 10);
$style = [
'border' => 0,
'vpadding' => 'auto',
'hpadding' => 'auto',
'fgcolor' => [0, 0, 0],
'bgcolor' => [255, 255, 255],
'module_width' => 1,
'module_height' => 1
];
$pdf->setCellPaddings(0, 0, 0, 0);
$pdf->write2DBarcode('https://www.example.com/moodle/admin/search.php',
'QRCODE,M', null, null, 35, 35, $style, 'N');
$pdf->SetFillColor(255, 255, 255);
$res = $pdf->Output('output', 'S');
$this->assertGreaterThan(100000, strlen($res));
$this->assertLessThan(120000, strlen($res));
}
}