Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove bad data added to export #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion btec.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
if ($showgroups) {
$groups = report_componentgrades_get_user_groups($course->id);
}
report_componentgrades_add_data($sheet, $students, $gradinginfopos, 'btec', $groups);
report_componentgrades_add_data($sheet, $students, $gradinginfopos, 'btec', $groups, $showgroups);

$workbook->close();

Expand Down
2 changes: 1 addition & 1 deletion guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
$groups = report_componentgrades_get_user_groups($course->id);
}

report_componentgrades_add_data($sheet, $students, $gradinginfopos, 'guide', $groups);
report_componentgrades_add_data($sheet, $students, $gradinginfopos, 'guide', $groups, $showgroups);

$workbook->close();

Expand Down
20 changes: 8 additions & 12 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ function report_componentgrades_add_header(MoodleExcelWorkbook $workbook, Moodle
$sheet->write_string(HEADINGSROW, $col, get_string('studentid', 'report_componentgrades'), $format2);
$col++;
}
if (get_config('report_componentgrades', 'showgroups')) {
if ($showgroups) {
$sheet->write_string(HEADINGSROW, $col++, get_string('groups'), $format2);
}
if ($showgroups) {
$sheet->write_string(HEADINGSROW, $col++, get_string('groups'), $format2);
}
$sheet->set_column(0, $col, 10); // Set column widths to 10.

Expand Down Expand Up @@ -170,7 +168,7 @@ function report_componentgrades_process_data(array $students, array $data) {
* @param array $groups - user group information (optional).
* @return void
*/
function report_componentgrades_add_data(MoodleExcelWorksheet $sheet, array $students, $gradinginfopos, $method, $groups = null) {
function report_componentgrades_add_data(MoodleExcelWorksheet $sheet, array $students, $gradinginfopos, $method, $groups = null, $showgroups = false) {
// Actual data.
$row = 5;
foreach ($students as $student) {
Expand All @@ -182,13 +180,11 @@ function report_componentgrades_add_data(MoodleExcelWorksheet $sheet, array $stu
if (get_config('report_componentgrades', 'showstudentid')) {
$sheet->write_string($row, $col++, $student->idnumber);
}
if (get_config('report_componentgrades', 'showgroups')) {
if (!is_null($groups)) {
if (isset($groups[$student->userid])) {
$sheet->write_string($row, $col++, implode(', ', $groups[$student->userid]));
} else {
$sheet->write_string($row, $col++, 'empty');
}
if ($showgroups) {
if (!is_null($groups) && isset($groups[$student->userid])) {
$sheet->write_string($row, $col++, implode(', ', $groups[$student->userid]));
} else {
$sheet->write_string($row, $col++, 'empty');
}
}

Expand Down
2 changes: 1 addition & 1 deletion rubric.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
if ($showgroups) {
$groups = report_componentgrades_get_user_groups($course->id);
}
$row = report_componentgrades_add_data($sheet, $students, $gradinginfopos, 'rubric', $groups);
report_componentgrades_add_data($sheet, $students, $gradinginfopos, 'rubric', $groups, $showgroups);

$workbook->close();

Expand Down