From: toyomoyo Date: Mon, 23 Jul 2007 07:49:52 +0000 (+0000) Subject: adding some outcome files X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e7746cf4f86c82415fcd864a5092dc2d1159ac77;p=moodle.git adding some outcome files --- diff --git a/grade/report/outcomes/editoutcomes.php b/grade/report/outcomes/editoutcomes.php new file mode 100755 index 0000000000..8732016b1c --- /dev/null +++ b/grade/report/outcomes/editoutcomes.php @@ -0,0 +1,69 @@ +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 index 0000000000..7e9f8b74d6 --- /dev/null +++ b/grade/report/outcomes/settings.php @@ -0,0 +1,76 @@ +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[] = 'Update + Delete'; // 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 'Add a new outcome'; + +// print the footer, end of page +admin_externalpage_print_footer(); +?> \ No newline at end of file