Skip to content
Browse files

Merge branch 'wip-MDL-25185-MOODLE_22_STABLE' of git://github.com/abg…

…reeve/moodle into MOODLE_22_STABLE
  • Loading branch information...
2 parents 38d0571 + 4ec0b1c commit f7562f72fbd2deca46910cd91193659521fefd27 Sam Hemelryk committed Feb 13, 2012
Showing with 17 additions and 3 deletions.
  1. +5 −1 mod/data/export.php
  2. +12 −2 mod/data/lib.php
View
6 mod/data/export.php
@@ -84,6 +84,8 @@
$PAGE->set_title($data->name);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
+ $url = new moodle_url('/mod/data/export.php', array('d' => $d));
+ groups_print_activity_menu($cm, $url);
echo $OUTPUT->heading(format_string($data->name));
// these are for the tab display
@@ -104,7 +106,9 @@
}
}
-$exportdata = data_get_exportdata($data->id, $fields, $selectedfields);
+$currentgroup = groups_get_activity_group($cm);
+
+$exportdata = data_get_exportdata($data->id, $fields, $selectedfields, $currentgroup);
$count = count($exportdata);
switch ($formdata['exporttype']) {
case 'csv':
View
14 mod/data/lib.php
@@ -2804,9 +2804,11 @@ function data_export_ods($export, $dataname, $count) {
* @param int $dataid
* @param array $fields
* @param array $selectedfields
+ * @param int $currentgroup group ID of the current group. This is used for
+ * exporting data while maintaining group divisions.
* @return array
*/
-function data_get_exportdata($dataid, $fields, $selectedfields) {
+function data_get_exportdata($dataid, $fields, $selectedfields, $currentgroup=0) {
global $DB;
$exportdata = array();
@@ -2826,7 +2828,15 @@ function data_get_exportdata($dataid, $fields, $selectedfields) {
$line = 1;
foreach($datarecords as $record) {
// get content indexed by fieldid
- if( $content = $DB->get_records('data_content', array('recordid'=>$record->id), 'fieldid', 'fieldid, content, content1, content2, content3, content4') ) {
+ if ($currentgroup) {
+ $select = 'SELECT c.fieldid, c.content, c.content1, c.content2, c.content3, c.content4 FROM {data_content} c, {data_records} r WHERE c.recordid = ? AND r.id = c.recordid AND r.groupid = ?';
+ $where = array($record->id, $currentgroup);
+ } else {
+ $select = 'SELECT fieldid, content, content1, content2, content3, content4 FROM {data_content} WHERE recordid = ?';
+ $where = array($record->id);
+ }
+
+ if( $content = $DB->get_records_sql($select, $where) ) {
foreach($fields as $field) {
$contents = '';
if(isset($content[$field->field->id])) {

0 comments on commit f7562f7

Please sign in to comment.
Something went wrong with that request. Please try again.