From 91737ef3898dc7cc8ce4f598882a686db6a33d0e Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Thu, 7 Aug 2014 13:47:36 +0800 Subject: [PATCH] MDL-46569 gradereport_history: Create a helper class Part of MDL-46191 --- grade/report/history/classes/helper.php | 78 +++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 grade/report/history/classes/helper.php diff --git a/grade/report/history/classes/helper.php b/grade/report/history/classes/helper.php new file mode 100644 index 00000000000..c5e71182586 --- /dev/null +++ b/grade/report/history/classes/helper.php @@ -0,0 +1,78 @@ +. + +/** + * Helper class for gradehistory report. + * + * @package gradereport_history + * @copyright 2014 onwards Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace gradereport_history; + +defined('MOODLE_INTERNAL') || die; + +/** + * Helper class for gradehistory report. + * + * @since Moodle 2.8 + * @package gradereport_history + * @copyright 2014 onwards Ankit Agarwal + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class helper { + /** + * Get an instance of the user select button {@link gradereport_history_user_button}. + * + * @param int $courseid course id. + * @param array $currentusers List of currently selected users. + * + * @return output\user_button the user select button. + */ + public static function get_user_select_button($courseid, $currentusers = array()) { + global $PAGE; + $button = new output\user_button($PAGE->url, get_string('selectuser', 'gradereport_history'), 'get'); + $button->class .= ' gradereport_history_plugin'; + + $modules = array('moodle-gradereport_history-quickselect', 'moodle-gradereport_history-quickselect-skin'); + $arguments = array( + 'courseid' => $courseid, + 'ajaxurl' => '/grade/report/history/ajax.php', + 'url' => $PAGE->url->out(false), + 'userfullnames' => $currentusers, + ); + + $function = 'M.gradereport_history.quickselect.init'; + $button->require_yui_module($modules, $function, array($arguments)); + $button->strings_for_js(array( + 'ajaxoneuserfound', + 'ajaxxusersfound', + 'ajaxnext25', + 'errajaxsearch', + 'none', + 'usersearch' + ), 'enrol'); + $button->strings_for_js(array( + 'deselect', + 'selectuser', + 'finishselectingusers', + ), 'gradereport_history'); + $button->strings_for_js('select'); + + return $button; + } +}