]> git.mjollnir.org Git - moodle.git/commitdiff
adding some outcome files
authortoyomoyo <toyomoyo>
Mon, 23 Jul 2007 07:49:52 +0000 (07:49 +0000)
committertoyomoyo <toyomoyo>
Mon, 23 Jul 2007 07:49:52 +0000 (07:49 +0000)
grade/report/outcomes/editoutcomes.php [new file with mode: 0755]
grade/report/outcomes/settings.php [new file with mode: 0755]

diff --git a/grade/report/outcomes/editoutcomes.php b/grade/report/outcomes/editoutcomes.php
new file mode 100755 (executable)
index 0000000..8732016
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+include_once('../../../config.php');
+require_once $CFG->libdir.'/formslib.php';
+class edit_outcomes_form extends moodleform {
+
+    function definition() {
+        global $CFG, $COURSE;
+
+        $mform =& $this->_form;
+        $mform->addElement('header', 'general', get_string('outcomes'));
+        
+        $mform->addElement('text', 'shortname', get_string('shortname'));
+        $mform->addRule('shortname', get_string('required'), 'required');
+        $mform->setType('id', PARAM_TEXT);
+        
+        $mform->addElement('text', 'fullname', get_string('fullname'));
+        $mform->addRule('fullname', get_string('required'), 'required');
+        $mform->setType('id', PARAM_TEXT);
+        
+        $scalearr = array();
+        if ($scales = get_records('scale')) {
+            foreach ($scales as $scale) {
+                $scalearr[$scale->id] = $scale->name;      
+            }
+        }
+
+        $mform->addElement('select', 'scaleid', get_string('scale'), $scalearr);
+        $mform->addRule('scaleid', get_string('required'), 'required');
+        $mform->setType('scaleid', PARAM_INT);
+        $mform->addElement('hidden', 'id');
+        $mform->setType('id', PARAM_INT);
+//-------------------------------------------------------------------------------
+        // buttons
+        $this->add_action_buttons();
+    }
+}
+
+$id = optional_param('id', 0, PARAM_INT); // id of the outcome
+if ($courseid = optional_param('courseid', 0, PARAM_INT)) { 
+    // optional course id, if set, editting from course
+} else {
+    // admin editting site level outcomes
+    $returnurl = $CFG->wwwroot."/grade/report/outcomes/settings.php";
+}
+// form processing
+
+$mform = new edit_outcomes_form();
+if ($id) {
+    // form set data  
+    $mform->set_data(get_record('grade_outcomes', 'id', $id));    
+}
+
+if ($mform->is_cancelled()) {
+    redirect($returnurl); 
+}
+if ($data = $mform->get_data()) {
+    if ($data->id) {
+        update_record('grade_outcomes', $data);
+    } else {
+        insert_record('grade_outcomes', $data);
+    }
+    redirect($returnurl);
+}
+
+print_header();
+$mform->display();
+print_footer();
+?>
\ No newline at end of file
diff --git a/grade/report/outcomes/settings.php b/grade/report/outcomes/settings.php
new file mode 100755 (executable)
index 0000000..7e9f8b7
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+
+include_once('../../../config.php');
+require_once($CFG->libdir.'/adminlib.php');
+require_once($CFG->libdir.'/tablelib.php');
+
+// setting up params
+$id = optional_param('id', 0, PARAM_INT); // outcomes id
+$page = optional_param('page', 0, PARAM_INT); // current page
+$search = optional_param('search', 0, PARAM_TEXT);
+$deleteid = optional_param('deleteid', 0, PARAM_INT); // which outcome to delete
+$confirm = optional_param('confirm', 1, PARAM_INT);
+$perpage = 30;
+
+// form processing
+if ($frm = data_submitted() && confirm_sesskey() && $deleteid) {
+    if ($confirm) {
+        // delete all outcomes used in courses
+        // delete all outcomes used in grade items
+    } else {
+        // prints confirmation
+    }
+}
+
+/// display information
+admin_externalpage_setup('gradereportoutcomes');
+admin_externalpage_print_header();
+
+/******************* ADD TABS HERE LATER ****************************/
+
+$totalcount = count_records('grade_outcomes');
+$baseurl = "settings.php";
+print_paging_bar($totalcount, $page, $perpage, $baseurl);
+
+if ($outcomes = get_recordset('grade_outcomes', '', '', '', '*', $page * $perpage, $perpage)) {
+        
+    $tablecolumns = array('outcome', 'edit', 'usedgradeitems', 'usedcourses');
+    $tableheaders = array(get_string('outcomes'), get_string('operations'), get_string('usedgradeitem'), get_string('usedcourses'));
+    
+    $table = new flexible_table('outcomes');
+    $table->define_columns($tablecolumns);
+    $table->define_headers($tableheaders);
+    $table->define_baseurl($baseurl);
+    $table->set_attribute('cellspacing', '0');
+    $table->set_attribute('id', 'user-grade');
+    $table->set_attribute('class', 'boxaligncenter generaltable');  
+    
+    $table->setup();
+    
+    foreach ($outcomes as $outcome) {
+        $data = array();
+        $data[] = $outcome['fullname'];
+        
+        // add operations
+        $data[] = '<a href="editoutcomes.php?id='.$outcome['id'].'"><img alt="Update" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/edit.gif"/></a>
+                   <a href="settings.php?deleteid='.$outcome['id'].'"><img alt="Delete" class="iconsmall" src="'.$CFG->wwwroot.'/pix/t/delete.gif"/></a>'; // icons and links
+        
+        // num of gradeitems using this
+        $num = count_records('grade_outcomes_courses', 'outcomeid' ,$outcome['id']);
+        $data[] = (int) $num;
+        
+        // num of courses using this outcome
+        $num = count_records('grade_items', 'outcomeid', $outcome['id']);
+        $data[] = (int) $num;
+
+        $table->add_data($data);
+    }
+    
+    $table->print_html();
+}
+
+echo '<a href="editoutcomes.php">Add a new outcome</a>';
+
+// print the footer, end of page
+admin_externalpage_print_footer();
+?>
\ No newline at end of file