MDL-11667, adding 2 global variables to set default export decimal point and display format. During export there are 2 new settings for decimal points and display format, default to site setting. Removed letter option because it is a format that you can choose now.

This commit is contained in:
toyomoyo 2007-10-10 06:43:23 +00:00
parent 8ad36f4cc3
commit 864d1f8c2c
14 changed files with 100 additions and 51 deletions

View File

@ -7,7 +7,7 @@
require_once $CFG->libdir.'/grade/constants.php';
$temp = new admin_settingpage('gradessettings', get_string('gradessettings', 'grades'));
$temp->add(new admin_setting_special_gradeexport());
// enable outcomes checkbox
$temp->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0, PARAM_INT));
// enable publishing in exports/imports
@ -33,6 +33,22 @@ $temp->add(new admin_setting_configselect('grade_decimalpoints', get_string('dec
'4' => '4',
'5' => '5')));
$temp->add(new admin_setting_configselect('grade_export_displaytype', get_string('gradeexportdisplaytype', 'grades'),
get_string('configgradeexportdisplaytype', 'grades'), GRADE_DISPLAY_TYPE_REAL,
array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'))));
$temp->add(new admin_setting_configselect('grade_export_decimalpoints', get_string('gradeexportdecimalpoints', 'grades'),
get_string('configexportdecimalpoints', 'grades'), 2,
array( '0' => '0',
'1' => '1',
'2' => '2',
'3' => '3',
'4' => '4',
'5' => '5')));
$temp->add(new admin_setting_special_gradeexport());
$ADMIN->add('grades', $temp);
/// Scales and outcomes

View File

@ -38,11 +38,6 @@ class grade_export_form extends moodleform {
$mform->addElement('header', 'options', get_string('options', 'grades'));
$mform->addElement('advcheckbox', 'export_letters', get_string('exportletters', 'grades'));
$mform->setDefault('export_letters', 0);
$mform->setHelpButton('export_letters', array(false, get_string('exportletters', 'grades'),
false, true, false, get_string("exportlettershelp", 'grades')));
$mform->addElement('advcheckbox', 'export_feedback', get_string('exportfeedback', 'grades'));
$mform->setDefault('export_feedback', 0);
@ -52,7 +47,35 @@ class grade_export_form extends moodleform {
if (!empty($features['updatedgrades'])) {
$mform->addElement('advcheckbox', 'updatedgradesonly', get_string('updatedgradesonly', 'grades'));
}
/// selections for decimal points and format, MDL-11667, defaults to site settings, if set
//$default_gradedisplaytype = $CFG->grade_export_displaytype;
$options = array(GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades'));
/*
foreach ($options as $key=>$option) {
if ($key == $default_gradedisplaytype) {
$options[GRADE_DISPLAY_TYPE_DEFAULT] = get_string('defaultprev', 'grades', $option);
break;
}
}
*/
$mform->addElement('select', 'display', get_string('gradeexportdisplaytype', 'grades'), $options);
$mform->setDefault('display', $CFG->grade_export_displaytype);
//$default_gradedecimals = $CFG->grade_export_decimalpoints;
$options = array(0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
$mform->addElement('select', 'decimals', get_string('gradeexportdecimalpoints', 'grades'), $options);
$mform->setDefault('decimals', $CFG->grade_export_decimalpoints);
$mform->disabledIf('decimals', 'display', 'eq', GRADE_DISPLAY_TYPE_LETTER);
/*
if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
$mform->disabledIf('decimals', 'display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);
}
*/
if (!empty($features['includeseparator'])) {
$radio = array();
$radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');

View File

@ -45,6 +45,8 @@ class grade_export {
var $userkey; // export using private user key
var $updatedgradesonly; // only export updated grades
var $displaytype; // display type (e.g. real, percentages, letter) for exports
var $decimalpoints; // number of decimal points for exports
/**
* Constructor should set up all the private variables ready to be pulled
* @param object $course
@ -54,7 +56,7 @@ class grade_export {
* @param boolean $export_letters
* @note Exporting as letters will lead to data loss if that exported set it re-imported.
*/
function grade_export($course, $groupid=0, $itemlist='', $export_feedback=false, $export_letters=false, $updatedgradesonly = false) {
function grade_export($course, $groupid=0, $itemlist='', $export_feedback=false, $updatedgradesonly = false, $displaytype = GRADE_DISPLAY_TYPE_REAL, $decimalpoints = 2) {
$this->course = $course;
$this->groupid = $groupid;
$this->grade_items = grade_item::fetch_all(array('courseid'=>$this->course->id));
@ -79,6 +81,9 @@ class grade_export {
$this->userkey = '';
$this->previewrows = false;
$this->updatedgradesonly = $updatedgradesonly;
$this->displaytype = $displaytype;
$this->decimalpoints = $decimalpoints;
}
/**
@ -148,14 +153,7 @@ class grade_export {
* @return string
*/
function format_grade($grade) {
$displaytype = null;
if ($this->export_letters) {
$displaytype = GRADE_DISPLAY_TYPE_LETTER;
} else {
$displaytype = GRADE_DISPLAY_TYPE_REAL;
}
return grade_format_gradevalue($grade->finalgrade, $this->grade_items[$grade->itemid], false, $displaytype, null);
return grade_format_gradevalue($grade->finalgrade, $this->grade_items[$grade->itemid], false, $this->displaytype, $this->decimalpoints);
}
/**
@ -266,7 +264,9 @@ echo "status is $status";
'itemids' =>implode(',', $itemids),
'export_letters' =>$this->export_letters,
'export_feedback' =>$this->export_feedback,
'updatedgradesonly' =>$this->updatedgradesonly);
'updatedgradesonly' =>$this->updatedgradesonly,
'displaytype' =>$this->displaytype,
'decimalpoints' =>$this->decimalpoints);
return $params;
}

View File

@ -27,11 +27,13 @@ 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
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
$export_letters = optional_param('export_letters', 0, PARAM_BOOL);
$id = required_param('id', PARAM_INT); // course id
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
$displaytype = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
$decimalpoints = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
if (!$course = get_record('course', 'id', $id)) {
print_error('nocourseid');
@ -45,7 +47,7 @@ require_capability('gradeexport/ods:view', $context);
// print all the exported data here
$export = new grade_export_ods($course, $groupid, $itemids, $export_feedback, $export_letters);
$export = new grade_export_ods($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints);
$export->print_grades();
?>

View File

@ -55,7 +55,7 @@ $mform = new grade_export_form(null, array('publishing' => true));
// process post information
if ($data = $mform->get_data()) {
$export = new grade_export_ods($course, groups_get_course_group($course));
$export = new grade_export_ods($course, groups_get_course_group($course), '', false, $data->updatedgradesonly, $data->display, $data->decimals);
// print the grades on screen for feedbacks
$export->process_form($data);

View File

@ -27,12 +27,14 @@ require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/export/lib.php';
require_once 'grade_export_txt.php';
$id = required_param('id', PARAM_INT); // course id
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
$export_letters = optional_param('export_letters', 0, PARAM_BOOL);
$separator = optional_param('separator', 'comma', PARAM_ALPHA);
$id = required_param('id', PARAM_INT); // course id
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
$separator = optional_param('separator', 'comma', PARAM_ALPHA);
$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
$displaytype = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
$decimalpoints = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
if (!$course = get_record('course', 'id', $id)) {
print_error('nocourseid');
@ -46,7 +48,7 @@ require_capability('gradeexport/txt:view', $context);
// print all the exported data here
$export = new grade_export_txt($course, $groupid, $itemids, $export_feedback, $export_letters, $separator);
$export = new grade_export_txt($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints, $separator);
$export->print_grades();
?>

View File

@ -30,8 +30,8 @@ class grade_export_txt extends grade_export {
var $separator; // default separator
function grade_export_txt($course, $groupid=0, $itemlist='', $export_feedback=false, $export_letters=false, $separator='comma') {
$this->grade_export($course, $groupid, $itemlist, $export_feedback, $export_letters);
function grade_export_txt($course, $groupid=0, $itemlist='', $export_feedback=false, $updatedgradesonly = false, $displaytype = GRADE_DISPLAY_TYPE_REAL, $decimalpoints = 2, $separator='comma') {
$this->grade_export($course, $groupid, $itemlist, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints);
$this->separator = $separator;
}

View File

@ -55,7 +55,7 @@ $mform = new grade_export_form(null, array('includeseparator'=>true, 'publishing
// process post information
if ($data = $mform->get_data()) {
$export = new grade_export_txt($course, groups_get_course_group($course));
$export = new grade_export_txt($course, groups_get_course_group($course), '', false, $data->updatedgradesonly, $data->display, $data->decimals);
// print the grades on screen for feedback

View File

@ -27,11 +27,13 @@ require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/export/lib.php';
require_once 'grade_export_xls.php';
$id = required_param('id', PARAM_INT); // course id
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
$export_letters = optional_param('export_letters', 0, PARAM_BOOL);
$id = required_param('id', PARAM_INT); // course id
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
$displaytype = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
$decimalpoints = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
if (!$course = get_record('course', 'id', $id)) {
print_error('nocourseid');
@ -45,7 +47,7 @@ require_capability('gradeexport/xls:view', $context);
// print all the exported data here
$export = new grade_export_xls($course, $groupid, $itemids, $export_feedback, $export_letters);
$export = new grade_export_xls($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints);
$export->print_grades();
?>

View File

@ -55,7 +55,7 @@ $mform = new grade_export_form(null, array('publishing' => true));
// process post information
if ($data = $mform->get_data()) {
$export = new grade_export_xls($course, groups_get_course_group($course));
$export = new grade_export_xls($course, groups_get_course_group($course), '', false, $data->updatedgradesonly, $data->display, $data->decimals);
// print the grades on screen for feedbacks
$export->process_form($data);

View File

@ -27,12 +27,13 @@ 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
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
$export_letters = optional_param('export_letters', 0, PARAM_BOOL);
$id = required_param('id', PARAM_INT); // course id
$groupid = optional_param('groupid', 0, PARAM_INT);
$itemids = required_param('itemids', PARAM_RAW);
$export_feedback = optional_param('export_feedback', 0, PARAM_BOOL);
$updatedgradesonly = optional_param('updatedgradesonly', false, PARAM_BOOL);
$displaytype = optional_param('displaytype', $CFG->grade_export_displaytype, PARAM_INT);
$decimalpoints = optional_param('decimalpoints', $CFG->grade_export_decimalpoints, PARAM_INT);
if (!$course = get_record('course', 'id', $id)) {
print_error('nocourseid');
@ -46,7 +47,7 @@ require_capability('gradeexport/xml:view', $context);
// print all the exported data here
$export = new grade_export_xml($course, $groupid, $itemids, $export_feedback, $export_letters, $updatedgradesonly);
$export = new grade_export_xml($course, $groupid, $itemids, $export_feedback, $updatedgradesonly, $displaytype, $decimalpoints);
$export->print_grades();
?>

View File

@ -74,7 +74,7 @@ class grade_export_xml extends grade_export {
foreach ($userdata->grades as $itemid => $grade) {
$grade_item = $this->grade_items[$itemid];
$grade->grade_item =& $grade_item;
$gradestr = $grade->finalgrade; // no formating for now
$gradestr = $this->format_grade($grade); // no formating for now
// MDL-11669, skip exported grades or bad grades (if setting says so)
if ($export_tracking) {

View File

@ -55,7 +55,8 @@ $mform = new grade_export_form(null, array('idnumberrequired'=>true, 'publishing
// process post information
if ($data = $mform->get_data()) {
$export = new grade_export_xml($course, groups_get_course_group($course), '', false, false, $data->updatedgradesonly);
$export = new grade_export_xml($course, groups_get_course_group($course), '', false, $data->updatedgradesonly, $data->display, $data->decimals);
// print the grades on screen for feedbacks
$export->process_form($data);
$export->print_continue();

View File

@ -69,6 +69,8 @@ $string['configenableajax'] = 'Adds a layer of AJAX functionality to the grader
$string['configenableoutcomes'] = 'Support for Outcomes (also known as Competencies, Goals, Standards or Criteria) means that we can grade things using one or more scales that are tied to outcome statements. Enabling outcomes makes such special grading possible throughout the site.';
$string['configgradeboundary'] = 'A percentage boundary over which grades will be assigned a grade letter (if the Letter grade display type is used). ';
$string['configgradedisplaytype'] = 'Grades can be shown as real grades, as percentages (in reference to the minimum and maximum grades) or as letters (A, B, C etc..)';
$string['configgradeexportdisplaytype'] = 'Grades can be shown as real grades, as percentages (in reference to the minimum and maximum grades) or as letters (A, B, C etc..) during export. This can be overriden during export.';
$string['configexportdecimalpoints'] = 'The number of decimal points to display for export. This can be overriden during export.';
$string['configgradeletter'] = 'A letter or other symbol used to represent a range of grades.';
$string['configgradeletterdefault'] = 'A letter or other symbol used to represent a range of grades. Leave this field empty to use the site default (currently $a).';
$string['configgradepublishing'] = 'Enable publishing in exports and imports: Exported grades can be accessed by accessing a URL, without having to log on to a Moodle site. Grades can be imported by accessing such a URL (which means that a moodle site can import grades published by another site). By default only administrators may use this feature, please educate users before adding required capabilities to other roles (dangers of bookmark sharing and download accelerators, IP restrictions, etc.).';
@ -136,8 +138,6 @@ $string['excludedhelp'] = 'If -excluded- is switched on, this grade will be excl
$string['expand'] = 'Expand Category';
$string['export'] = 'Export';
$string['exportfeedback'] = 'Include feedback in export';
$string['exportletters'] = 'Export letter grades as letters';
$string['exportlettershelp'] = 'For grade items that use grade letters instead of values, the letters will be exported instead of the actual values.';
$string['exportplugins'] = 'Export plugins';
$string['extracredit'] = 'Extra Credit';
$string['extracreditwarning'] = 'Note: Setting all items for a category to extra credit will effectively remove them from the grade calculation. Since there will be no point total';
@ -169,6 +169,8 @@ $string['gradedisplay'] = 'Grade display';
$string['gradedisplaytype'] = 'Grade display type';
$string['gradeexceptions'] = 'Grade Exceptions';
$string['gradeexceptionshelp'] = 'Grade Exceptions Help';
$string['gradeexportdisplaytype'] = 'Grade export display type';
$string['gradeexportdecimalpoints'] = 'Grade export decimal points';
$string['gradehelp'] = 'Grade Help';
$string['gradeitem'] = 'Grade item';
$string['gradeitemislocked'] = 'This activity is locked in the gradebook. Changes that are made to grades in this activity will not be copied to the gradebook until it is unlocked.';