���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/bank.tar
���ѧ٧ѧ�
search/tag_condition.php 0000644 00000010670 15152217524 0011353 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * A condition for adding filtering by tag to the question bank. * * @package core_question * @copyright 2018 Ryan Wyllie <ryan@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core_question\bank\search; /** * Question bank search class to allow searching/filtering by tags on a question. * * @copyright 2018 Ryan Wyllie <ryan@moodle.com> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class tag_condition extends condition { /** @var string SQL fragment to add to the where clause. */ protected $where; /** @var string SQL fragment to add to the where clause. */ protected $contexts; /** @var array List of IDs for tags that have been selected in the form. */ protected $selectedtagids; /** * Constructor. * * @param array $contexts List of contexts to show tags from * @param int[] $selectedtagids List of IDs for tags to filter by. * @throws \coding_exception * @throws \dml_exception */ public function __construct(array $contexts, array $selectedtagids = []) { global $DB; $this->contexts = $contexts; // If some tags have been selected then we need to filter // the question list by the selected tags. if ($selectedtagids) { // We treat each additional tag as an AND condition rather than // an OR condition. // // For example, if the user filters by the tags "foo" and "bar" then // we reduce the question list to questions that are tagged with both // "foo" AND "bar". Any question that does not have ALL of the specified // tags will be omitted. list($tagsql, $tagparams) = $DB->get_in_or_equal($selectedtagids, SQL_PARAMS_NAMED); $tagparams['tagcount'] = count($selectedtagids); $tagparams['questionitemtype'] = 'question'; $tagparams['questioncomponent'] = 'core_question'; $this->selectedtagids = $selectedtagids; $this->params = $tagparams; $this->where = "q.id IN (SELECT ti.itemid FROM {tag_instance} ti WHERE ti.itemtype = :questionitemtype AND ti.component = :questioncomponent AND ti.tagid {$tagsql} GROUP BY ti.itemid HAVING COUNT(itemid) = :tagcount)"; } else { $this->selectedtagids = []; $this->params = []; $this->where = ''; } } /** * Get the SQL WHERE snippet to be used in the SQL to retrieve the * list of questions. This SQL snippet will add the logic for the * tag condition. * * @return string */ public function where() { return $this->where; } /** * Named SQL params to be used with the SQL WHERE snippet. * * @return array */ public function params() { return $this->params; } /** * Print HTML to display the list of tags to filter by. */ public function display_options() { global $OUTPUT; $tags = \core_tag_tag::get_tags_by_area_in_contexts('core_question', 'question', $this->contexts); $tagoptions = array_map(function($tag) { return [ 'id' => $tag->id, 'name' => $tag->name, 'selected' => in_array($tag->id, $this->selectedtagids) ]; }, array_values($tags)); $context = [ 'tagoptions' => $tagoptions ]; return $OUTPUT->render_from_template('core_question/tag_condition', $context); } } search/category_condition.php 0000644 00000016617 15152217524 0012424 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * A search class to control from which category questions are listed. * * @package core_question * @copyright 2013 Ray Morris * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core_question\bank\search; use qbank_managecategories\helper; /** * This class controls from which category questions are listed. * * @copyright 2013 Ray Morris * @author 2021 Safat Shahin <safatshahin@catalyst-au.net> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class category_condition extends condition { /** @var \stdClass The course record. */ protected $course; /** @var \stdClass The category record. */ protected $category; /** @var array of contexts. */ protected $contexts; /** @var bool Whether to include questions from sub-categories. */ protected $recurse; /** @var string SQL fragment to add to the where clause. */ protected $where; /** @var array query param used in where. */ protected $params; /** @var string categoryID,contextID as used with question_bank_view->display(). */ protected $cat; /** @var int The maximum displayed length of the category info. */ protected $maxinfolength; /** * Constructor * @param string $cat categoryID,contextID as used with question_bank_view->display() * @param bool $recurse Whether to include questions from sub-categories * @param array $contexts Context objects as used by question_category_options() * @param \moodle_url $baseurl The URL the form is submitted to * @param \stdClass $course Course record * @param integer $maxinfolength The maximum displayed length of the category info. */ public function __construct($cat, $recurse, $contexts, $baseurl, $course, $maxinfolength = null) { $this->cat = $cat; $this->recurse = $recurse; $this->contexts = $contexts; $this->baseurl = $baseurl; $this->course = $course; $this->init(); $this->maxinfolength = $maxinfolength; } /** * Initialize the object so it will be ready to return where() and params() */ private function init() { global $DB; if (!$this->category = $this->get_current_category($this->cat)) { return; } if ($this->recurse) { $categoryids = question_categorylist($this->category->id); } else { $categoryids = [$this->category->id]; } list($catidtest, $this->params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED, 'cat'); $this->where = 'qbe.questioncategoryid ' . $catidtest; } /** * SQL fragment to add to the where clause. * * @return string */ public function where() { return $this->where; } /** * Return parameters to be bound to the above WHERE clause fragment. * @return array parameter name => value. */ public function params() { return $this->params; } /** * Called by question_bank_view to display the GUI for selecting a category */ public function display_options() { global $PAGE; $displaydata = []; $catmenu = helper::question_category_options($this->contexts, true, 0, true, -1, false); $displaydata['categoryselect'] = \html_writer::select($catmenu, 'category', $this->cat, [], array('class' => 'searchoptions custom-select', 'id' => 'id_selectacategory')); $displaydata['categorydesc'] = ''; if ($this->category) { $displaydata['categorydesc'] = $this->print_category_info($this->category); } return $PAGE->get_renderer('core_question', 'bank')->render_category_condition($displaydata); } /** * Displays the recursion checkbox GUI. * question_bank_view places this within the section that is hidden by default */ public function display_options_adv() { global $PAGE; $displaydata = []; if ($this->recurse) { $displaydata['checked'] = 'checked'; } return $PAGE->get_renderer('core_question', 'bank')->render_category_condition_advanced($displaydata); } /** * Display the drop down to select the category. * * @param array $contexts of contexts that can be accessed from here. * @param \moodle_url $pageurl the URL of this page. * @param string $current 'categoryID,contextID'. * @deprecated since Moodle 4.0 */ protected function display_category_form($contexts, $pageurl, $current) { debugging('Function display_category_form() is deprecated, please use the core_question renderer instead.', DEBUG_DEVELOPER); echo \html_writer::start_div('choosecategory'); $catmenu = question_category_options($contexts, true, 0, true, -1, false); echo \html_writer::label(get_string('selectacategory', 'question'), 'id_selectacategory', true, ["class" => "mr-1"]); echo \html_writer::select($catmenu, 'category', $current, [], array('class' => 'searchoptions custom-select', 'id' => 'id_selectacategory')); echo \html_writer::end_div() . "\n"; } /** * Look up the category record based on cateogry ID and context * @param string $categoryandcontext categoryID,contextID as used with question_bank_view->display() * @return \stdClass The category record */ protected function get_current_category($categoryandcontext) { global $DB, $OUTPUT; list($categoryid, $contextid) = explode(',', $categoryandcontext); if (!$categoryid) { $this->print_choose_category_message($categoryandcontext); return false; } if (!$category = $DB->get_record('question_categories', ['id' => $categoryid, 'contextid' => $contextid])) { echo $OUTPUT->box_start('generalbox questionbank'); echo $OUTPUT->notification('Category not found!'); echo $OUTPUT->box_end(); return false; } return $category; } /** * Print the category description * @param \stdClass $category the category information form the database. */ protected function print_category_info($category): string { $formatoptions = new \stdClass(); $formatoptions->noclean = true; $formatoptions->overflowdiv = true; if (isset($this->maxinfolength)) { return shorten_text(format_text($category->info, $category->infoformat, $formatoptions, $this->course->id), $this->maxinfolength); } else { return format_text($category->info, $category->infoformat, $formatoptions, $this->course->id); } } } search/condition.php 0000644 00000004340 15152217524 0010515 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Defines an abstract class for filtering/searching the question bank. * * @package core_question * @copyright 2013 Ray Morris * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core_question\bank\search; /** * An abstract class for filtering/searching questions. * * See also {@see question_bank_view::init_search_conditions()}. * @copyright 2013 Ray Morris * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class condition { /** * Return an SQL fragment to be ANDed into the WHERE clause to filter which questions are shown. * @return string SQL fragment. Must use named parameters. */ abstract public function where(); /** * Return parameters to be bound to the above WHERE clause fragment. * @return array parameter name => value. */ public function params() { return []; } /** * Display GUI for selecting criteria for this condition. Displayed when Show More is open. * * Compare display_options(), which displays always, whether Show More is open or not. * @return bool|string HTML form fragment */ public function display_options_adv() { return false; } /** * Display GUI for selecting criteria for this condition. Displayed always, whether Show More is open or not. * * Compare display_options_adv(), which displays when Show More is open. * @return bool|string HTML form fragment */ public function display_options() { return false; } } search/hidden_condition.php 0000644 00000004611 15152217524 0012031 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * A search class to control whether hidden / deleted questions are hidden in the list. * * @package core_question * @copyright 2013 Ray Morris * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core_question\bank\search; use core_question\local\bank\question_version_status; /** * This class controls whether hidden / deleted questions are hidden in the list. * * @copyright 2013 Ray Morris * @author 2021 Safat Shahin <safatshahin@catalyst-au.net> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class hidden_condition extends condition { /** @var bool Whether to include old "deleted" questions. */ protected $hide; /** @var string SQL fragment to add to the where clause. */ protected $where; /** * Constructor. * @param bool $hide whether to include old "deleted" questions. */ public function __construct($hide = true) { $this->hide = $hide; if ($hide) { $this->where = "qv.status = '" . question_version_status::QUESTION_STATUS_READY . "' " . " OR qv.status = '" . question_version_status::QUESTION_STATUS_DRAFT . "' "; } } /** * SQL fragment to add to the where clause. * * @return string */ public function where() { return $this->where; } /** * Print HTML to display the "Also show old questions" checkbox */ public function display_options_adv() { global $PAGE; $displaydata = []; if (!$this->hide) { $displaydata['checked'] = 'checked'; } return $PAGE->get_renderer('core_question', 'bank')->render_hidden_condition_advanced($displaydata); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�