ÿØÿà 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.php000064400000002235152266351220007111 0ustar00. /** * Capabilities * * @package report_questioninstances * @copyright 2008 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $capabilities = array( 'report/questioninstances:view' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( 'manager' => CAP_ALLOW ), 'clonepermissionsfrom' => 'moodle/site:config', ) ); lang/en/report_questioninstances.php000064400000003302152266351220013754 0ustar00. /** * lang strings * * @package report * @subpackage questioninstances * @copyright 2008 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['editquestionshere'] = 'Edit questions in this context'; $string['eventreportviewed'] = 'Report viewed'; $string['getreport'] = 'Get the report'; $string['hiddenquestions'] = 'Hidden'; $string['intro'] = 'This report lists all the contexts in the system where there are questions of a particular type.'; $string['pluginname'] = 'Question instances'; $string['questioninstances:view'] = 'View question instances report'; $string['reportforallqtypes'] = 'Report for all question types'; $string['reportformissingqtypes'] = 'Report for question of unknown types'; $string['reportforqtype'] = 'Report for question type \'{$a}\''; $string['reportsettings'] = 'Report settings'; $string['totalquestions'] = 'Total'; $string['visiblequestions'] = 'Visible'; $string['privacy:metadata'] = 'The Question instances plugin does not store any personal data.'; version.php000064400000002246152266351220006752 0ustar00. /** * Version info * * @package report * @subpackage questioninstances * @copyright 2008 Tim Hunt * @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 = 'report_questioninstances'; // Full name of the plugin (used for diagnostics) classes/privacy/provider.php000064400000003017152266351220012226 0ustar00. /** * Privacy Subsystem implementation for report_questioninstances. * * @package report_questioninstances * @copyright 2018 Zig Tan * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace report_questioninstances\privacy; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for report_questioninstances 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'; } }classes/event/report_viewed.php000064400000005300152266351220012713 0ustar00. /** * The report_questioninstances report viewed event. * * @package report_questioninstances * @copyright 2014 Petr Skoda * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace report_questioninstances\event; defined('MOODLE_INTERNAL') || die(); /** * The report_questioninstances report viewed event class. * * @property-read array $other { * Extra information about the event. * * - string requestedqtype: Requested question type. * } * * @package report_questioninstances * @since Moodle 2.7 * @copyright 2014 Petr Skoda * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class report_viewed extends \core\event\base { /** * Init method. * * @return void */ protected function init() { $this->data['crud'] = 'r'; $this->data['edulevel'] = self::LEVEL_OTHER; $this->context = \context_system::instance(); } /** * Return localised event name. * * @return string */ public static function get_name() { return get_string('eventreportviewed', 'report_questioninstances'); } /** * Returns description of what happened. * * @return string */ public function get_description() { return "The user with id '$this->userid' viewed the question instances report."; } /** * Returns relevant URL. * * @return \moodle_url */ public function get_url() { return new \moodle_url('/report/questioninstances/index.php', array('qtype' => $this->other['requestedqtype'])); } /** * Custom validation. * * @throws \coding_exception */ protected function validate_data() { parent::validate_data(); if (!isset($this->other['requestedqtype'])) { throw new \coding_exception('The \'requestedqtype\' value must be set in other.'); } } public static function get_other_mapping() { // Nothing to map. return false; } } index.php000064400000016564152266351220006404 0ustar00. /** * For a given question type, list the number of * * @package report * @subpackage questioninstances * @copyright 2008 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(__DIR__.'/../../config.php'); require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/questionlib.php'); // Get URL parameters. $requestedqtype = optional_param('qtype', '', PARAM_SAFEDIR); // Print the header & check permissions. admin_externalpage_setup('reportquestioninstances', '', null, '', array('pagelayout'=>'report')); $PAGE->set_primary_active_tab('siteadminnode'); echo $OUTPUT->header(); // Log. \report_questioninstances\event\report_viewed::create(array('other' => array('requestedqtype' => $requestedqtype)))->trigger(); // Prepare the list of capabilities to choose from $qtypes = question_bank::get_all_qtypes(); $qtypechoices = array(); foreach ($qtypes as $qtype) { $qtypechoices[$qtype->name()] = $qtype->local_name(); } // Sort by label. core_collator::asort($qtypechoices); // Print the settings form. echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter centerpara'); echo '
'; echo $OUTPUT->heading(get_string('reportsettings', 'report_questioninstances')); echo '

', get_string('intro', 'report_questioninstances') , '

'; echo '

'; echo html_writer::select($qtypechoices, 'qtype', $requestedqtype, array('_all_'=>get_string('all'))); echo '

'; echo '

'; echo '
'; echo $OUTPUT->box_end(); $params[] = \core_question\local\bank\question_version_status::QUESTION_STATUS_HIDDEN; // If we have a qtype to report on, generate the report. if ($requestedqtype) { // Work out the bits needed for the SQL WHERE clauses. if ($requestedqtype == 'missingtype') { $title = get_string('reportformissingqtypes', 'report_questioninstances'); $othertypes = array_keys($qtypes); $key = array_search('missingtype', $othertypes); unset($othertypes[$key]); [$sqlqtypetest, $sqlqtypetestparams] = $DB->get_in_or_equal($othertypes, SQL_PARAMS_QM, '', false); $sqlqtypetest = 'WHERE qtype ' . $sqlqtypetest; $params = array_merge($params, $sqlqtypetestparams); } else if ($requestedqtype == '_all_') { $title = get_string('reportforallqtypes', 'report_questioninstances'); $sqlqtypetest = ''; } else { $title = get_string('reportforqtype', 'report_questioninstances', question_bank::get_qtype($requestedqtype)->local_name()); $sqlqtypetest = 'WHERE qtype = ?'; $params [] = $requestedqtype; } // Get the question counts, and all the context information, for each // context. That is, rows of these results can be used as $context objects. $ctxpreload = context_helper::get_preload_record_columns_sql('con'); $ctxgroupby = implode(',', array_keys(context_helper::get_preload_record_columns('con'))); $counts = $DB->get_records_sql(" SELECT result.contextid, SUM(numquestions) AS numquestions, SUM(numhidden) AS numhidden, $ctxpreload FROM (SELECT data.contextid, data.versionid, COUNT(data.numquestions) AS numquestions, (SELECT COUNT(qv.id) FROM {question_versions} qv WHERE qv.id = data.versionid AND qv.status = ?) AS numhidden FROM (SELECT qv.id as versionid, qc.contextid, 1 AS numquestions FROM {question} q JOIN {question_versions} qv ON qv.questionid = q.id JOIN {question_bank_entries} qbe ON qbe.id = qv.questionbankentryid JOIN {question_categories} qc ON qc.id = qbe.questioncategoryid JOIN {context} con ON con.id = qc.contextid $sqlqtypetest AND qv.version = (SELECT MAX(v.version) FROM {question_versions} v JOIN {question_bank_entries} be ON be.id = v.questionbankentryid WHERE be.id = qbe.id) AND (q.parent = 0 OR q.parent = q.id)) data GROUP BY data.contextid, data.versionid) result JOIN {context} con ON con.id = result.contextid GROUP BY result.contextid, $ctxgroupby ORDER BY numquestions DESC, numhidden ASC, con.contextlevel ASC, con.id ASC", $params); // Print the report heading. echo $OUTPUT->heading($title); // Initialise the table. $table = new html_table(); $table->head = array( get_string('context', 'role'), get_string('totalquestions', 'report_questioninstances'), get_string('visiblequestions', 'report_questioninstances'), get_string('hiddenquestions', 'report_questioninstances')); $table->data = array(); $table->class = ''; $table->id = ''; // Add the data for each row. $totalquestions = 0; $totalvisible = 0; $totalhidden = 0; foreach ($counts as $count) { // Work out a link for editing questions in this context. context_helper::preload_from_record($count); $context = context::instance_by_id($count->contextid); $contextname = $context->get_context_name(); $url = question_edit_url($context); if ($url) { $contextname = '' . $contextname . ''; } // Put the scores in the table. $numvisible = $count->numquestions - $count->numhidden; $table->data[] = array( $contextname, $count->numquestions, $numvisible, $count->numhidden); // Update the totals. $totalquestions += $count->numquestions; $totalvisible += $numvisible; $totalhidden += $count->numhidden; } // Add a totals row. $table->data[] = array( '' . get_string('total') . '', $totalquestions, $totalvisible, $totalhidden); // Print it. echo html_writer::table($table); } // Footer. echo $OUTPUT->footer(); tests/event/events_test.php000064400000004253152266351220012113 0ustar00. /** * Tests for question instances events. * * @package report_questioninstances * @copyright 2014 Petr Skoda * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ namespace report_questioninstances\event; /** * Class for question instances events. * * @package report_questioninstances * @copyright 2014 Petr Skoda * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. */ final class events_test extends \advanced_testcase { /** * Setup testcase. */ public function setUp(): void { parent::setUp(); $this->setAdminUser(); $this->resetAfterTest(); } /** * Test the report viewed event. */ public function test_report_viewed(): void { $requestedqtype = 'all'; $event = \report_questioninstances\event\report_viewed::create(array('other' => array('requestedqtype' => $requestedqtype))); // Trigger and capture the event. $sink = $this->redirectEvents(); $event->trigger(); $events = $sink->get_events(); $event = reset($events); $this->assertInstanceOf('\report_questioninstances\event\report_viewed', $event); $this->assertEquals(\context_system::instance(), $event->get_context()); $this->assertEventContextNotUsed($event); $url = new \moodle_url('/report/questioninstances/index.php', array('qtype' => $requestedqtype)); $this->assertEquals($url, $event->get_url()); $event->get_name(); } } tests/behat/question_reports.feature000064400000005674152266351220014013 0ustar00@core @core_question @report @report_questioninstance Feature: A Teacher can generate question instance reports In order to see question instance reports As a Teacher I need to generate them Background: Given the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: | fullname | shortname | format | | Course 1 | C1 | weeks | And the following "activities" exist: | activity | course | name | | quiz | C1 | Test quiz Q001 | And the following "questions" exist: | questioncategory | qtype | name | | Default for Test quiz Q001 | truefalse | TF | | Default for Test quiz Q001 | shortanswer | SA | And quiz "Test quiz Q001" contains the following questions: | question | page | maxmark | | TF | 1 | 5.0 | | SA | 1 | 5.0 | And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Activity module | Test quiz Q001 | Quiz category | Scenario: Generate general and specific report Given I am on the "C1" "Course" page logged in as "admin" And I navigate to "Reports > Question instances" in site administration # Checks the dropdown list is in alphabetical order And "Matching" "option" should appear before "Select missing words" "option" in the "Question type" "select" When I press "Get the report" Then "Quiz: Test quiz Q001" row "Total" column of "generaltable" table should contain "2" And "Quiz: Test quiz Q001" row "Visible" column of "generaltable" table should contain "2" And "Quiz: Test quiz Q001" row "Hidden" column of "generaltable" table should contain "0" Scenario: Generate report displaying hidden questions Given I am on the "Test quiz Q001" "mod_quiz > question bank" page logged in as "admin" And I choose "Delete" action for "TF" in the question bank And I press "Delete" And I navigate to "Reports > Question instances" in site administration When I press "Get the report" Then "Quiz: Test quiz Q001" row "Total" column of "generaltable" table should contain "2" And "Quiz: Test quiz Q001" row "Visible" column of "generaltable" table should contain "1" And "Quiz: Test quiz Q001" row "Hidden" column of "generaltable" table should contain "1" And I set the field "menuqtype" to "True/False" And I press "Get the report" And "Quiz: Test quiz Q001" row "Total" column of "generaltable" table should contain "1" And "Quiz: Test quiz Q001" row "Visible" column of "generaltable" table should contain "0" And "Quiz: Test quiz Q001" row "Hidden" column of "generaltable" table should contain "1" settings.php000064400000002223152266351220007120 0ustar00. /** * Settings and links * * @package report * @subpackage questioninstances * @copyright 2008 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; $ADMIN->add('reports', new admin_externalpage('reportquestioninstances', get_string('pluginname', 'report_questioninstances'), "$CFG->wwwroot/report/questioninstances/index.php", 'report/questioninstances:view')); // no report settings $settings = null;