mirror of
https://github.com/moodle/moodle.git
synced 2025-02-13 12:34:28 +01:00
Merge branch 'wip-MDL-25185-master' of git://github.com/abgreeve/moodle
This commit is contained in:
commit
ac87f25829
@ -84,6 +84,8 @@ if($mform->is_cancelled()) {
|
||||
$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 @@ foreach ($formdata as $key => $value) {
|
||||
}
|
||||
}
|
||||
|
||||
$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':
|
||||
|
@ -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])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user