forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-40457 Question Bank: Allow plugins to add columns to question ban…
…k view Allows plugins to add columns to the question bank view by extending core_question\bank\column_base Columns to display are set in $CFG->questionbankcolumns. Columns are namespaced and autoloaded to support this.
- Loading branch information
1 parent
7784c3a
commit 17f229f
Showing
18 changed files
with
1,935 additions
and
1,526 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,46 @@ | ||
<?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 core_question\bank; | ||
|
||
/** | ||
* A base class for actions that are an icon that lets you manipulate the question in some way. | ||
* | ||
* @copyright 2009 Tim Hunt | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
abstract class action_column_base extends column_base { | ||
|
||
protected function get_title() { | ||
return ' '; | ||
} | ||
|
||
public function get_extra_classes() { | ||
return array('iconcol'); | ||
} | ||
|
||
protected function print_icon($icon, $title, $url) { | ||
global $OUTPUT; | ||
echo '<a title="' . $title . '" href="' . $url . '"> | ||
<img src="' . $OUTPUT->pix_url($icon) . '" class="iconsmall" alt="' . $title . '" /></a>'; | ||
} | ||
|
||
public function get_required_fields() { | ||
// Createdby is required for permission checks. | ||
return array('q.id', 'q.createdby'); | ||
} | ||
} |
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 core_question\bank; | ||
|
||
/** | ||
* A column with a checkbox for each question with name q{questionid}. | ||
* | ||
* @copyright 2009 Tim Hunt | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class checkbox_column extends column_base { | ||
protected $strselect; | ||
protected $firstrow = true; | ||
|
||
public function init() { | ||
$this->strselect = get_string('select'); | ||
} | ||
|
||
public function get_name() { | ||
return 'checkbox'; | ||
} | ||
|
||
protected function get_title() { | ||
return '<input type="checkbox" disabled="disabled" id="qbheadercheckbox" />'; | ||
} | ||
|
||
protected function get_title_tip() { | ||
return get_string('selectquestionsforbulk', 'question'); | ||
} | ||
|
||
protected function display_content($question, $rowclasses) { | ||
global $PAGE; | ||
echo '<input title="' . $this->strselect . '" type="checkbox" name="q' . | ||
$question->id . '" id="checkq' . $question->id . '" value="1"/>'; | ||
if ($this->firstrow) { | ||
$PAGE->requires->strings_for_js(array('selectall', 'deselectall'), 'moodle'); | ||
$PAGE->requires->yui_module('moodle-question-qbankmanager', 'M.question.qbankmanager.init', | ||
array('checkq' . $question->id)); | ||
$this->firstrow = false; | ||
} | ||
} | ||
|
||
public function get_required_fields() { | ||
return array('q.id'); | ||
} | ||
} |
Oops, something went wrong.