MDL-22388 Added some checks to kill these scripts dead with an unequivocal notice...
[moodle.git] / mod / feedback / choose_group_form.php
CommitLineData
1adbd2c3 1<?php
c70ad9f7 2/**
3* prints the form to choose the group you want to analyse
4*
c70ad9f7 5* @author Andreas Grabs
6* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
7* @package feedback
8*/
9
bfebaf64
MD
10if (!defined('MOODLE_INTERNAL')) {
11 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
12}
13
c70ad9f7 14require_once $CFG->libdir.'/formslib.php';
15
16class feedback_choose_group_form extends moodleform {
17 var $feedbackdata;
1adbd2c3 18
c70ad9f7 19 function definition() {
20 $this->feedbackdata = new object();
21 //this function can not be called, because not all data are available at this time
22 //I use set_form_elements instead
23 }
1adbd2c3 24
c70ad9f7 25 //this function set the data used in set_form_elements()
26 //in this form the only value have to set is course
27 //eg: array('course' => $course)
28 function set_feedbackdata($data) {
29 if(is_array($data)) {
30 foreach($data as $key => $val) {
31 $this->feedbackdata->{$key} = $val;
32 }
33 }
34 }
1adbd2c3 35
c70ad9f7 36 //here the elements will be set
37 //this function have to be called manually
38 //the advantage is that the data are already set
39 function set_form_elements(){
40 $mform =& $this->_form;
1adbd2c3 41
c70ad9f7 42 $elementgroup = array();
43 //headline
44 // $mform->addElement('header', 'general', get_string('choose_group', 'feedback'));
45 // hidden elements
46 $mform->addElement('hidden', 'id');
d18e0fe6 47 $mform->setType('id', PARAM_INT);
c70ad9f7 48 $mform->addElement('hidden', 'do_show');
d18e0fe6 49 $mform->setType('do-show', PARAM_INT);
1adbd2c3 50
c70ad9f7 51 // visible elements
52 $groups_options = array();
53 if(isset($this->feedbackdata->groups)){
54 $groups_options['-1'] = get_string('allgroups');
55 foreach($this->feedbackdata->groups as $group) {
56 $groups_options[$group->id] = $group->name;
57 }
58 }
59 $attributes = 'onChange="this.form.submit()"';
60 $elementgroup[] =& $mform->createElement('select', 'lstgroupid', '', $groups_options, $attributes);
61 // buttons
62 $elementgroup[] =& $mform->createElement('submit', 'switch_group', get_string('switch_group', 'feedback'));
63 $mform->addGroup($elementgroup, 'elementgroup', '', array(' '), false);
1adbd2c3 64
c70ad9f7 65//-------------------------------------------------------------------------------
66 }
67}
1adbd2c3 68