mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-14517 Cannot export analysis to excel by course
This commit is contained in:
parent
4f5ffac022
commit
59f89d805b
@ -72,7 +72,7 @@
|
||||
//button "export to excel"
|
||||
echo '<div align="center">';
|
||||
$export_button_link = 'analysis_to_excel.php';
|
||||
$export_button_options = array('sesskey'=>$USER->sesskey, 'id'=>$id);
|
||||
$export_button_options = array('sesskey'=>$USER->sesskey, 'id'=>$id, 'coursefilter'=>$coursefilter);
|
||||
$export_button_label = get_string('export_to_excel', 'feedback');
|
||||
print_single_button($export_button_link, $export_button_options, $export_button_label, 'post');
|
||||
echo '</div>';
|
||||
|
@ -13,6 +13,7 @@
|
||||
require_once('easy_excel.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); //the POST dominated the GET
|
||||
$coursefilter = optional_param('coursefilter', '0', PARAM_INT);
|
||||
|
||||
$formdata = data_submitted();
|
||||
|
||||
@ -104,7 +105,7 @@
|
||||
//print the analysed sheet
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//get the completeds
|
||||
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid);
|
||||
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid, $coursefilter);
|
||||
if($completedscount > 0){
|
||||
//write the count of completeds
|
||||
$rowOffset1++;
|
||||
@ -129,7 +130,7 @@
|
||||
$itemclass = 'feedback_item_'.$item->typ;
|
||||
//get the instance of the item-class
|
||||
$itemobj = new $itemclass();
|
||||
$rowOffset1 = $itemobj->excelprint_item($worksheet1, $rowOffset1, $item, $mygroupid);
|
||||
$rowOffset1 = $itemobj->excelprint_item($worksheet1, $rowOffset1, $item, $mygroupid, $coursefilter);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -137,7 +138,7 @@
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//get the completeds
|
||||
|
||||
$completeds = feedback_get_completeds_group($feedback, $mygroupid);
|
||||
$completeds = feedback_get_completeds_group($feedback, $mygroupid, $coursefilter);
|
||||
//important: for each completed you have to print each item, even if it is not filled out!!!
|
||||
//therefor for each completed we have to iterate over all items of the feedback
|
||||
//this is done by feedback_excelprint_detailed_items
|
||||
|
@ -1496,7 +1496,7 @@ function feedback_get_current_completed($feedbackid, $tmp = false, $courseid = f
|
||||
* @param int $groupid
|
||||
* @return mixed array of found completeds otherwise false
|
||||
*/
|
||||
function feedback_get_completeds_group($feedback, $groupid = false) {
|
||||
function feedback_get_completeds_group($feedback, $groupid = false, $courseid = false) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if (intval($groupid) > 0){
|
||||
@ -1511,10 +1511,24 @@ function feedback_get_completeds_group($feedback, $groupid = false) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ($values = $DB->get_records('feedback_completed', array('feedback'=>$feedback->id))) {
|
||||
return $values;
|
||||
} else {
|
||||
return false;
|
||||
if($courseid) {
|
||||
$query = "SELECT DISTINCT fbc.*
|
||||
FROM {feedback_completed} AS fbc, {feedback_value} AS fbv
|
||||
WHERE fbc.id = fbv.completed
|
||||
AND fbc.feedback = ?
|
||||
AND fbv.course_id = ?
|
||||
ORDER BY random_response";
|
||||
if ($values = $DB->get_records_sql($query, array($feedback->id, $courseid))) {
|
||||
return $values;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
if ($values = $DB->get_records('feedback_completed', array('feedback'=>$feedback->id))) {
|
||||
return $values;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user