mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-72448 qbank_history: Add history plugin to core
This implementation will introduce history plugin to show the versions of a question. This plugin uses the actual qbank api to implement the feature.
- Loading branch information
1 parent
9cd77c4
commit 6c923f4
Showing
17 changed files
with
918 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?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/>. | ||
|
||
namespace qbank_history; | ||
|
||
/** | ||
* Helper class for question history. | ||
* | ||
* @package qbank_history | ||
* @copyright 2022 Catalyst IT Australia Pty Ltd | ||
* @author Safat Shahin <safatshahin@catalyst-au.net> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class helper { | ||
|
||
/** | ||
* Get the question history url. | ||
* | ||
* @param int $entryid id of the question entry | ||
* @param string $returnrul url of the page to return to | ||
* @param int $courseid id of the course | ||
* @return \moodle_url | ||
*/ | ||
public static function question_history_url(int $entryid, string $returnrul, int $courseid): \moodle_url { | ||
$params = [ | ||
'entryid' => $entryid, | ||
'returnurl' => $returnrul, | ||
'courseid' => $courseid | ||
]; | ||
|
||
return new \moodle_url('/question/bank/history/history.php', $params); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?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/>. | ||
|
||
namespace qbank_history; | ||
|
||
use core_question\local\bank\menu_action_column_base; | ||
|
||
/** | ||
* Question bank column for the history action icon. | ||
* | ||
* @package qbank_history | ||
* @copyright 2022 Catalyst IT Australia Pty Ltd | ||
* @author Safat Shahin <safatshahin@catalyst-au.net> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class history_action_column extends menu_action_column_base { | ||
|
||
// Store this lang string for performance. | ||
protected $strpreview; | ||
|
||
public function init(): void { | ||
parent::init(); | ||
$this->strpreview = get_string('history_action', 'qbank_history'); | ||
} | ||
|
||
public function get_name(): string { | ||
return 'historyaction'; | ||
} | ||
|
||
protected function get_url_icon_and_label(\stdClass $question): array { | ||
if (!\question_bank::is_qtype_installed($question->qtype)) { | ||
// It sometimes happens that people end up with junk questions | ||
// in their question bank of a type that is no longer installed. | ||
// We cannot do most actions on them, because that leads to errors. | ||
return [null, null, null]; | ||
} | ||
|
||
if (question_has_capability_on($question, 'use')) { | ||
$url = helper::question_history_url($question->questionbankentryid, $this->qbank->returnurl, | ||
$this->qbank->course->id); | ||
return [$url, 't/log', $this->strpreview]; | ||
} | ||
|
||
return [null, null, null]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?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/>. | ||
|
||
namespace qbank_history\output; | ||
|
||
/** | ||
* Class renderer for rendering question history. | ||
* | ||
* @package qbank_history | ||
* @copyright 2022 Catalyst IT Australia Pty Ltd | ||
* @author Safat Shahin <safatshahin@catalyst-au.net> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class renderer extends \plugin_renderer_base { | ||
|
||
/** | ||
* Render the history header. | ||
* | ||
* @param array $historydata data to be passed in the mustache | ||
* @return string | ||
*/ | ||
public function render_history_header(array $historydata): string { | ||
return $this->render_from_template('qbank_history/history_header', $historydata); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?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/>. | ||
|
||
namespace qbank_history; | ||
|
||
/** | ||
* Class plugin_feature is the entrypoint for the columns. | ||
* | ||
* @package qbank_history | ||
* @copyright 2022 Catalyst IT Australia Pty Ltd | ||
* @author Safat Shahin <safatshahin@catalyst-au.net> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class plugin_feature extends \core_question\local\bank\plugin_features_base { | ||
|
||
public function get_question_columns($qbank): array { | ||
return [ | ||
new history_action_column($qbank), | ||
new version_number_column($qbank) | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?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/>. | ||
|
||
namespace qbank_history\privacy; | ||
|
||
/** | ||
* Privacy Subsystem for qbank_history implementing null_provider. | ||
* | ||
* @package qbank_history | ||
* @copyright 2022 Catalyst IT Australia Pty Ltd | ||
* @author Safat Shahin <safatshahin@catalyst-au.net> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class provider implements \core_privacy\local\metadata\null_provider { | ||
|
||
public static function get_reason(): string { | ||
return 'privacy:metadata'; | ||
} | ||
|
||
} |
Oops, something went wrong.