diff --git a/grade/export/grade_export_form.php b/grade/export/grade_export_form.php
index 9326fea5221..211019d76c6 100755
--- a/grade/export/grade_export_form.php
+++ b/grade/export/grade_export_form.php
@@ -16,7 +16,7 @@ class grade_export_form extends moodleform {
$mform->addElement($element);
}
}
- $this->add_action_buttons(false, get_string('submit'));
+ $this->add_action_buttons(false, get_string('submit'));
}
}
?>
\ No newline at end of file
diff --git a/grade/export/lib.php b/grade/export/lib.php
index 94e2e869c32..df39b919506 100755
--- a/grade/export/lib.php
+++ b/grade/export/lib.php
@@ -42,7 +42,7 @@ function print_gradeitem_selections($id, $params = NULL) {
* Base export class
*/
class grade_export {
-
+
var $format = ''; // export format
var $id; // course id
var $itemids; // comma separated grade_item ids;
@@ -51,34 +51,34 @@ class grade_export {
var $comments = array(); // Collect all comments for each grade
var $totals = array(); // Collect all totals in this array
var $columns = array(); // Accumulate column names in this array.
- var $columnhtml = array(); // Accumulate column html in this array.
+ var $columnhtml = array(); // Accumulate column html in this array.
var $columnidnumbers = array(); // Collect all gradeitem id numbers
var $students = array();
var $course; // course
-
+
// common strings
- var $strgrades;
- var $strgrade;
-
+ var $strgrades;
+ var $strgrade;
+
/**
* Constructor should set up all the private variables ready to be pulled
* @input int id - course id
* @input string itemids - comma separated value of itemids to process for this export
*/
function grade_export($id, $itemids = '') {
-
+
$this->strgrades = get_string("grades");
$this->strgrade = get_string("grade");
$this->itemids = $itemids;
-
- $strmax = get_string("maximumshort");
-
+
+ $strmax = get_string("maximumshort");
+
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect");
}
$context = get_context_instance(CONTEXT_COURSE, $id);
require_capability('moodle/course:viewcoursegrades', $context);
-
+
$this->id = $id;
$this->course = $course;
@@ -88,7 +88,7 @@ class grade_export {
/// Check to see if groups are being used in this course
if ($groupmode = groupmode($course)) { // Groups are being used
-
+
if (isset($_GET['group'])) {
$changegroup = $_GET['group']; /// 0 or higher
} else {
@@ -96,7 +96,7 @@ class grade_export {
}
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
-
+
} else {
$currentgroup = false;
}
@@ -119,44 +119,44 @@ class grade_export {
// if grade_item ids are specified
if ($itemids) {
foreach ($itemids as $iid) {
-
+
if ($iid) {
$params->id = clean_param($iid, PARAM_INT);
$gradeitems[] = new grade_item($params);
- }
- }
+ }
+ }
} else {
// else we get all items for this course
$gradeitems = grade_grades::fetch_all(array('courseid'=>$this->id));
}
-
+
if ($gradeitems) {
foreach ($gradeitems as $gradeitem) {
-
+
// load as an array of grade_final objects
- if ($itemgrades = $gradeitem -> get_final()) {
-
+ if ($itemgrades = $gradeitem -> get_final()) {
+
$this->columns[$gradeitem->id] = "$gradeitem->itemmodule: ".format_string($gradeitem->itemname,true)." - $gradeitem->grademax";
-
- $this->columnidnumbers[$gradeitem->id] = $gradeitem->idnumber; // this might be needed for some export plugins
-
+
+ $this->columnidnumbers[$gradeitem->id] = $gradeitem->idnumber; // this might be needed for some export plugins
+
if (!empty($gradeitem->grademax)) {
$maxgrade = "$strmax: $gradeitem->grademax";
} else {
$maxgrade = "";
- }
-
- if (!empty($this->students)) {
+ }
+
+ if (!empty($this->students)) {
foreach ($this->students as $student) {
unset($studentgrade);
// add support for comment here MDL-9634
-
+
if (!empty($itemgrades[$student->id])) {
$studentgrade = $itemgrades[$student->id];
}
-
+
if (!empty($studentgrade->finalgrade)) {
- $this->grades[$student->id][$gradeitem->id] = $currentstudentgrade = $studentgrade->finalgrade;
+ $this->grades[$student->id][$gradeitem->id] = $currentstudentgrade = $studentgrade->finalgrade;
} else {
$this->grades[$student->id][$gradeitem->id] = $currentstudentgrade = "";
$this->gradeshtml[$student->id][$gradeitem->id] = "";
@@ -166,8 +166,8 @@ class grade_export {
} else {
$this->totals[$student->id] = (float)($this->totals[$student->id]) + 0;
}
-
- if (!empty($comment)) {
+
+ if (!empty($comment)) {
// load comments here
if ($studentgrade) {
$studentgrade->load_text();
@@ -176,20 +176,20 @@ class grade_export {
$this->comments[$student->id][$gradeitem->id] = $comment;
}
} else {
- $this->comments[$student->id][$gradeitem->id] = '';
+ $this->comments[$student->id][$gradeitem->id] = '';
}
}
}
}
}
- }
+ }
}
-
+
/**
* To be implemented by child classes
*/
function print_grades() { }
-
+
/**
* Displays all the grades on screen as a feedback mechanism
*/
@@ -205,34 +205,34 @@ class grade_export {
foreach ($this->columns as $column) {
$column = strip_tags($column);
echo "
$column
";
-
- /// add a column_feedback column
+
+ /// add a column_feedback column
if ($feedback) {
echo "
{$column}_feedback
";
- }
+ }
}
echo '
'.get_string("total")."
";
echo '';
/// Print all the lines of data.
-
-
- foreach ($this->grades as $studentid => $studentgrades) {
-
+
+
+ foreach ($this->grades as $studentid => $studentgrades) {
+
echo '
';
}
echo '';
-
+
/// feeding gradeitems into the grade_import_mapping_form
include_once($CFG->libdir.'/grade/grade_item.php');
$gradeitems = array();
@@ -376,11 +376,11 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) {
foreach ($grade_items as $grade_item) {
// skip course type and category type
if ($grade_item->itemtype == 'course' || $grade_item->itemtype == 'category') {
- continue;
- }
-
+ continue;
+ }
+
// this was idnumber
- $gradeitems[$grade_item->id] = $grade_item->itemname;
+ $gradeitems[$grade_item->id] = $grade_item->itemname;
}
}
}
diff --git a/grade/import/grade_import_form.php b/grade/import/grade_import_form.php
index 7f530473bcc..e0018e1ad6d 100755
--- a/grade/import/grade_import_form.php
+++ b/grade/import/grade_import_form.php
@@ -17,7 +17,7 @@ class grade_import_form extends moodleform {
$encodings = $textlib->get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
- $options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
+ $options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
$mform->addElement('select', 'previewrows', 'Preview rows', $options); // TODO: localize
$mform->setType('previewrows', PARAM_INT);
$this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
@@ -34,7 +34,7 @@ class grade_import_form extends moodleform {
}
class grade_import_mapping_form extends moodleform {
-
+
function definition () {
global $CFG;
$mform =& $this->_form;
@@ -54,35 +54,35 @@ class grade_import_mapping_form extends moodleform {
}
}
$mform->addElement('select', 'mapfrom', get_string('mapfrom', 'grades'), $mapfromoptions);
- //choose_from_menu($mapfromoptions, 'mapfrom');
-
+ //choose_from_menu($mapfromoptions, 'mapfrom');
+
$maptooptions = array('userid'=>'userid', 'username'=>'username', 'useridnumber'=>'useridnumber', 'useremail'=>'useremail', '0'=>'ignore');
//choose_from_menu($maptooptions, 'mapto');
$mform->addElement('select', 'mapto', get_string('mapto', 'grades'), $maptooptions);
-
+
$mform->addElement('header', 'general', get_string('mappings', 'grades'));
-
+
// add a comment option
if ($gradeitems = $this->_customdata['gradeitems']) {
- $comments = array();
+ $comments = array();
foreach ($gradeitems as $itemid => $itemname) {
- $comments['feedback_'.$itemid] = 'comments for '.$itemname;
- }
+ $comments['feedback_'.$itemid] = 'comments for '.$itemname;
+ }
}
include_once($CFG->libdir.'/gradelib.php');
- if ($header) {
+ if ($header) {
$i = 0; // index
foreach ($header as $h) {
$h = trim($h);
- // this is what each header maps to
- $mform->addElement('selectgroups',
- 'mapping_'.$i, s($h),
- array('others'=>array('0'=>'ignore', 'new'=>'new gradeitem'),
- 'gradeitems'=>$gradeitems,
+ // this is what each header maps to
+ $mform->addElement('selectgroups',
+ 'mapping_'.$i, s($h),
+ array('others'=>array('0'=>'ignore', 'new'=>'new gradeitem'),
+ 'gradeitems'=>$gradeitems,
'comments'=>$comments));
$i++;
}
@@ -105,7 +105,7 @@ class grade_import_mapping_form extends moodleform {
//echo '';
$mform->addElement('hidden', 'filename', $newfilename);
$mform->setType('filename', PARAM_FILE);
- $this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
+ $this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
}
}
diff --git a/grade/import/lib.php b/grade/import/lib.php
index 5fb1a0c4a81..d9b31d69999 100755
--- a/grade/import/lib.php
+++ b/grade/import/lib.php
@@ -1,53 +1,53 @@
libdir.'/gradelib.php');
include_once($CFG->libdir.'/grade/grade_item.php');
$commitstart = time(); // start time in case we need to roll back
$newitemids = array(); // array to hold new grade_item ids from grade_import_newitem table, mapping array
-
+
/// first select distinct new grade_items with this batch
-
- if ($newitems = get_records_sql("SELECT *
+
+ if ($newitems = get_records_sql("SELECT *
FROM {$CFG->prefix}grade_import_newitem
WHERE import_code = $importcode")) {
-
- // instances of the new grade_items created, cached
+
+ // instances of the new grade_items created, cached
// in case grade_update fails, so that we can remove them
$instances = array();
foreach ($newitems as $newitem) {
// get all grades with this item
-
- if ($grades = get_records('grade_import_values', 'newgradeitem', $newitem->id)) {
+
+ if ($grades = get_records('grade_import_values', 'newgradeitem', $newitem->id)) {
// make the grardes array for update_grade
-
+
// find the max instance number of 'manual' grade item
// and increment that number by 1 by hand
// I can not find other ways to make 'manual' type work,
// unless we have a 'new' flag for grade_update to let it
// know that this is a new grade_item, and let grade_item
// handle the instance id in the case of a 'manual' import?
- if ($lastimport = get_record_sql("SELECT *
+ if ($lastimport = get_record_sql("SELECT *
FROM {$CFG->prefix}grade_items
WHERE courseid = $courseid
AND itemtype = 'manual'
ORDER BY iteminstance DESC", true)) {
$instance = $lastimport->iteminstance + 1;
} else {
- $instance = 1;
+ $instance = 1;
}
-
+
$instances[] = $instance;
// if fails, deletes all the created grade_items and grades
@@ -57,7 +57,7 @@ function grade_import_commit($courseid, $importcode) {
// insert each individual grade to this new grade item
$failed = 0;
- foreach ($grades as $grade) {
+ foreach ($grades as $grade) {
if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, NULL, NULL, $grade->feedback)) {
$failed = 1;
break;
@@ -65,7 +65,7 @@ function grade_import_commit($courseid, $importcode) {
}
if ($failed) {
foreach ($instances as $instance) {
- $gradeitem = new grade_item(array('courseid'=>$courseid, 'itemtype'=>'manual', 'iteminstance'=>$instance));
+ $gradeitem = new grade_item(array('courseid'=>$courseid, 'itemtype'=>'manual', 'iteminstance'=>$instance));
// this method does not seem to delete all the raw grades and the item itself
// which I think should be deleted in this case, can I use sql directly here?
$gradeitem->delete();
@@ -79,15 +79,15 @@ function grade_import_commit($courseid, $importcode) {
/// then find all existing items
- if ($gradeitems = get_records_sql("SELECT DISTINCT (itemid)
+ if ($gradeitems = get_records_sql("SELECT DISTINCT (itemid)
FROM {$CFG->prefix}grade_import_values
WHERE import_code = $importcode
AND itemid > 0")) {
$modifieditems = array();
-
+
foreach ($gradeitems as $itemid=>$iteminfo) {
-
+
if (!$gradeitem = new grade_item(array('id'=>$itemid))) {
// not supposed to happen, but just in case
import_cleanup($importcode);
@@ -107,7 +107,7 @@ function grade_import_commit($courseid, $importcode) {
$modifieditems[] = $itemid;
}
-
+
if (!empty($failed)) {
import_cleanup($importcode);
return false;
diff --git a/grade/import/xml/index.php b/grade/import/xml/index.php
index 697839661cf..8f7c9e86494 100755
--- a/grade/import/xml/index.php
+++ b/grade/import/xml/index.php
@@ -47,7 +47,7 @@ if ( $formdata = $mform->get_data()) {
// trim utf-8 bom
$textlib = new textlib();
// converts to propert unicode
- $text = $textlib->convert($text, $formdata->encoding);
+ $text = $textlib->convert($text, $formdata->encoding);
$text = $textlib->trim_utf8_bom($text);
// Fix mac/dos newlines
$text = preg_replace('!\r\n?!',"\n",$text);
@@ -55,19 +55,19 @@ if ( $formdata = $mform->get_data()) {
// text is the text, we should xmlize it
include_once($CFG->dirroot.'/lib/xmlize.php');
$content = xmlize($text);
-
+
if ($results = $content['results']['#']['result']) {
-
+
// import batch identifier timestamp
$importcode = time();
$status = true;
-
+
$numlines = 0;
-
+
// print some previews
print_heading(get_string('importpreview', 'grades'));
-
- echo '
';
+
+ echo '
';
foreach ($results as $i => $result) {
if ($numlines < $formdata->previewrows && isset($results[$i+1])) {
echo '
';
@@ -88,14 +88,14 @@ if ( $formdata = $mform->get_data()) {
$status = false;
break;
}
-
+
// grade item locked, abort
if ($gradeitem->locked) {
$status = false;
notify(get_string('gradeitemlocked', 'grades'));
- break 3;
- }
-
+ break 3;
+ }
+
// check if grade_grades is locked and if so, abort
if ($grade_grades = new grade_grades(array('itemid'=>$gradeitem->id, 'userid'=>$result['#']['student'][0]['#']))) {
if ($grade_grades->locked) {
@@ -114,11 +114,11 @@ if ( $formdata = $mform->get_data()) {
$newgrades[] = $newgrade;
}
}
-
+
// loop through info collected so far
if ($status && !empty($newgrades)) {
foreach ($newgrades as $newgrade) {
-
+
// check if user exist
if (!$user = get_record('user', 'id', $newgrade->userid)) {
// no user found, abort
@@ -127,8 +127,8 @@ if ( $formdata = $mform->get_data()) {
notify(get_string('baduserid', 'grades'));
notify(get_string('importfailed', 'grades'));
break;
- }
-
+ }
+
// check grade value is a numeric grade
if (!is_numeric($newgrade->rawgrade)) {
$status = false;
@@ -153,11 +153,11 @@ if ( $formdata = $mform->get_data()) {
if ($status) {
/// comit the code if we are up this far
grade_import_commit($id, $importcode);
- }
+ }
} else {
// no results section found in xml,
// assuming bad format, abort import
- notify('badxmlformat', 'grade');
+ notify('badxmlformat', 'grade');
}
} else {
// display the standard upload file form
diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php
index b01fc8b909e..be253c55fa6 100644
--- a/lib/grade/grade_category.php
+++ b/lib/grade/grade_category.php
@@ -482,7 +482,7 @@ class grade_category extends grade_object {
$weightsum = 0;
$sum = 0;
foreach($items as $key=>$value) {
- $grade_value = isset($grade_values[$key]) ? $grade_values[$key] : 0;
+ $grade_value = isset($grade_values[$key]) ? $grade_values[$key] : 0;
if ($items[$key]->aggregationcoef <= 0) {
continue;
}
@@ -513,11 +513,11 @@ class grade_category extends grade_object {
}
break;
- case GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL: // special average
+ case GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL: // special average
$num = 0;
$sum = 0;
foreach($items as $key=>$value) {
- $grade_value = isset($grade_values[$key]) ? $grade_values[$key] : 0;
+ $grade_value = isset($grade_values[$key]) ? $grade_values[$key] : 0;
if ($items[$key]->aggregationcoef == 0) {
$num += 1;
$sum += $grade_value;
@@ -532,7 +532,7 @@ class grade_category extends grade_object {
}
break;
- case GRADE_AGGREGATE_EXTRACREDIT_MEAN_GRADED: // special average
+ case GRADE_AGGREGATE_EXTRACREDIT_MEAN_GRADED: // special average
$num = 0;
$sum = 0;
foreach($grade_values as $key=>$grade_value) {
@@ -617,7 +617,7 @@ class grade_category extends grade_object {
or $this->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN_GRADED
or $this->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL
or $this->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN_GRADED);
-
+
}
/**
diff --git a/lib/grade/grade_grades.php b/lib/grade/grade_grades.php
index e370d5632ae..68a5238ca6d 100644
--- a/lib/grade/grade_grades.php
+++ b/lib/grade/grade_grades.php
@@ -427,7 +427,7 @@ class grade_grades extends grade_object {
*/
function standardise_score($rawgrade, $source_min, $source_max, $target_min, $target_max) {
if (is_null($rawgrade)) {
- return null;
+ return null;
}
$factor = ($rawgrade - $source_min) / ($source_max - $source_min);