From a13c83c5b29a0364f657bbdf146416d43289d29c Mon Sep 17 00:00:00 2001 From: st143971 Date: Sat, 16 Sep 2023 08:46:59 +0200 Subject: [PATCH] - Updated course_access checks using moodles can_access_course instead of custom one (addressing https://github.com/SE-Stuttgart/moodle-block_slidefinder/issues/8) - updated strings addressing https://github.com/SE-Stuttgart/moodle-block_slidefinder/issues/6 - added the customary content check for the block addressing https://github.com/SE-Stuttgart/moodle-block_slidefinder/issues/4 - updated thirdpartylibs.xml addressing https://github.com/SE-Stuttgart/moodle-block_slidefinder/issues/3 - updated error handling & management - other bugfixes --- .github/workflows/ci.yml | 112 ++++++++++++++++++++++++++ block_slidefinder.php | 130 +++++++++++++++++-------------- externallib.php | 68 ++++++++-------- lang/de/block_slidefinder.php | 20 +++-- lang/en/block_slidefinder.php | 35 +++++---- locallib.php | 98 +++++++++++++++++------ renderer.php | 29 ------- templates/lrf_drop_down.mustache | 13 ++-- templates/lrf_search.mustache | 3 +- thirdpartylibs.xml | 2 +- version.php | 2 +- 11 files changed, 336 insertions(+), 176 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 renderer.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..badf6d7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,112 @@ +name: Moodle Plugin CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-22.04 + + services: + postgres: + image: postgres:13 + env: + POSTGRES_USER: 'postgres' + POSTGRES_HOST_AUTH_METHOD: 'trust' + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 + + mariadb: + image: mariadb:10 + env: + MYSQL_USER: 'root' + MYSQL_ALLOW_EMPTY_PASSWORD: "true" + MYSQL_CHARACTER_SET_SERVER: "utf8mb4" + MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 + + strategy: + fail-fast: false + matrix: + php: ['7.4', '8.0', '8.1'] + moodle-branch: ['MOODLE_401_STABLE'] + database: [pgsql, mariadb] + + steps: + - name: Check out repository code + uses: actions/checkout@v3 + with: + path: plugin + + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: ${{ matrix.extensions }} + ini-values: max_input_vars=5000 + # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug". + # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems). + coverage: none + + - name: Initialise moodle-plugin-ci + run: | + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 + echo $(cd ci/bin; pwd) >> $GITHUB_PATH + echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH + sudo locale-gen en_AU.UTF-8 + echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV + + - name: Install moodle-plugin-ci + run: | + moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 + env: + DB: ${{ matrix.database }} + MOODLE_BRANCH: ${{ matrix.moodle-branch }} + + - name: PHP Lint + if: ${{ always() }} + run: moodle-plugin-ci phplint + + - name: PHP Copy/Paste Detector + continue-on-error: true # This step will show errors but will not fail + if: ${{ always() }} + run: moodle-plugin-ci phpcpd + + - name: PHP Mess Detector + continue-on-error: true # This step will show errors but will not fail + if: ${{ always() }} + run: moodle-plugin-ci phpmd + + - name: Moodle Code Checker + if: ${{ always() }} + run: moodle-plugin-ci phpcs --max-warnings 0 + + - name: Moodle PHPDoc Checker + if: ${{ always() }} + run: moodle-plugin-ci phpdoc --max-warnings 0 + + - name: Validating + if: ${{ always() }} + run: moodle-plugin-ci validate + + - name: Check upgrade savepoints + if: ${{ always() }} + run: moodle-plugin-ci savepoints + + - name: Mustache Lint + if: ${{ always() }} + run: moodle-plugin-ci mustache + + - name: Grunt + if: ${{ always() }} + run: moodle-plugin-ci grunt --max-lint-warnings 0 + + - name: PHPUnit tests + if: ${{ always() }} + run: moodle-plugin-ci phpunit --fail-on-warning + + - name: Behat features + if: ${{ always() }} + run: moodle-plugin-ci behat --profile chrome diff --git a/block_slidefinder.php b/block_slidefinder.php index c0a733e..e74f6ae 100644 --- a/block_slidefinder.php +++ b/block_slidefinder.php @@ -35,54 +35,82 @@ function init() { } /** - * Describe Block Content + * Describe Block Content. */ public function get_content() { - global $PAGE, $CFG, $DB, $USER; + global $OUTPUT, $PAGE, $DB, $USER; - - // Context - $systemcontext = context_system::instance(); - $usercontext = context_user::instance($USER->id); - - // Params - $cid = optional_param('id', 0, PARAM_INT); // Do we have a set course id? Or are we on our dashboard (default). - $lrf_cid = optional_param('lrf_cid', $cid, PARAM_INT); // Selected course ID (by our course selection). - $search = optional_param('search', '', PARAM_TEXT); // Searched pattern (search hook). - - $course = null; // Course to search in. - $course_id = 0; // Course ID of searched course. - - $view_course_selection = false; // Are we displaying the course selection? - $view_selected_course = false; // Are we displaying the search field? Did we select a course? Are we allowed to search said course? - - // Get Course and CourseID by parameter - if ($course = $DB->get_record('course', array('id' => $lrf_cid))) { - $course_id = $course->id; - $coursecontext = context_course::instance($course->id); + if ($this->content !== null) { + return $this->content; } - // Renderer needed to use templates - $renderer = $PAGE->get_renderer(get_class($this)); - - $view_course_selection = !$cid; - $view_selected_course = $course_id ? can_access_course($course) : false; + // Params. + $cid = optional_param('id', 0, PARAM_INT); // Do we have a set course id? Or are we on our dashboard (default). + $lrf_cid = optional_param('lrf_cid', 0, PARAM_INT); // Selected course ID (by our course selection). + $search = optional_param('search', '', PARAM_TEXT); // Searched pattern (search hook). // Main Content (text) and Footer of the block $text = ''; $footer = ''; - if ($view_course_selection) { - $text .= $renderer->render_from_template('block_slidefinder/lrf_drop_down', [ - 'action' => $PAGE->url, - 'course_selector_param_name' => 'lrf_cid', - 'course_selector_options' => block_lrf_select_course_options($course_id), - ]); - } - if ($view_selected_course) { - $text .= $renderer->render_from_template('block_slidefinder/lrf_search', [ + try { + // Get all current params. + $hiddenparams = $_GET; + + // Filter out 'lrf_cid' as a param we use and change. + $hiddenparams = array_filter($hiddenparams, function ($key) { + return $key !== 'lrf_cid'; + }, ARRAY_FILTER_USE_KEY); + + // Restructure (for mustache) the name=>value list into a list of array objects having the name and value attribute. + $hiddenparams = array_map(function ($name, $value) { + return array("name" => $name, "value" => $value); + }, array_keys($hiddenparams), $hiddenparams); + + if ($cid == 0) { // My Moodle Page. + if ($lrf_cid != 0) { + // Course. + if (!$course = $DB->get_record('course', array('id' => $lrf_cid))) { + throw new moodle_exception(get_string('error_course_not_found', 'block_slidefinder')); + } + // Does the user have access to the course? + if (!can_access_course($course)) { + throw new moodle_exception(get_string('error_course_access_denied', 'block_slidefinder')); + } + } else { + $course = null; + } + $text .= $OUTPUT->render_from_template('block_slidefinder/lrf_drop_down', [ + 'action' => $PAGE->url, + 'course_selector_param_name' => 'lrf_cid', + 'course_selector_options' => block_slidefinder_select_course_options($lrf_cid), + 'hidden_params' => $hiddenparams + ]); + } else { // Course Page. + // Course. + if (!$course = $DB->get_record('course', array('id' => $cid))) { + throw new moodle_exception(get_string('error_course_not_found', 'block_slidefinder')); + } + // Does the user have access to the course? + if (!can_access_course($course)) { + throw new moodle_exception(get_string('error_course_access_denied', 'block_slidefinder')); + } + } + + $data = [[], []]; + if (!is_null($course)) { + $data = block_slidefinder_get_content_as_chapters_for_all_book_pdf_matches_from_course($course->id, $USER->id); + if (!empty($data[1])) { + $footer .= get_string('misconfigured_info', get_class($this)); + foreach ($data[1] as $key => $value) { + $footer .= '
'; + $footer .= $value; + } + } + } + + $text .= $OUTPUT->render_from_template('block_slidefinder/lrf_search', [ 'action' => $PAGE->url, - 'cid' => $cid, 'lrf_cid' => $lrf_cid, 'course_selector_param_name' => 'lrf_cid', 'search_term_param_name' => 'search', @@ -90,8 +118,13 @@ public function get_content() { 'search_term_label' => get_string('search_term', get_class($this)), 'search_term' => $search, 'chapter_label' => get_string('chapter', get_class($this)), - 'content' => base64_encode(json_encode($this->get_pdfs_content_from_course($course))) + 'content' => base64_encode(json_encode($data[0])), + 'hidden_params' => $hiddenparams ]); + } catch (\Throwable $th) { + debugging($th); + $text .= get_string('error_message', get_class($this)); + $footer .= $th; } $this->content = new stdClass(); @@ -99,25 +132,4 @@ public function get_content() { $this->content->footer = $footer; return $this->content; } - - /** - * Returns the PDFs and their content (splitted in pages) for all eligable PDFs in the given course. - * - * @param mixed $course course to search in. - * - * @return array array of objects each holding one pdf page on content and some metadata - */ - function get_pdfs_content_from_course($course): array { - if ($course == null) return []; - - $chapters = array(); - - $matches = block_lrf_get_all_book_pdf_matches_from_course($course); - - foreach ($matches as $match) { - $chapters = array_merge($chapters, block_lrf_get_content_as_chapters($match)); - } - - return $chapters; - } } diff --git a/externallib.php b/externallib.php index da22bcc..5d5e089 100644 --- a/externallib.php +++ b/externallib.php @@ -25,24 +25,27 @@ require_once("$CFG->libdir/externallib.php"); -class block_slidefinder_external extends external_api -{ +class block_slidefinder_external extends external_api { /** * Returns description of method parameter * @return external_function_parameters */ - public static function get_searched_locations_parameters() - { + public static function get_searched_locations_parameters() { return new external_function_parameters( array( - 'search_string' => new external_value( - PARAM_TEXT, - 'String to search for in the course', + 'user_id' => new external_value( + PARAM_INT, + 'Id of the user using the webservice', VALUE_REQUIRED ), 'course_id' => new external_value( PARAM_INT, - 'Id of the course', + 'Id of the course the user wants to access', + VALUE_REQUIRED + ), + 'search_string' => new external_value( + PARAM_TEXT, + 'String to search for in the course', VALUE_REQUIRED ), 'context_length' => new external_value( @@ -56,50 +59,50 @@ public static function get_searched_locations_parameters() /** * Get all occurences, their context and a link to the chapter of $search_string in the eligable $PDF-Book lectures in the given course. * - * @param string $search_string the string to search for + * @param int $user_id id of the user who initiates the search * @param int $course_id id of the course to search in + * @param string $search_string the string to search for * @param int $context_length the size of the context snippet on each side of the found @param $seach_string occurences in words * * @return string json encoded array of arrays holding the 'filename', 'page_number', 'book_chapter_url' and 'context' of each chapter/pdf-page the $search_term was found * @return string return '' the $course_id was incorrect */ - public static function get_searched_locations($search_string, $course_id, $context_length) - { + public static function get_searched_locations($user_id, $course_id, $search_string, $context_length) { global $CFG, $DB; require_once(__DIR__ . '/locallib.php'); - $context = context_course::instance($course_id); // Validate parameter $params = self::validate_parameters( self::get_searched_locations_parameters(), array( - 'search_string' => $search_string, + 'user_id' => $user_id, 'course_id' => $course_id, + 'search_string' => $search_string, 'context_length' => $context_length ) ); $transaction = $DB->start_delegated_transaction(); - // Get Course + // User. + if (!$user = $DB->get_record('user', array('id' => $user_id))) { + throw new moodle_exception(get_string('error_user_not_found', 'block_slidefinder')); + } + // Course. if (!$course = $DB->get_record('course', array('id' => $course_id))) { - return ''; + throw new moodle_exception(get_string('error_course_not_found', 'block_slidefinder')); } - $context = context_course::instance($course_id); - - // Get all Book-PDF matches - $matches = block_lrf_get_all_book_pdf_matches_from_course($course); - - // Get PDF Content for matches - $chapters = array(); - foreach ($matches as $match) { - $chapters = array_merge($chapters, block_lrf_get_content_as_chapters($match)); + // Does the user have access to the course? + if (!can_access_course($course, $user)) { + throw new moodle_exception(get_string('error_course_access_denied', 'block_slidefinder')); } + [$chapters, $misconfiguredchapters] = block_slidefinder_get_content_as_chapters_for_all_book_pdf_matches_from_course($course_id, $user_id); + // Get Search Results & Context for PDFs $results = array(); foreach ($chapters as $chapter) { - $result = self::lrf_search_content($chapter, $search_string, $context_length); + $result = self::search_content($chapter, $search_string, $context_length); if ($result) $results[] = [ 'filename' => $result->filename, 'page_number' => $result->page, @@ -116,8 +119,7 @@ public static function get_searched_locations($search_string, $course_id, $conte * Returns description of the method return values * @return external_value */ - public static function get_searched_locations_returns() - { + public static function get_searched_locations_returns() { return new external_value(PARAM_TEXT, 'Search results', VALUE_REQUIRED); } @@ -130,8 +132,7 @@ public static function get_searched_locations_returns() * * @return stdClass|null the given @param $page object with the additional $page->context or null if nothing was found */ - private static function lrf_search_content($page, $search_term, $context_length) - { + private static function search_content($page, $search_term, $context_length) { $content = ' ' . $page->content . ' '; // Is the searched word in this page? @@ -184,8 +185,7 @@ private static function lrf_search_content($page, $search_term, $context_length) * * @return string the extracted substring */ - private static function substring($string, $start, $end) - { + private static function substring($string, $start, $end) { $start = min($start, $end, strlen($string) - 1); $end = min($end, strlen($string) - 1); @@ -205,8 +205,7 @@ private static function substring($string, $start, $end) * * @return int index of the first occurence found or -1 if nothing was found */ - private static function indexOf($haystack, $needle, $offset) - { + private static function indexOf($haystack, $needle, $offset) { $offset = min(strlen($haystack) - 1, $offset); $offset = max(0, $offset); @@ -224,8 +223,7 @@ private static function indexOf($haystack, $needle, $offset) * * @return int index of the first occurence found or -1 if nothing was found */ - private static function lastIndexOf($haystack, $needle, $offset) - { + private static function lastIndexOf($haystack, $needle, $offset) { $offset = min(strlen($haystack) - 1, $offset); $offset = max(0, $offset); diff --git a/lang/de/block_slidefinder.php b/lang/de/block_slidefinder.php index ac4949f..d9db5a8 100644 --- a/lang/de/block_slidefinder.php +++ b/lang/de/block_slidefinder.php @@ -23,19 +23,27 @@ */ defined('MOODLE_INTERNAL') || die(); - -// Config +// Config. $string['pluginname'] = 'Foliensuche'; - -// Block +// Block. $string['search_term'] = 'Gesucht: '; $string['chapter'] = 'Kapitel'; +$string['misconfigured_info'] = 'Die folgenden Dateien sind zwar als übereinstimmend gekennzeichnet, ' + . 'wurden aber nicht korrekt eingerichtet. Vielleicht stimmt die Kapitelanzahl zwischen Buch und pdf nicht überein?'; -//Search Field +// Search Field. $string['search'] = 'Suche...'; $string['select_course'] = 'Wähle Kurs...'; - +// Capabilities. $string['block_slidefinder:myaddinstance'] = 'Füge einen neuen Foliensuche Block zu meinem Moodle Dashboard hinzu'; $string['block_slidefinder:addinstance'] = 'Füge einen neuen Foliensuche Block zu dieser Seite hinzu'; + +// Error. +$string['error_message'] = 'Es ist ein Problem aufgetreten. ' + . 'Bitte kontaktieren Sie den Ersteller des Plugins und senden Sie ihm den Fehler. Dies ist der Fehler:'; +$string['error_user_not_found'] = 'User does not exist.'; +$string['error_course_not_found'] = 'Course is misconfigured'; +$string['error_course_access_denied'] = 'Access to course denied.'; +$string['error_book_pdf_mismatch'] = 'There exists an mismatch of book and pdf.'; diff --git a/lang/en/block_slidefinder.php b/lang/en/block_slidefinder.php index a85b228..f918e8b 100644 --- a/lang/en/block_slidefinder.php +++ b/lang/en/block_slidefinder.php @@ -24,19 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +// Config. +$string['pluginname'] = 'Slide finder'; -// Config -$string['pluginname'] = 'Slide Finder'; - -// Block -$string['search_term'] = 'Search Term: '; +// Block. +$string['search_term'] = 'Search term: '; $string['chapter'] = 'Chapter'; - -//Search Field -$string['search'] = 'Search Keyword...'; -$string['select_course'] = 'Select Course...'; - - - -$string['block_slidefinder:myaddinstance'] = 'Add a new Slide Finder block to my Moodle dashboard.'; -$string['block_slidefinder:addinstance'] = 'Add a new Slide Finder block to this page.'; +$string['misconfigured_info'] = 'The following files are flagged as matching but have not been set up correctly. ' + . 'Maybe there is a chapter count mismatch between book and pdf?'; + +//Search Field. +$string['search'] = 'Search keyword...'; +$string['select_course'] = 'Select course...'; + +// Capabilities. +$string['block_slidefinder:myaddinstance'] = 'Add a new slide finder block to my moodle Dashboard.'; +$string['block_slidefinder:addinstance'] = 'Add a new slide finder block to this page.'; + +// Error. +$string['error_message'] = 'There was a problem. Please contact the Plugin creator and send him the error. This is the error:'; +$string['error_user_not_found'] = 'User does not exist.'; +$string['error_course_not_found'] = 'Course is misconfigured'; +$string['error_course_access_denied'] = 'Access to course denied.'; +$string['error_book_pdf_mismatch'] = 'There exists an mismatch of book and pdf.'; diff --git a/locallib.php b/locallib.php index 2f7834a..e2c1f8c 100644 --- a/locallib.php +++ b/locallib.php @@ -25,6 +25,49 @@ require_once(__DIR__ . '/pdfparser/alt_autoload.php-dist'); +/** + * Return the content & link of all chapters that are part of an eliganble book-pdf match in the given course. + * + * @param int $courseid ID of the course to be searched + * @param int $userid ID of the user initiating the search + * + * @return array [0] list of chapters (content, link, other metadata). One chapter for each eligable book chaper in course. + * @return array [1] list of filenames of intended eligable pairs that have a problem + */ +function block_slidefinder_get_content_as_chapters_for_all_book_pdf_matches_from_course($courseid, $userid) { + global $DB; + + $coursechapters = array(); + $misconfiguredcoursechapters = array(); + + try { + // Course. + if (!$course = $DB->get_record('course', array('id' => $courseid))) { + throw new moodle_exception(get_string('error_course_not_found', 'block_slidefinder')); + } + // Does the user have access to the course? + if (!can_access_course($course, $userid)) { + throw new moodle_exception(get_string('error_course_access_denied', 'block_slidefinder')); + } + } catch (\Throwable $th) { + debugging($th); + return [$coursechapters, $misconfiguredcoursechapters]; + } + + $matches = block_slidefinder_get_all_book_pdf_matches_from_course($course); + + foreach ($matches as $match) { + $matchchapters = block_slidefinder_get_content_as_chapters($match); + if (!is_null($matchchapters) && !empty($matchchapters)) { + $coursechapters = array_merge($coursechapters, $matchchapters); + } else { + $misconfiguredcoursechapters[] = $match->filename; + } + } + + return [$coursechapters, $misconfiguredcoursechapters]; +} + /** * Return a list of all eligable book-pdf matches in a given course. * @@ -32,7 +75,7 @@ * * @return array list of matches as objects containing pdf file information and book_id */ -function block_lrf_get_all_book_pdf_matches_from_course($course) { +function block_slidefinder_get_all_book_pdf_matches_from_course($course) { // Get all PDFs from course $fs = get_file_storage(); $pdfs = array(); @@ -84,31 +127,38 @@ function block_lrf_get_all_book_pdf_matches_from_course($course) { * * @return array list of objects containing the content and some metadata of one PDF page. */ -function block_lrf_get_content_as_chapters($match) { - $fs = get_file_storage(); +function block_slidefinder_get_content_as_chapters($match) { + $chapters = array(); - $config = new \Smalot\PdfParser\Config(); - $config->setHorizontalOffset(''); - $pdf_parser = new \Smalot\PdfParser\Parser([], $config); + try { + $fs = get_file_storage(); - $chapters = array(); + $config = new \Smalot\PdfParser\Config(); + $config->setHorizontalOffset(''); + $pdf_parser = new \Smalot\PdfParser\Parser([], $config); + + $file = $fs->get_file_by_hash($match->pathnamehash); + if ($file->get_mimetype() != 'application/pdf') return $chapters; + + $pdf = $pdf_parser->parseContent($file->get_content()); + $pdf_details = $pdf->getDetails(); + $pages = $pdf->getPages(); - $file = $fs->get_file_by_hash($match->pathnamehash); - if ($file->get_mimetype() != 'application/pdf') return $chapters; - - $pdf = $pdf_parser->parseContent($file->get_content()); - $pdf_details = $pdf->getDetails(); - $pages = $pdf->getPages(); - - for ($i = 0; $i < $pdf_details['Pages']; $i++) { - $chapter = new stdClass(); - $chapter->filename = $match->filename; - $chapter->section = $match->section; - $chapter->page = $i + 1; - $chapter->content = $pages[$i]->getText(); - $chapter->book_url = block_lrf_get_book_chapter_url($match->bookid, $i + 1); - $chapters[] = $chapter; + for ($i = 0; $i < $pdf_details['Pages']; $i++) { + $chapter = new stdClass(); + $chapter->filename = $match->filename; + $chapter->section = $match->section; + $chapter->page = $i + 1; + $chapter->content = $pages[$i]->getText(); + $chapter->book_url = block_slidefinder_get_book_chapter_url($match->bookid, $i + 1); + $chapters[] = $chapter; + } + } catch (\Throwable $th) { + gc_collect_cycles(); + debugging($th); + return null; } + gc_collect_cycles(); return $chapters; } @@ -121,7 +171,7 @@ function block_lrf_get_content_as_chapters($match) { * * @return string url linking to the book chapter */ -function block_lrf_get_book_chapter_url($book_id, $pagenum) { +function block_slidefinder_get_book_chapter_url($book_id, $pagenum) { global $DB; $book_type_id = $DB->get_field('modules', 'id', ['name' => 'book'], MUST_EXIST); @@ -138,7 +188,7 @@ function block_lrf_get_book_chapter_url($book_id, $pagenum) { * @param int $cid ID of a course. The selected course is at the beginning of the array, else a selection method. * @return array Array of courses the current user has access to. Position 1 is either selected course or selection message. */ -function block_lrf_select_course_options(int $cid = 0) { +function block_slidefinder_select_course_options(int $cid = 0) { $courses = array(); foreach (get_courses() as $course) { diff --git a/renderer.php b/renderer.php deleted file mode 100644 index 7cc74eb..0000000 --- a/renderer.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * Renderer - * - * @package block_slidefinder - * @copyright 2022 Universtity of Stuttgart - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -defined('MOODLE_INTERNAL') || die(); - - -class block_slidefinder_renderer extends plugin_renderer_base -{ -} diff --git a/templates/lrf_drop_down.mustache b/templates/lrf_drop_down.mustache index 471c3a5..2e15fbe 100644 --- a/templates/lrf_drop_down.mustache +++ b/templates/lrf_drop_down.mustache @@ -25,27 +25,30 @@ "course_selector_param_name": "lrf_cid", "course_selector_options": [{id:3, value:VALUE}], + + "hidden_params":[{name:cache, value=1}] } }}
{{^inform}} -
+ {{/inform}}
-
{{^inform}} diff --git a/templates/lrf_search.mustache b/templates/lrf_search.mustache index 2b410dd..c0e2ad7 100644 --- a/templates/lrf_search.mustache +++ b/templates/lrf_search.mustache @@ -23,7 +23,6 @@ { "action": "https://moodle.local/admin/search.php", - "cid": 0, "lrf_cid": 0, "course_selector_param_name": "lrf_cid", @@ -43,8 +42,8 @@ {{/inform}} - {{#cid}}{{/cid}} {{#lrf_cid}}{{/lrf_cid}} + {{#hidden_params}} {{/hidden_params}}