<?php //$Id$
+/**
+ * Print grading plugin selection popup form.
+ *
+ * @param int $courseid id of course
+ * @param string $active_type type of plugin on current page - import, export, report or edit
+ * @param string $active_plugin active plugin type - grader, user, cvs, ...
+ * @param boolean $return return as string
+ * @return nothing or string if $return true
+ */
function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $return=false) {
global $CFG;
return popup_form($CFG->wwwroot.'/grade/', $menu, 'choosepluginreport', $active, 'choose', '', '', $return, 'self', get_string('selectplugin', 'grades'));
}
+/**
+ * Utility class used for return tracking when using edit and other forms from grade plubins
+ */
class grade_plugin_return {
var $type;
var $plugin;
var $userid;
var $page;
+ /**
+ * Constructor
+ * @param array $params - associative array with return parameters, if null parameter are taken from _GET or _POST
+ */
function grade_plugin_return ($params=null) {
if (empty($params)) {
$this->type = optional_param('gpr_type', null, PARAM_SAFEDIR);
}
}
+ /**
+ * Returns return parameters as options array suitable for buttons.
+ * @return array options
+ */
function get_options() {
if (empty($this->type) or empty($this->plugin)) {
return array();
return $params;
}
+ /**
+ * Returns return url
+ * @param string $default default url when params not set
+ * @return string url
+ */
function get_return_url($default) {
global $CFG;
return $url;
}
+ /**
+ * Returns string with hidden return tracking form elements.
+ * @return string
+ */
function get_form_fields() {
if (empty($this->type) or empty($this->plugin)) {
return '';
}
}
+ /**
+ * Add hidden elements into mform
+ * @param object $mform moodle form object
+ * @return void
+ */
function add_mform_elements(&$mform) {
if (empty($this->type) or empty($this->plugin)) {
return;
}
}
+ /**
+ * Add return tracking params into url
+ * @param string $url
+ * @return string $url with erturn tracking params
+ */
function add_url_params($url) {
if (empty($this->type) or empty($this->plugin)) {
return $url;