ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/lib/tests/dataformat_test.php000064400000015036152267653600024504 0ustar00. namespace core; use coding_exception; use context_system; use core_component; /** * Tests for the dataformat plugins * * @package core * @covers \core\dataformat * @copyright 2020 Paul Holden * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ final class dataformat_test extends \advanced_testcase { /** * Test getting writer instance for given dataformat */ public function test_get_format_instance(): void { $instance = dataformat::get_format_instance('pdf'); $this->assertInstanceOf(\dataformat_pdf\writer::class, $instance); } /** * Test getting writer instance for invalid dataformat */ public function test_get_format_instance_invalid(): void { $this->expectException(coding_exception::class); $this->expectExceptionMessage('Invalid dataformat (weird)'); dataformat::get_format_instance('weird'); } /** * Data provider to return array of dataformat types * * @return array */ public static function write_data_provider(): array { $data = []; $dataformats = core_component::get_plugin_list('dataformat'); foreach ($dataformats as $dataformat => $unused) { $data[] = [$dataformat]; } return $data; } /** * Test writing dataformat export to local file * * @param string $dataformat * @return void * * @dataProvider write_data_provider */ public function test_write_data(string $dataformat): void { $columns = ['fruit', 'colour', 'animal']; $rows = [ ['banana', 'yellow', 'monkey'], ['apple', 'red', 'wolf'], ['melon', 'green', 'aardvark'], ]; // Export to file. Assert that the exported file exists and is non-zero in size. $exportfile = dataformat::write_data('My export', $dataformat, $columns, $rows); $this->assertFileExists($exportfile); $this->assertGreaterThan(0, filesize($exportfile)); } /** * Test writing dataformat export to filearea * * @param string $dataformat * @return void * * @dataProvider write_data_provider */ public function test_write_data_to_filearea(string $dataformat): void { $this->resetAfterTest(); $columns = ['fruit', 'colour', 'animal']; $rows = [ ['banana', 'yellow', 'monkey'], ['apple', 'red', 'wolf'], ['melon', 'green', 'aardvark'], ]; // Export to filearea. Assert that the the file exists in file storage and matches the original file record. $filerecord = [ 'contextid' => context_system::instance()->id, 'component' => 'core_dataformat', 'filearea' => 'test', 'itemid' => 0, 'filepath' => '/', 'filename' => 'My export', ]; $file = dataformat::write_data_to_filearea($filerecord, $dataformat, $columns, $rows); $this->assertEquals($filerecord['contextid'], $file->get_contextid()); $this->assertEquals($filerecord['component'], $file->get_component()); $this->assertEquals($filerecord['filearea'], $file->get_filearea()); $this->assertEquals($filerecord['itemid'], $file->get_itemid()); $this->assertEquals($filerecord['filepath'], $file->get_filepath()); $this->assertStringStartsWith($filerecord['filename'], $file->get_filename()); $this->assertGreaterThan(0, $file->get_filesize()); } /** * Data provider for test_escape_spreadsheet_formula. * * @return array */ public static function escape_spreadsheet_formula_provider(): array { return [ 'null stays null' => [ null, null, ], 'empty string stays empty' => [ '', '', ], 'Formula with tab' => [ 'value' => "\t=SUM(1+1)", 'expected' => "'\t=SUM(1+1)", ], 'Formula with carriage return' => [ 'value' => "\r=SUM(1+1)", 'expected' => "'\r=SUM(1+1)", ], 'Formula with new line' => [ 'value' => "\n=SUM(1+1)", 'expected' => "'\n=SUM(1+1)", ], 'Formula starting with "="' => [ 'value' => "=SUM(1+1)", 'expected' => "'=SUM(1+1)", ], 'Formula starting with "+"' => [ 'value' => "+1+1", 'expected' => "'+1+1", ], 'Formula starting with "-"' => [ 'value' => "-1+1", 'expected' => "'-1+1", ], 'Formula starting with "@"' => [ 'value' => "@A5", 'expected' => "'@A5", ], 'Null placeholder' => [ 'value' => "-", 'expected' => "-", ], 'dash with leading space is not placeholder, so escaped' => [ ' -', "' -", ], 'dash with trailing space is not placeholder, so escaped' => [ '- ', "'- ", ], 'Non-formula' => [ 'value' => "Hello there", 'expected' => "Hello there", ], ]; } /** * Test escape_spreadsheet_formula. * * @dataProvider escape_spreadsheet_formula_provider * @param string|null $value The value to test. * @param string|null $expected The expected value after escaping. */ public function test_escape_spreadsheet_formula(?string $value, ?string $expected): void { $this->resetAfterTest(); $escapedvalue = dataformat::escape_spreadsheet_formula($value); $this->assertEquals($expected, $escapedvalue); } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/lib/tests/plugininfo/dataformat_test.php000064400000005717152270067760026663 0ustar00. declare(strict_types=1); namespace core\plugininfo; use advanced_testcase; /** * Unit tests for the dataformat plugininfo class * * @package core * @covers \core\plugininfo\dataformat * @copyright 2022 Paul Holden * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ final class dataformat_test extends advanced_testcase { /** * Helper method, to allow easy filtering of default formats in order to perform assertions without any third-party * formats affecting expected results * * @param string $format * @return bool */ private function filter_default_plugins(string $format): bool { $defaultformats = ['csv', 'excel', 'html', 'json', 'ods', 'pdf']; return in_array($format, $defaultformats); } /** * Test getting enabled plugins */ public function test_get_enabled_plugins(): void { $this->resetAfterTest(); // Check all default formats. $plugins = array_filter(dataformat::get_enabled_plugins(), [$this, 'filter_default_plugins']); $this->assertEquals([ 'csv' => 'csv', 'excel' => 'excel', 'html' => 'html', 'json' => 'json', 'ods' => 'ods', 'pdf' => 'pdf', ], $plugins); // Disable excel & html. dataformat::enable_plugin('excel', 0); dataformat::enable_plugin('html', 0); $plugins = array_filter(dataformat::get_enabled_plugins(), [$this, 'filter_default_plugins']); $this->assertEquals([ 'csv' => 'csv', 'json' => 'json', 'ods' => 'ods', 'pdf' => 'pdf', ], $plugins); } /** * Test getting enabled plugins obeys configured sortorder */ public function test_get_enabled_plugins_sorted(): void { $this->resetAfterTest(); set_config('dataformat_plugins_sortorder', 'csv,pdf,excel,json,html,ods'); $plugins = array_filter(dataformat::get_enabled_plugins(), [$this, 'filter_default_plugins']); $this->assertEquals([ 'csv' => 'csv', 'pdf' => 'pdf', 'excel' => 'excel', 'json' => 'json', 'html' => 'html', 'ods' => 'ods', ], $plugins); } }