adding some strings
[moodle-linuxchix.git] / grade / report / outcomes / editoutcomes.php
blobef6bc50507dbf95274dcde9516a9d1c8c79131c5
1 <?php
3 include_once('../../../config.php');
4 require_once $CFG->libdir.'/formslib.php';
6 // courseid needs to be passed in to know whether this should be tied to a course
7 class edit_outcomes_form extends moodleform {
9 function definition() {
10 global $CFG, $COURSE;
12 $mform =& $this->_form;
13 $mform->addElement('header', 'general', get_string('outcomes'));
15 $mform->addElement('text', 'shortname', get_string('shortname'));
16 $mform->addRule('shortname', get_string('required'), 'required');
17 $mform->setType('shortname', PARAM_TEXT);
19 $mform->addElement('text', 'fullname', get_string('fullname'));
20 $mform->addRule('fullname', get_string('required'), 'required');
21 $mform->setType('fullname', PARAM_TEXT);
23 $scalearr = array();
24 if ($scales = get_records('scale')) {
25 foreach ($scales as $scale) {
26 $scalearr[$scale->id] = $scale->name;
30 $mform->addElement('select', 'scaleid', get_string('scale'), $scalearr);
31 $mform->addRule('scaleid', get_string('required'), 'required');
32 $mform->setType('scaleid', PARAM_INT);
33 $mform->addElement('hidden', 'id');
34 $mform->setType('id', PARAM_INT);
35 $mform->addElement('hidden', 'courseid');
36 $mform->setType('courseid', PARAM_INT);
37 //-------------------------------------------------------------------------------
38 // buttons
39 $this->add_action_buttons();
43 $id = optional_param('id', 0, PARAM_INT); // id of the outcome
44 if ($courseid = optional_param('courseid', 0, PARAM_INT)) {
45 // optional course id, if set, editting from course
46 require_login($courseid);
47 require_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_COURSE, $courseid));
48 $returnurl = $CFG->wwwroot."/grade/report/outcomes/course.php?id=$courseid";
49 } else {
50 // admin editting site level outcomes
51 require_capability('gradereport/outcomes:manage', get_context_instance(CONTEXT_SYSTEM));
52 $returnurl = $CFG->wwwroot."/grade/report/outcomes/site.php";
54 // form processing
56 $mform = new edit_outcomes_form();
57 if ($id) {
58 // form set data
59 $mform->set_data(get_record('grade_outcomes', 'id', $id));
61 // if courseid is provided, set it in the form
62 if ($courseid) {
63 $data->courseid = $courseid;
64 $mform->set_data($data);
67 if ($mform->is_cancelled()) {
68 redirect($returnurl);
70 if ($data = $mform->get_data()) {
71 if ($data->courseid == 0) {
72 $data->courseid = NULL;
75 if ($data->id) {
76 update_record('grade_outcomes', $data);
77 } else {
78 insert_record('grade_outcomes', $data);
80 redirect($returnurl);
83 // Build navigation
84 $strgrades = get_string('grades');
85 $stroutcomes = get_string('outcomes', 'grades');
86 $navlinks = array();
87 $navlinks[] = array('name' => $strgrades, 'link' => $CFG->wwwroot . '/grade/index.php?id='.$courseid, 'type' => 'misc');
88 $navlinks[] = array('name' => $stroutcomes, 'link' => '', 'type' => 'misc');
90 $navigation = build_navigation($navlinks);
91 /// Print header
92 print_header_simple($strgrades.':'.$stroutcomes, ':'.$strgrades, $navigation, '', '', true);
93 // Add tabs
94 $currenttab = 'editoutcomes';
95 include('tabs.php');
96 $mform->display();
97 print_footer();