ÿØÿà 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-Ї Ç db/access.php000064400000003051152266460640007115 0ustar00. /** * Glossary random block caps. * * @package block_glossary_random * @copyright Mark Nelson * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $capabilities = array( 'block/glossary_random:myaddinstance' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( 'user' => CAP_ALLOW ), 'clonepermissionsfrom' => 'moodle/my:manageblocks' ), 'block/glossary_random:addinstance' => array( 'riskbitmask' => RISK_SPAM | RISK_XSS, 'captype' => 'write', 'contextlevel' => CONTEXT_BLOCK, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ), 'clonepermissionsfrom' => 'moodle/site:manageblocks' ), ); lang/en/block_glossary_random.php000064400000005315152266460640013174 0ustar00. /** * Strings for component 'block_glossary_random', language 'en', branch 'MOODLE_20_STABLE' * * @package block_glossary_random * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['addentry'] = 'Add a new entry'; $string['askaddentry'] = 'When users can add entries to the glossary, show a link with this text'; $string['askinvisible'] = 'When users cannot edit or view the glossary, show this text (without link)'; $string['askviewglossary'] = 'When users can view the glossary but not add entries, show a link with this text'; $string['glossary_random:addinstance'] = 'Add a new random glossary entry block'; $string['glossary_random:myaddinstance'] = 'Add a new random glossary entry block to Dashboard'; $string['intro'] = 'Make sure you have at least one glossary with at least one entry added to this course. Then you can adjust the following settings'; $string['invisible'] = '(to be continued)'; $string['lastmodified'] = 'Last modified entry'; $string['nextalpha'] = 'Alphabetical order'; $string['nextone'] = 'Next entry'; $string['noentriesyet'] = 'There are no entries yet in the chosen glossary.'; $string['notyetconfigured'] = 'Please configure this block using the edit icon.'; $string['notyetglossary'] = 'You need to have at least one glossary to choose.'; $string['pluginname'] = 'Random glossary entry'; $string['random'] = 'Random entry'; $string['refresh'] = 'Days before a new entry is chosen'; $string['select_glossary'] = 'Take entries from this glossary'; $string['showconcept'] = 'Show concept (heading) for each entry'; $string['title'] = 'Title'; $string['type'] = 'How a new entry is chosen'; $string['viewglossary'] = 'View all entries'; $string['whichfooter'] = 'You can display links to actions of the glossary this block is associated with. The block will only display links to actions which are enabled for that glossary.'; $string['privacy:metadata'] = 'The Random glossary entry block only shows data stored in other locations.'; backup/moodle2/restore_glossary_random_block_task.class.php000064400000007151152266460640020350 0ustar00. /** * @package block_glossary_random * @subpackage backup-moodle2 * @copyright 2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Specialised restore task for the glossary_random block * (using execute_after_tasks for recoding of glossaryid) * * TODO: Finish phpdocs */ class restore_glossary_random_block_task extends restore_block_task { protected function define_my_settings() { } protected function define_my_steps() { } public function get_fileareas() { return array(); // No associated fileareas } public function get_configdata_encoded_attributes() { return array(); // No special handling of configdata } /** * This function, executed after all the tasks in the plan * have been executed, will perform the recode of the * target glossary for the block. This must be done here * and not in normal execution steps because the glossary * may be restored after the block. */ public function after_restore() { global $DB; // Get the blockid $blockid = $this->get_blockid(); // Extract block configdata and update it to point to the new glossary if ($configdata = $DB->get_field('block_instances', 'configdata', array('id' => $blockid))) { $config = $this->decode_configdata($configdata); if (!empty($config->glossary)) { if ($glossarymap = restore_dbops::get_backup_ids_record($this->get_restoreid(), 'glossary', $config->glossary)) { // Get glossary mapping and replace it in config $config->glossary = $glossarymap->newitemid; } else if ($this->is_samesite()) { // We are restoring on the same site, check if glossary can be used in the block in this course. $glossaryid = $DB->get_field_sql("SELECT id FROM {glossary} " . "WHERE id = ? AND (course = ? OR globalglossary = 1)", [$config->glossary, $this->get_courseid()]); if (!$glossaryid) { unset($config->glossary); } } else { // The block refers to a glossary not present in the backup file. unset($config->glossary); } // Unset config variables that are no longer used. unset($config->globalglossary); unset($config->courseid); // Save updated config. $configdata = base64_encode(serialize($config)); $DB->set_field('block_instances', 'configdata', $configdata, array('id' => $blockid)); } } } public static function define_decode_contents() { return array(); } public static function define_decode_rules() { return array(); } } edit_form.php000064400000010704152266460640007242 0ustar00. /** * Form for editing HTML block instances. * * @package block_glossary_random * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Form for editing Random glossary entry block instances. * * @copyright 2009 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_glossary_random_edit_form extends block_edit_form { protected function specific_definition($mform) { global $DB; // Fields for editing HTML block title and contents. $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); $mform->addElement('text', 'config_title', get_string('title', 'block_glossary_random')); $mform->setDefault('config_title', get_string('pluginname','block_glossary_random')); $mform->setType('config_title', PARAM_TEXT); // Select glossaries to put in dropdown box ... $glossaries = $DB->get_records_select_menu('glossary', 'course = ? OR globalglossary = ?', [$this->get_course_id(), 1], 'name', 'id,name'); foreach($glossaries as $key => $value) { $glossaries[$key] = strip_tags(format_string($value, true)); } $mform->addElement('select', 'config_glossary', get_string('select_glossary', 'block_glossary_random'), $glossaries); $mform->addElement('text', 'config_refresh', get_string('refresh', 'block_glossary_random'), array('size' => 5)); $mform->setDefault('config_refresh', 0); $mform->setType('config_refresh', PARAM_INT); // and select quotetypes to put in dropdown box $types = array( 0 => get_string('random','block_glossary_random'), 1 => get_string('lastmodified','block_glossary_random'), 2 => get_string('nextone','block_glossary_random'), 3 => get_string('nextalpha','block_glossary_random') ); $mform->addElement('select', 'config_type', get_string('type', 'block_glossary_random'), $types); $mform->addElement('selectyesno', 'config_showconcept', get_string('showconcept', 'block_glossary_random')); $mform->setDefault('config_showconcept', 1); $mform->addElement('static', 'footerdescription', '', get_string('whichfooter', 'block_glossary_random')); $mform->addElement('text', 'config_addentry', get_string('askaddentry', 'block_glossary_random')); $mform->setDefault('config_addentry', get_string('addentry', 'block_glossary_random')); $mform->setType('config_addentry', PARAM_NOTAGS); $mform->addElement('text', 'config_viewglossary', get_string('askviewglossary', 'block_glossary_random')); $mform->setDefault('config_viewglossary', get_string('viewglossary', 'block_glossary_random')); $mform->setType('config_viewglossary', PARAM_NOTAGS); $mform->addElement('text', 'config_invisible', get_string('askinvisible', 'block_glossary_random')); $mform->setDefault('config_invisible', get_string('invisible', 'block_glossary_random')); $mform->setType('config_invisible', PARAM_NOTAGS); } /** * Returns id of the course where this block is located (or siteid for the dashboard or non-course page) * * @return int */ protected function get_course_id(): int { if ($this->block->instance->id) { return $this->block->course->id; } else if ($parentcontext = $this->block->context->get_course_context(false)) { return $parentcontext->instanceid; } else { return get_site()->id; } } /** * Display the configuration form when block is being added to the page * * @return bool */ public static function display_form_when_adding(): bool { return true; } } version.php000064400000002344152266460640006760 0ustar00. /** * Version details * * @package block_glossary_random * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2025041400; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2025040800; // Requires this Moodle version. $plugin->component = 'block_glossary_random'; // Full name of the plugin (used for diagnostics) $plugin->dependencies = ['mod_glossary' => 2025040800]; block_glossary_random.php000064400000030301152266460640011642 0ustar00. /** * Glossary Random block. * * @package block_glossary_random * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('BGR_RANDOMLY', '0'); define('BGR_LASTMODIFIED', '1'); define('BGR_NEXTONE', '2'); define('BGR_NEXTALPHA', '3'); class block_glossary_random extends block_base { /** * @var cm_info|stdClass has properties 'id' (course module id) and 'uservisible' * (whether the glossary is visible to the current user) */ protected $glossarycm = null; /** @var stdClass course data. */ public $course; function init() { $this->title = get_string('pluginname','block_glossary_random'); } function specialization() { global $CFG, $DB; require_once($CFG->libdir . '/filelib.php'); $this->course = $this->page->course; // load userdefined title and make sure it's never empty if (empty($this->config->title)) { $this->title = get_string('pluginname','block_glossary_random'); } else { $this->title = format_string($this->config->title, true, ['context' => $this->context]); } if (empty($this->config->glossary)) { return false; } if (!isset($this->config->nexttime)) { $this->config->nexttime = 0; } //check if it's time to put a new entry in cache if (time() > $this->config->nexttime) { if (!($cm = $this->get_glossary_cm()) || !$cm->uservisible) { // Skip generating of the cache if we can't display anything to the current user. return false; } // place glossary concept and definition in $pref->cache if (!$numberofentries = $DB->count_records('glossary_entries', array('glossaryid'=>$this->config->glossary, 'approved'=>1))) { $this->config->cache = get_string('noentriesyet','block_glossary_random'); $this->instance_config_commit(); } $glossaryctx = context_module::instance($cm->id); $entries = $DB->get_records_sql('SELECT id, concept, definition, definitionformat, definitiontrust FROM {glossary_entries} WHERE glossaryid = ? AND approved = 1 ORDER BY timemodified ASC', [$this->config->glossary]); // Reset entries keys, so subsequent selection by index works correctly. $entries = array_values($entries); if (empty($entries)) { $text = get_string('noentriesyet', 'block_glossary_random'); } else { // Now picking out the correct entry from the array. switch ($this->config->type) { case BGR_RANDOMLY: $i = ($numberofentries > 1) ? rand(1, $numberofentries) : 1; if (count($entries) == 1) { $entry = reset($entries); } else { $entry = $entries[$i - 1]; } break; case BGR_NEXTONE: // The array is already sorted by last modified. if (isset($this->config->previous)) { $i = $this->config->previous + 1; } else { $i = 1; } if ($i > $numberofentries) { // Loop back to beginning. $i = 1; } if (count($entries) == 1) { $entry = reset($entries); } else { $entry = $entries[$i - 1]; } break; case BGR_NEXTALPHA: // Now sort the array in regard to the current language. usort($entries, function($a, $b) { return format_string($a->concept) <=> format_string($b->concept); }); if (isset($this->config->previous)) { $i = $this->config->previous + 1; } else { $i = 1; } if ($i > $numberofentries) { // Loop back to beginning. $i = 1; } if (count($entries) == 1) { $entry = $entries; } else { $entry = $entries[$i - 1]; } break; default: // BGR_LASTMODIFIED // The array is already sorted by last modified. $i = $numberofentries; if (count($entries) == 1) { $entry = reset($entries); } else { $entry = array_pop($entries); } break; } if (empty($this->config->showconcept) || (!isset($entry->concept))) { $text = ''; } else { $text = "

" . format_string($entry->concept, true, ["context" => $glossaryctx]) . "

"; } $options = new stdClass(); if (isset($entry->definitiontrust)) { $options->trusted = $entry->definitiontrust; } $options->overflowdiv = true; if (isset($entry->definitiontrust) && isset($entry->id) && isset($entry->definition)) { $entry->definition = file_rewrite_pluginfile_urls($entry->definition, 'pluginfile.php', $glossaryctx->id, 'mod_glossary', 'entry', $entry->id); $text .= format_text($entry->definition, $entry->definitionformat, $options); } $this->config->nexttime = usergetmidnight(time()) + DAYSECS * $this->config->refresh; $this->config->previous = $i; } // store the text $this->config->cache = $text; $this->instance_config_commit(); } } /** * Replace the instance's configuration data with those currently in $this->config; */ function instance_config_commit($nolongerused = false) { // Unset config variables that are no longer used. unset($this->config->globalglossary); unset($this->config->courseid); parent::instance_config_commit($nolongerused); } /** * Checks if glossary is available - it should be either located in the same course or be global * * @return null|cm_info|stdClass object with properties 'id' (course module id) and 'uservisible' */ protected function get_glossary_cm() { global $DB; if (empty($this->config->glossary)) { // No glossary is configured. return null; } if (!empty($this->glossarycm)) { return $this->glossarycm; } if (!empty($this->page->course->id)) { // First check if glossary belongs to the current course (we don't need to make any DB queries to find it). $modinfo = get_fast_modinfo($this->page->course); if (isset($modinfo->instances['glossary'][$this->config->glossary])) { $this->glossarycm = $modinfo->instances['glossary'][$this->config->glossary]; if ($this->glossarycm->uservisible) { // The glossary is in the same course and is already visible to the current user, // no need to check if it is global, save on DB query. return $this->glossarycm; } } } // Find course module id for the given glossary, only if it is global. $cm = $DB->get_record_sql("SELECT cm.id, cm.visible AS uservisible FROM {course_modules} cm JOIN {modules} md ON md.id = cm.module JOIN {glossary} g ON g.id = cm.instance WHERE g.id = :instance AND md.name = :modulename AND g.globalglossary = 1", ['instance' => $this->config->glossary, 'modulename' => 'glossary']); if ($cm) { // This is a global glossary, create an object with properties 'id' and 'uservisible'. We don't need any // other information so why bother retrieving it. Full access check is skipped for global glossaries for // performance reasons. $this->glossarycm = $cm; } else if (empty($this->glossarycm)) { // Glossary does not exist. Remove it in the config so we don't repeat this check again later. $this->config->glossary = 0; $this->instance_config_commit(); } return $this->glossarycm; } function instance_allow_multiple() { // Are you going to allow multiple instances of each block? // If yes, then it is assumed that the block WILL USE per-instance configuration return true; } function get_content() { if ($this->content !== null) { return $this->content; } $this->content = (object)['text' => '', 'footer' => '']; if (!$cm = $this->get_glossary_cm()) { if ($this->user_can_edit()) { $this->content->text = get_string('notyetconfigured', 'block_glossary_random'); } return $this->content; } if (empty($this->config->cache)) { $this->config->cache = ''; } if ($cm->uservisible) { // Show glossary if visible and place links in footer. $this->content->text = $this->config->cache; if (has_capability('mod/glossary:write', context_module::instance($cm->id))) { $this->content->footer = html_writer::link(new moodle_url('/mod/glossary/edit.php', ['cmid' => $cm->id]), format_string($this->config->addentry)) . '
'; } $this->content->footer .= html_writer::link(new moodle_url('/mod/glossary/view.php', ['id' => $cm->id]), format_string($this->config->viewglossary)); } else { // Otherwise just place some text, no link. $this->content->footer = format_string($this->config->invisible); } return $this->content; } /** * Return the plugin config settings for external functions. * * @return stdClass the configs for both the block instance and plugin * @since Moodle 3.8 */ public function get_config_for_external() { // Return all settings for all users since it is safe (no private keys, etc..). $configs = !empty($this->config) ? $this->config : new stdClass(); return (object) [ 'instance' => $configs, 'plugin' => new stdClass(), ]; } /** * This block shouldn't be added to a page if the glossary module is disabled. * * @param moodle_page $page * @return bool */ public function can_block_be_added(moodle_page $page): bool { $pluginclass = \core_plugin_manager::resolve_plugininfo_class('mod'); return $pluginclass::get_enabled_plugin('glossary'); } } classes/privacy/provider.php000064400000003004152266460640012231 0ustar00. /** * Privacy Subsystem implementation for block_glossary_random. * * @package block_glossary_random * @copyright 2018 Zig Tan * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace block_glossary_random\privacy; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for block_glossary_random implementing null_provider. * * @copyright 2018 Zig Tan * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\null_provider { /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. * * @return string */ public static function get_reason(): string { return 'privacy:metadata'; } } tests/glossary_random_test.php000064400000004543152266460640012702 0ustar00. namespace block_glossary_random; use advanced_testcase; use block_glossary_random; use context_course; /** * PHPUnit block_glossary_random tests * * @package block_glossary_random * @category test * @copyright 2021 Sara Arjona (sara@moodle.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @coversDefaultClass \block_glossary_random */ final class glossary_random_test extends advanced_testcase { public static function setUpBeforeClass(): void { require_once(__DIR__ . '/../../moodleblock.class.php'); require_once(__DIR__ . '/../block_glossary_random.php'); parent::setUpBeforeClass(); } /** * Test the behaviour of can_block_be_added() method. * * @covers ::can_block_be_added */ public function test_can_block_be_added(): void { $this->resetAfterTest(); $this->setAdminUser(); // Create a course and prepare the page where the block will be added. $course = $this->getDataGenerator()->create_course(); $page = new \moodle_page(); $page->set_context(context_course::instance($course->id)); $page->set_pagelayout('course'); $block = new block_glossary_random(); $pluginclass = \core_plugin_manager::resolve_plugininfo_class('mod'); // If glossary module is enabled, the method should return true. $pluginclass::enable_plugin('glossary', 1); $this->assertTrue($block->can_block_be_added($page)); // However, if the glossary module is disabled, the method should return false. $pluginclass::enable_plugin('glossary', 0); $this->assertFalse($block->can_block_be_added($page)); } } tests/behat/glossary_random.feature000064400000012670152266460640013572 0ustar00@block @block_glossary_random Feature: Random glossary entry block is used in a course In order to show the entries from glossary As a teacher I can add the random glossary entry to a course page Background: Given the following "courses" exist: | fullname | shortname | | Course 1 | C1 | And the following "users" exist: | username | firstname | lastname | email | | student1 | Sam1 | Student1 | student1@example.com | | teacher1 | Terry1 | Teacher1 | teacher1@example.com | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | teacher1 | C1 | editingteacher | Scenario: Student can not see the block if it is not configured When I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add the "Random glossary entry" block Then I should see "Please configure this block using the edit icon" in the "block_glossary_random" "block" And I log out And I log in as "student1" And I am on "Course 1" course homepage And "block_glossary_random" "block" should not exist And I log out Scenario: View random (last) entry in the glossary with auto approval Given the following "activities" exist: | activity | name | intro | course | idnumber | defaultapproval | | glossary | GlossaryAuto | Test glossary description | C1 | glossary1 | 1 | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add the "Random glossary entry" block And I configure the "block_glossary_random" block And I set the following fields to these values: | Title | AutoGlossaryblock | | Take entries from this glossary | GlossaryAuto | | How a new entry is chosen | Last modified entry | And I press "Save changes" And I log out When I log in as "student1" And I am on "Course 1" course homepage Then I should see "There are no entries yet in the chosen glossary" in the "AutoGlossaryblock" "block" And I click on "Add a new entry" "link" in the "AutoGlossaryblock" "block" And I set the following fields to these values: | Concept | Concept1 | | Definition | Definition1 | And I press "Save changes" And I am on "Course 1" course homepage And I should see "Concept1" in the "AutoGlossaryblock" "block" And I should see "Definition1" in the "AutoGlossaryblock" "block" And I should not see "There are no entries yet in the chosen glossary" in the "AutoGlossaryblock" "block" And I click on "Add a new entry" "link" in the "AutoGlossaryblock" "block" And I set the following fields to these values: | Concept | Concept2 | | Definition | Definition2 | And I press "Save changes" And I am on "Course 1" course homepage # Only the last entry appears in the block And I should not see "Concept1" in the "AutoGlossaryblock" "block" And I should not see "Definition1" in the "AutoGlossaryblock" "block" And I should see "Concept2" in the "AutoGlossaryblock" "block" And I should see "Definition2" in the "AutoGlossaryblock" "block" And I click on "View all entries" "link" in the "AutoGlossaryblock" "block" And I should see "GlossaryAuto" in the "#page-navbar" "css_element" And I should see "Concept1" in the "#page-content" "css_element" And I should see "Concept2" in the "#page-content" "css_element" And I log out Scenario: View random (last) entry in the glossary with manual approval Given the following "activities" exist: | activity | name | intro | course | idnumber | defaultapproval | | glossary | GlossaryManual | Test glossary description | C1 | glossary2 | 0 | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add the "Random glossary entry" block And I configure the "block_glossary_random" block And I set the following fields to these values: | Title | ManualGlossaryblock | | Take entries from this glossary | GlossaryManual | | How a new entry is chosen | Last modified entry | And I press "Save changes" And I log out When I log in as "student1" And I am on "Course 1" course homepage Then I should see "There are no entries yet in the chosen glossary" in the "ManualGlossaryblock" "block" And I click on "Add a new entry" "link" in the "ManualGlossaryblock" "block" And I set the following fields to these values: | Concept | Concept1 | | Definition | Definition1 | And I press "Save changes" And I am on "Course 1" course homepage And I should see "There are no entries yet in the chosen glossary" in the "ManualGlossaryblock" "block" And I log out And I log in as "teacher1" And I am on "Course 1" course homepage And I should see "There are no entries yet in the chosen glossary" in the "ManualGlossaryblock" "block" And I follow "GlossaryManual" And I follow "Pending approval" And I follow "Approve" And I click on "Course 1" "link" in the "#page-navbar" "css_element" And I should see "Concept1" in the "ManualGlossaryblock" "block" And I should see "Definition1" in the "ManualGlossaryblock" "block" And I log out tests/behat/glossary_random_global.feature000064400000007570152266460640015115 0ustar00@block @block_glossary_random Feature: Random glossary entry block linking to global glossary In order to show the entries from glossary As a teacher I can add the random glossary entry to a course page Background: Given the following "courses" exist: | fullname | shortname | | Course 1 | C1 | | Course 2 | C2 | And the following "activity" exists: | activity | glossary | | name | Tips and Tricks | | intro | Frontpage glossary description | | course | C2 | | idnumber | glossary0 | | globalglossary | 1 | | defaultapproval | 1 | And the following "users" exist: | username | firstname | lastname | email | | student1 | Sam1 | Student1 | student1@example.com | | teacher1 | Terry1 | Teacher1 | teacher1@example.com | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | teacher1 | C1 | editingteacher | Scenario: View random (last) entry in the global glossary When I log in as "admin" And I am on "Course 2" course homepage And I follow "Tips and Tricks" And I press "Add entry" And I set the following fields to these values: | Concept | Never come late | | Definition | Come in time for your classes | And I press "Save changes" And I log out # As a teacher add a block to the course page linking to the global glossary. And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add the "Random glossary entry" block And I configure the "block_glossary_random" block And I set the following fields to these values: | Title | Tip of the day | | Take entries from this glossary | Tips and Tricks | | How a new entry is chosen | Last modified entry | And I press "Save changes" Then I should see "Never come late" in the "Tip of the day" "block" And I should not see "Add a new entry" in the "Tip of the day" "block" And I should see "View all entries" in the "Tip of the day" "block" And I log out # Student who can't see the module is still able to view entries in this block (because the glossary was marked as global) And I log in as "student1" And I am on "Course 1" course homepage And I should see "Never come late" in the "Tip of the day" "block" And I should not see "Add a new entry" in the "Tip of the day" "block" And I should see "View all entries" in the "Tip of the day" "block" And I log out Scenario: Removing the global glossary that is used in random glossary block And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add the "Random glossary entry" block And I configure the "block_glossary_random" block And I set the following fields to these values: | Title | Tip of the day | | Take entries from this glossary | Tips and Tricks | | How a new entry is chosen | Last modified entry | And I press "Save changes" And I log out And I log in as "admin" And I am on "Course 2" course homepage And I follow "Tips and Tricks" And I follow "Settings" And I set the field "globalglossary" to "0" And I press "Save and return to course" And I am on "Course 1" course homepage Then I should see "Please configure this block using the edit icon." in the "Tip of the day" "block" And I log out And I log in as "student1" And I am on "Course 1" course homepage And "Tip of the day" "block" should not exist And I log out tests/behat/glossary_random_addblock_disabled.feature000064400000003757152266460640017252 0ustar00@block @block_glossary_random @javascript Feature: Add the glossary random block when main feature is disabled In order to add the glossary random block to my course As a teacher It should be added to courses only if the glossary module is enabled. Background: Given the following "courses" exist: | fullname | shortname | format | | Course 1 | C1 | topics | And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | glossary_random | Course | C1 | course-view-* | site-post | Scenario: The glossary random block is displayed even when glossary module is disabled When I log in as "admin" And I navigate to "Plugins > Activity modules > Manage activities" in site administration And I toggle the "Disable Glossary" admin switch "off" And I am on "Course 1" course homepage with editing mode on Then "Random glossary entry" "block" should exist Scenario: The glossary random block can be removed even when glossary module is disabled When I log in as "admin" And I am on "Course 1" course homepage with editing mode on And I open the "Random glossary entry" blocks action menu And I click on "Delete Random glossary entry block" "link" in the "Random glossary entry" "block" And "Delete block?" "dialogue" should exist And I click on "Cancel" "button" in the "Delete block?" "dialogue" And "Random glossary entry" "block" should exist When I navigate to "Plugins > Activity modules > Manage activities" in site administration And I toggle the "Disable Glossary" admin switch "off" And I am on "Course 1" course homepage with editing mode on And I open the "Random glossary entry" blocks action menu And I click on "Delete Random glossary entry block" "link" in the "Random glossary entry" "block" And I click on "Delete" "button" in the "Delete block?" "dialogue" Then "Random glossary entry" "block" should not exist tests/behat/glossary_random_frontpage.feature000064400000002556152266460640015641 0ustar00@block @block_glossary_random Feature: Random glossary entry block can be added to the frontpage In order to show the entries from glossary on the frontpage As a teacher I can add the random glossary entry to the frontpage Scenario: Admin can add random glossary block to the frontpage Given the following "activities" exist: | activity | name | intro | course | idnumber | | glossary | Tips and Tricks | Frontpage glossary description | Acceptance test site | glossary0 | And I log in as "admin" And I am on site homepage And I turn editing mode on And I add the "Random glossary entry" block And I configure the "block_glossary_random" block And I set the following fields to these values: | Title | Tip of the day | | Take entries from this glossary | Tips and Tricks | And I press "Save changes" And I click on "Add a new entry" "link" in the "Tip of the day" "block" And I set the following fields to these values: | Concept | Never come late | | Definition | Come in time for your classes | And I press "Save changes" When I log out Then I should see "Never come late" in the "Tip of the day" "block" And I should see "Come in time for your classes" in the "Tip of the day" "block" tests/behat/glossary_random_addblock.feature000064400000006471152266460640015417 0ustar00@block @block_glossary_random @javascript @addablocklink Feature: Add the glossary random block when main feature is enabled In order to add the glossary random block to my course As a teacher It should be added to courses only if the glossary module is enabled. Background: Given the following "courses" exist: | fullname | shortname | format | | Course 1 | C1 | topics | And the following "users" exist: | username | firstname | lastname | email | | student1 | Student | 1 | student1@example.com | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "course enrolments" exist: | user | course | role | | student1 | C1 | student | | teacher1 | C1 | editingteacher | And I am on the "C1" "course" page logged in as "admin" Scenario: The glossary random block can be added when glossary module is enabled Given I turn editing mode on When I click on "Add a block" "link" Then I should see "Random glossary entry" Scenario: The glossary random block cannot be added when glossary module is disabled Given I navigate to "Plugins > Activity modules > Manage activities" in site administration And I toggle the "Disable Glossary" admin switch "off" And I am on "Course 1" course homepage with editing mode on When I click on "Add a block" "link" Then I should not see "Random glossary entry" Scenario: View alphabetical order multilang entries in the glossary block Given the following "activities" exist: | activity | name | intro | course | idnumber | defaultapproval | | glossary | Animals | An animal glossary | C1 | glossary3 | 1 | And the following "mod_glossary > entries" exist: | glossary | user | concept | definition | | Animals | student1 | Aardvark | AardvarkErdferkel | | Animals | student1 | Kangaroo | KangarooKänguru | | Animals | student1 | Zebra | ZebraZebra | And the "multilang" filter is "on" And the "multilang" filter applies to "content and headings" And I log out And I log in as "teacher1" And I am on "C1" course homepage with editing mode on And I add the "Random glossary entry..." block And I set the following fields to these values: | Title | ManualGlossaryblock | | Take entries from this glossary | Animals | | Days before a new entry is chosen | 0 | | How a new entry is chosen | Alphabetical order | And I press "Save changes" And I should see "Aardvark" in the "ManualGlossaryblock" "block" And I should not see "AardvarkErdferkel" in the "ManualGlossaryblock" "block" And I reload the page And I should see "Kangaroo" in the "ManualGlossaryblock" "block" And I reload the page Then I should see "Zebra" in the "ManualGlossaryblock" "block" And I log out