From: toyomoyo Date: Tue, 3 Jul 2007 06:20:07 +0000 (+0000) Subject: some minor cleanup/bug fix X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7759d32720ed06f1e99612615550693c16627b0b;p=moodle.git some minor cleanup/bug fix --- diff --git a/grade/export/grade_export_form.php b/grade/export/grade_export_form.php index dfda9fd6a9..9326fea522 100755 --- a/grade/export/grade_export_form.php +++ b/grade/export/grade_export_form.php @@ -9,7 +9,7 @@ class grade_export_form extends moodleform { $mform->addElement('header', 'general', get_string('gradeitemsinc', 'grades')); // TODO: localize $id = $this->_customdata['id']; // course id $mform->addElement('hidden', 'id', $id); - if ($grade_items = grade_grades::fetch_all(array('courseid'=>$id))) { + if ($grade_items = grade_item::fetch_all(array('courseid'=>$id))) { foreach ($grade_items as $grade_item) { $element = new HTML_QuickForm_advcheckbox('itemids[]', null, $grade_item->itemname, array('selected'=>'selected'), array(0, $grade_item->id)); $element->setChecked(1); diff --git a/grade/export/lib.php b/grade/export/lib.php index 9890271c33..46caa062a0 100755 --- a/grade/export/lib.php +++ b/grade/export/lib.php @@ -121,7 +121,7 @@ class grade_export { foreach ($itemids as $iid) { if ($iid) { - $params->id = $iid; + $params->id = clean_param($iid, PARAM_INT); $gradeitems[] = new grade_item($params); } } diff --git a/grade/export/ods/export.php b/grade/export/ods/export.php index 20fd2053b0..a6528764b9 100755 --- a/grade/export/ods/export.php +++ b/grade/export/ods/export.php @@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/grade/export/lib.php'); require_once('grade_export_ods.php'); $id = required_param('id', PARAM_INT); // course id -$itemids = explode(",", required_param('itemids', PARAM_NOTAGS)); +$itemids = explode(",", required_param('itemids', PARAM_RAW)); $feedback = optional_param('feedback', '', PARAM_ALPHA); // print all the exported data here diff --git a/grade/export/ods/index.php b/grade/export/ods/index.php index 706dd00725..97625668be 100755 --- a/grade/export/ods/index.php +++ b/grade/export/ods/index.php @@ -25,9 +25,11 @@ require_once("../../../config.php"); require_once($CFG->dirroot.'/grade/export/lib.php'); require_once('grade_export_ods.php'); -$id = required_param('id', PARAM_INT); // course id -$feedback = optional_param('feedback', '', PARAM_ALPHA); - +$id = required_param('id', PARAM_INT); // course id +$course = get_record('course', 'id', $id); +$feedback = optional_param('feedback', '', PARAM_ALPHA); +$action = 'exportods'; +print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); // process post information if (($data = data_submitted()) && confirm_sesskey()) { @@ -38,9 +40,6 @@ if (($data = data_submitted()) && confirm_sesskey()) { } // print the grades on screen for feedbacks - $course = get_record('course', 'id', $id); - $action = 'exporttxt'; - print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); $export = new grade_export($id, $data->itemids); $export->display_grades($feedback); @@ -49,9 +48,7 @@ if (($data = data_submitted()) && confirm_sesskey()) { redirect('export.php?id='.$id.'&itemids='.$itemidsurl); exit; } -$course = get_record('course', 'id', $id); -$action = 'exportods'; -print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); + print_gradeitem_selections($id); print_footer(); ?> \ No newline at end of file diff --git a/grade/export/txt/export.php b/grade/export/txt/export.php index 635b19f826..48e01f5d52 100755 --- a/grade/export/txt/export.php +++ b/grade/export/txt/export.php @@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/grade/export/lib.php'); require_once('grade_export_txt.php'); $id = required_param('id', PARAM_INT); // course id -$itemids = explode(",", required_param('itemids', PARAM_NOTAGS)); +$itemids = explode(",", required_param('itemids', PARAM_RAW)); $feedback = optional_param('feedback', '', PARAM_ALPHA); // print all the exported data here diff --git a/grade/export/txt/grade_export_txt_form.php b/grade/export/txt/grade_export_txt_form.php index d27770108b..df752c5dda 100755 --- a/grade/export/txt/grade_export_txt_form.php +++ b/grade/export/txt/grade_export_txt_form.php @@ -9,7 +9,7 @@ class grade_export_txt_form extends moodleform { $mform->addElement('header', 'general', 'Gradeitems to be included'); // TODO: localize $id = $this->_customdata['id']; // course id $mform->addElement('hidden', 'id', $id); - if ($grade_items = grade_grades::fetch_all(array('courseid'=>$id))) { + if ($grade_items = grade_item::fetch_all(array('courseid'=>$id))) { foreach ($grade_items as $grade_item) { $element = new HTML_QuickForm_advcheckbox('itemids[]', null, $grade_item->itemname, array('selected'=>'selected'), array(0, $grade_item->id)); $element->setChecked(1); diff --git a/grade/export/txt/index.php b/grade/export/txt/index.php index 6f93d3abb5..b0bd0fafa2 100755 --- a/grade/export/txt/index.php +++ b/grade/export/txt/index.php @@ -27,19 +27,19 @@ require_once('grade_export_txt.php'); $id = required_param('id', PARAM_INT); // course id $feedback = optional_param('feedback', '', PARAM_ALPHA); +$course = get_record('course', 'id', $id); +$action = 'exporttxt'; // for printing header +print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); // process post information if (($data = data_submitted()) && confirm_sesskey()) { + // $itemids consists of ints and ",", will be cleaned in the main export class if (!is_array($data->itemids)) { $itemidsurl = $data->itemids; } else { $itemidsurl = implode(",",$data->itemids); } - - $course = get_record('course', 'id', $id); - $action = 'exporttxt'; - print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); $export = new grade_export($id, $data->itemids); $export->display_grades($feedback); @@ -49,42 +49,10 @@ if (($data = data_submitted()) && confirm_sesskey()) { exit; } - -$course = get_record('course', 'id', $id); -$action = 'exporttxt'; -print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); +// print the form to choose what grade_items to export include_once('grade_export_txt_form.php'); $mform = new grade_export_txt_form(qualified_me(), array('id'=>$id)); $mform->display(); -/* -// print_gradeitem_selections($id); -// print all items for selections -// make this a standard function in lib maybe -if ($grade_items = grade_grades::fetch_all(array('courseid'=>$id))) { - echo '
'; - echo '
'; - foreach ($grade_items as $grade_item) { - - echo '
'; - - if ($grade_item->itemtype == 'category') { - // grade categories should be displayed bold - echo ''.$grade_item->itemname.''; - } else { - echo $grade_item->itemname; - } - } - echo '
'; - echo 'tab'; - echo 'comma'; - echo ''; - echo ''; - echo '
'; - echo ''; - echo '
'; - echo '
'; -} -*/ print_footer(); ?> \ No newline at end of file diff --git a/grade/export/xls/export.php b/grade/export/xls/export.php index d734cb2832..a848cb5403 100755 --- a/grade/export/xls/export.php +++ b/grade/export/xls/export.php @@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/grade/export/lib.php'); require_once('grade_export_xls.php'); $id = required_param('id', PARAM_INT); // course id -$itemids = explode(",", required_param('itemids', PARAM_NOTAGS)); +$itemids = explode(",", required_param('itemids', PARAM_RAW)); $feedback = optional_param('feedback', '', PARAM_ALPHA); // print all the exported data here diff --git a/grade/export/xls/index.php b/grade/export/xls/index.php index 30552c6c4d..cc152c8fd8 100755 --- a/grade/export/xls/index.php +++ b/grade/export/xls/index.php @@ -26,8 +26,12 @@ require_once($CFG->dirroot.'/grade/export/lib.php'); require_once('grade_export_xls.php'); $id = required_param('id', PARAM_INT); // course id +$course = get_record('course', 'id', $id); $feedback = optional_param('feedback', '', PARAM_ALPHA); +$action = 'exporttxt'; +print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); + // process post information if (($data = data_submitted()) && confirm_sesskey()) { @@ -38,9 +42,6 @@ if (($data = data_submitted()) && confirm_sesskey()) { } // print the grades on screen for feedbacks - $course = get_record('course', 'id', $id); - $action = 'exporttxt'; - print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); $export = new grade_export($id, $data->itemids); $export->display_grades($feedback); @@ -49,9 +50,7 @@ if (($data = data_submitted()) && confirm_sesskey()) { redirect('export.php?id='.$id.'&itemids='.$itemidsurl); exit; } -$course = get_record('course', 'id', $id); -$action = 'exportxls'; -print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); + print_gradeitem_selections($id); print_footer(); ?> \ No newline at end of file diff --git a/grade/export/xml/export.php b/grade/export/xml/export.php index d9b79f1884..21876523af 100755 --- a/grade/export/xml/export.php +++ b/grade/export/xml/export.php @@ -5,7 +5,7 @@ require_once($CFG->dirroot.'/grade/export/lib.php'); require_once('grade_export_xml.php'); $id = required_param('id', PARAM_INT); // course id -$itemids = explode(",", required_param('itemids', PARAM_NOTAGS)); +$itemids = explode(",", required_param('itemids', PARAM_RAW)); $feedback = optional_param('feedback', '', PARAM_ALPHA); // print all the exported data here diff --git a/grade/export/xml/index.php b/grade/export/xml/index.php index 280bf9a7a3..0045e0a046 100755 --- a/grade/export/xml/index.php +++ b/grade/export/xml/index.php @@ -25,8 +25,12 @@ require_once("../../../config.php"); require_once($CFG->dirroot.'/grade/export/lib.php'); require_once('grade_export_xml.php'); -$id = required_param('id', PARAM_INT); // course id +$id = required_param('id', PARAM_INT); // course id +$course = get_record('course', 'id', $id); $feedback = optional_param('feedback', '', PARAM_ALPHA); + +$action = 'exportxml'; +print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); // process post information if (($data = data_submitted()) && confirm_sesskey()) { @@ -38,10 +42,7 @@ if (($data = data_submitted()) && confirm_sesskey()) { } // print the grades on screen for feedbacks - $course = get_record('course', 'id', $id); - $action = 'exportxml'; - print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); - + $export = new grade_export($id, $data->itemids); $export->display_grades($feedback); @@ -49,9 +50,7 @@ if (($data = data_submitted()) && confirm_sesskey()) { redirect('export.php?id='.$id.'&itemids='.$itemidsurl); exit; } -$course = get_record('course', 'id', $id); -$action = 'exportxml'; -print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action)); + print_gradeitem_selections($id); print_footer(); ?> \ No newline at end of file