Fixing hotpotatoes results , adding the user email in the exercise results when exporting to CSV, XLS

skala
Julio Montoya 15 years ago
parent f321c01f96
commit ecee88cb06
  1. 35
      main/exercice/exercice.php
  2. 151
      main/exercice/exercise_result.class.php

@ -73,6 +73,13 @@ $exfile = strtolower($exfile[sizeof($exfile) - 1]);
$exercicePath = substr($exercicePath, 0, strpos($exercicePath, $exfile)); $exercicePath = substr($exercicePath, 0, strpos($exercicePath, $exfile));
$exercicePath = $exercicePath . "exercice.php"; $exercicePath = $exercicePath . "exercice.php";
if ($show == 'result') {
if (empty($_GET['exerciseId']) && empty($_GET['path']) ) {
//header('Location: exercice.php?' . api_get_cidreq());
}
}
// maximum number of exercises on a same page // maximum number of exercises on a same page
$limitExPage = 50; $limitExPage = 50;
@ -381,13 +388,13 @@ if (!empty ($_POST['export_report']) && $_POST['export_report'] == 'export_repor
switch ($_POST['export_format']) { switch ($_POST['export_format']) {
case 'xls' : case 'xls' :
$export = new ExerciseResult(); $export = new ExerciseResult();
$export->exportCompleteReportXLS($documentPath, $user_id, $_SESSION['export_user_fields'], $_POST['export_filter'],$_POST['exerciseId']); $export->exportCompleteReportXLS($documentPath, $user_id, $_SESSION['export_user_fields'], $_POST['export_filter'],$_POST['exerciseId'], $_POST['hotpotato_name']);
exit; exit;
break; break;
case 'csv' : case 'csv' :
default : default :
$export = new ExerciseResult(); $export = new ExerciseResult();
$export->exportCompleteReportCSV($documentPath, $user_id, $_SESSION['export_user_fields'], $_POST['export_filter'],$_POST['exerciseId']); $export->exportCompleteReportCSV($documentPath, $user_id, $_SESSION['export_user_fields'], $_POST['export_filter'],$_POST['exerciseId'], $_POST['hotpotato_name']);
exit; exit;
break; break;
} }
@ -608,7 +615,8 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
echo '<form id="form1a" name="form1a" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '" style="display:inline">'; echo '<form id="form1a" name="form1a" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '" style="display:inline">';
echo '<input type="hidden" name="export_report" value="export_report">'; echo '<input type="hidden" name="export_report" value="export_report">';
echo '<input type="hidden" name="export_format" value="csv">'; echo '<input type="hidden" name="export_format" value="csv">';
echo '<input type="hidden" name="exerciseId" value="'.intval($_GET['exerciseId']).'">'; echo '<input type="hidden" name="exerciseId" value="'.intval($_GET['exerciseId']).'">';
echo '<input type="hidden" name="hotpotato_name" value="'.Security::remove_XSS($_GET['path']).'">';
if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) { if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) {
$filter = 1; $filter = 1;
@ -619,7 +627,8 @@ if ($is_allowedToEdit && $origin != 'learnpath') {
echo '</form>'; echo '</form>';
echo '<form id="form1b" name="form1b" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '" style="display:inline">'; echo '<form id="form1b" name="form1b" method="post" action="' . api_get_self() . '?show=' . Security :: remove_XSS($_GET['show']) . '" style="display:inline">';
echo '<input type="hidden" name="export_report" value="export_report">'; echo '<input type="hidden" name="export_report" value="export_report">';
echo '<input type="hidden" name="export_filter" value="'.(empty($filter)?1:intval($filter)).'">'; echo '<input type="hidden" name="export_filter" value="'.(empty($filter)?1:intval($filter)).'">';
echo '<input type="hidden" name="hotpotato_name" value="'.Security::remove_XSS($_GET['path']).'">';
echo '<input type="hidden" name="export_format" value="xls">'; echo '<input type="hidden" name="export_format" value="xls">';
echo '<input type="hidden" name="exerciseId" value="'.intval($_GET['exerciseId']).'">'; echo '<input type="hidden" name="exerciseId" value="'.intval($_GET['exerciseId']).'">';
echo '</form>'; echo '</form>';
@ -654,12 +663,14 @@ if ($show == 'result') {
default : default :
null; null;
} }
if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) { if (!empty($_GET['exerciseId'])) {
$view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&id_session='.intval($_GET['id_session']).'&exerciseId='.intval($_GET['exerciseId']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('exercice_check.png', get_lang('ShowCorrectedOnly'),'','32').'</a>'; if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) {
} else { $view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&id_session='.intval($_GET['id_session']).'&exerciseId='.intval($_GET['exerciseId']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('exercice_check.png', get_lang('ShowCorrectedOnly'),'','32').'</a>';
$view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&id_session='.intval($_GET['id_session']).'&exerciseId='.intval($_GET['exerciseId']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('exercice_uncheck.png', get_lang('ShowUnCorrectedOnly'),'','32').'</a>'; } else {
$view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&id_session='.intval($_GET['id_session']).'&exerciseId='.intval($_GET['exerciseId']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('exercice_uncheck.png', get_lang('ShowUnCorrectedOnly'),'','32').'</a>';
}
echo $view_result;
} }
echo $view_result;
} }
} }
echo '</div>'; // closing the actions div echo '</div>'; // closing the actions div
@ -789,7 +800,7 @@ if ($show == 'test') {
//Settings //Settings
//$actions = Display::url(Display::return_icon('edit.gif',get_lang('Edit'), array('width'=>'20px')), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']); //$actions = Display::url(Display::return_icon('edit.gif',get_lang('Edit'), array('width'=>'20px')), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']);
$actions = Display::url(Display::return_icon('edit.gif',get_lang('Edit')), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']); $actions = Display::url(Display::return_icon('edit.png',get_lang('Edit'),array('width' =>'22px')), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']);
$actions .='<a href="exercice.php?' . api_get_cidreq() . '&show=result&exerciseId='.$row['id'].'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')).'</a>'; $actions .='<a href="exercice.php?' . api_get_cidreq() . '&show=result&exerciseId='.$row['id'].'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')).'</a>';
@ -984,9 +995,7 @@ if ($show == 'test') {
$item = Display::tag('td','<img src="../img/hotpotatoes_s.png" alt="HotPotatoes" /> <a href="showinframes.php?file='.$path.'&cid='.api_get_course_id().'&uid='.api_get_user_id().'"'.(!$active?'class="invisible"':'').'>'.$title.'</a> '); $item = Display::tag('td','<img src="../img/hotpotatoes_s.png" alt="HotPotatoes" /> <a href="showinframes.php?file='.$path.'&cid='.api_get_course_id().'&uid='.api_get_user_id().'"'.(!$active?'class="invisible"':'').'>'.$title.'</a> ');
$item .= Display::tag('td','-'); $item .= Display::tag('td','-');
$actions = '<a href="adminhp.php?'.api_get_cidreq().'&hotpotatoesName='.$path.'"> $actions = Display::url(Display::return_icon('edit.png',get_lang('Edit'),array('width' =>'22px')), 'adminhp.php?'.api_get_cidreq().'&hotpotatoesName='.$path);
<img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="'.api_htmlentities(get_lang('Modify'),ENT_QUOTES,$charset).'" /></a>';
$actions .='<a href="exercice.php?' . api_get_cidreq() . '&show=result&path='.$path.'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')).'</a>'; $actions .='<a href="exercice.php?' . api_get_cidreq() . '&show=result&path='.$path.'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')).'</a>';
// if active // if active

@ -90,7 +90,7 @@ class ExerciseResult
* @param string The document path (for HotPotatoes retrieval) * @param string The document path (for HotPotatoes retrieval)
* @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
*/ */
function _getExercisesReporting($document_path,$user_id=null,$filter=0, $exercise_id = 0) { function _getExercisesReporting($document_path, $user_id=null, $filter=0, $exercise_id = 0, $hotpotato_name = null) {
$return = array(); $return = array();
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); $TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
@ -104,59 +104,55 @@ class ExerciseResult
$TBL_COURSE_REL_USER = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $TBL_COURSE_REL_USER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$cid = api_get_course_id(); $cid = api_get_course_id();
$user_id = intval($user_id); $user_id = intval($user_id);
$session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' '; $session_id_and = ' AND te.session_id = ' . api_get_session_id() . ' ';
$exercise_id = intval($exercise_id); $exercise_id = intval($exercise_id);
$hotpotato_name = Database::escape_string($hotpotato_name);
if (!empty($exercise_id)) { if (!empty($exercise_id)) {
$session_id_and .= " AND exe_exo_id = $exercise_id "; $session_id_and .= " AND exe_exo_id = $exercise_id ";
} }
if (empty($user_id)) { if (empty($user_id)) {
$sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", ce.title as extitle, te.exe_result as exresult , te.exe_weighting as exweight, $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", ce.title as extitle, te.exe_result as exresult , te.exe_weighting as exweight,
te.exe_date as exdate, te.exe_id as exid, email as exemail, te.start_date as exstart, steps_counter as exstep, exe_user_id as excruid,te.exe_duration as exduration te.exe_date as exdate, te.exe_id as exid, email as exemail, te.start_date as exstart, steps_counter as exstep, exe_user_id as excruid,te.exe_duration as exduration
FROM $TBL_EXERCISES AS ce INNER JOIN $TBL_TRACK_EXERCISES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id) FROM $TBL_EXERCISES AS ce INNER JOIN $TBL_TRACK_EXERCISES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0"; WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0";
$hpsql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", tth.exe_name, tth.exe_result , tth.exe_weighting, tth.exe_date $hpsql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", email, tth.exe_name, tth.exe_result , tth.exe_weighting, tth.exe_date
FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($cid) . "' WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND tth.exe_name = '$hotpotato_name'
ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC"; ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC";
} else { } else {
$user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
// get only this user's results // get only this user's results
$sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", ce.title as extitle, te.exe_result as exresult, " . $sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").", ce.title as extitle, te.exe_result as exresult, " .
"te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, " . "te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, " .
"te.start_date as exstart, steps_counter as exstep, exe_user_id as excruid, te.exe_duration as exduration, ce.results_disabled as exdisabled "te.start_date as exstart, steps_counter as exstep, exe_user_id as excruid, te.exe_duration as exduration, ce.results_disabled as exdisabled
FROM $TBL_EXERCISES AS ce INNER JOIN $TBL_TRACK_EXERCISES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id) FROM $TBL_EXERCISES AS ce INNER JOIN $TBL_TRACK_EXERCISES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND" . WHERE te.status != 'incomplete' AND te.exe_cours_id='" . Database :: escape_string($cid) . "' $user_id_and $session_id_and AND ce.active <>-1 AND" .
" orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER BY userpart2, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC"; " orig_lp_id = 0 AND orig_lp_item_id = 0 ORDER BY userpart2, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";
$hpsql = "SELECT '',exe_name, exe_result , exe_weighting, exe_date $hpsql = "SELECT '',exe_name, exe_result , exe_weighting, exe_date
FROM $TBL_TRACK_HOTPOTATOES FROM $TBL_TRACK_HOTPOTATOES
WHERE exe_user_id = '" . $user_id . "' AND exe_cours_id = '" . Database :: escape_string($cid) . "' WHERE exe_user_id = '" . $user_id . "' AND exe_cours_id = '" . Database :: escape_string($cid) . "' AND tth.exe_name = '$hotpotato_name'
ORDER BY exe_cours_id ASC, exe_date DESC"; ORDER BY exe_cours_id ASC, exe_date DESC";
} }
$results = array(); $results = array();
$resx = Database::query($sql); $resx = Database::query($sql);
while ($rowx = Database::fetch_array($resx,'ASSOC')) { while ($rowx = Database::fetch_array($resx,'ASSOC')) {
$results[] = $rowx; $results[] = $rowx;
} }
$hpresults = array();
//$results = getManyResultsXCol($sql,9); $resx = Database::query($hpsql);
$hpresults = getManyResultsXCol($hpsql,8); while ($rowx = Database::fetch_array($resx,'ASSOC')) {
$hpresults[] = $rowx;
$NoTestRes = 0; }
$NoHPTestRes = 0;
$j=0;
if ($filter) { if ($filter) {
switch ($filter) { switch ($filter) {
case 1 : case 1 :
@ -171,7 +167,7 @@ class ExerciseResult
} }
//Print the results of tests //Print the results of tests
if(is_array($results)) { if(is_array($results) && empty($hotpotato_name)) {
for($i = 0; $i < sizeof($results); $i++) { for($i = 0; $i < sizeof($results); $i++) {
$revised = false; $revised = false;
@ -186,50 +182,42 @@ class ExerciseResult
if ($filter_by_revised && !$revised) continue; if ($filter_by_revised && !$revised) continue;
$return[$i] = array(); $return[$i] = array();
$id = $results[$i]['exid']; //$id = $results[$i]['exid'];
$mailid = $results[$i]['exemail'];
$userlast = $results[$i]['userpart1']; if (empty($user_id)) {
$userfirst = $results[$i]['userpart2']; $return[$i]['last_name'] = $results[$i]['userpart1'];
$test = $results[$i]['extitle']; $return[$i]['first_name'] = $results[$i]['userpart2'];
$res = $results[$i]['exresult']; $return[$i]['user_id'] = $results[$i]['userid'];
$return[$i]['email'] = $results[$i]['exemail'];
if (empty($user_id)) {
$user = $results[$i]['userpart1'];//.$results[$i]['userpart2'];
$return[$i]['last_name'] = $user;
$return[$i]['first_name'] = $userfirst;
$return[$i]['user_id'] = $results[$i]['userid'];
} }
$return[$i]['title'] = $test; $return[$i]['title'] = $results[$i]['extitle'];
$return[$i]['time'] = api_convert_and_format_date($results[$i]['exdate'], null, date_default_timezone_get()); $return[$i]['time'] = api_convert_and_format_date($results[$i]['exdate'], null, date_default_timezone_get());
$return[$i]['result'] = $res; $return[$i]['result'] = $results[$i]['exresult'];
$return[$i]['max'] = $results[$i]['exweight']; $return[$i]['max'] = $results[$i]['exweight'];
$j=$i;
} }
} }
$j++;
// Print the Result of Hotpotatoes Tests // Print the Result of Hotpotatoes Tests
if(is_array($hpresults)) if (is_array($hpresults)) {
{ for($i = 0; $i < sizeof($hpresults); $i++) {
for($i = 0; $i < sizeof($hpresults); $i++) $return[$i] = array();
{ $title = GetQuizName($hpresults[$i]['exe_name'], $document_path);
$return[$j+$i] = array(); if ($title =='') {
$title = GetQuizName($hpresults[$i]['exname'],$document_path); $title = basename($hpresults[$i]['exe_name']);
if ($title =='')
{
$title = basename($hpresults[$i]['exname']);
} }
if(empty($user_id)) if(empty($user_id)) {
{ $return[$i]['email'] = $hpresults[$i]['email'];
$return[$j+$i]['user'] = $hpresults[$i]['userpart1'].$hpresults[$i]['userpart2']; $return[$i]['first_name'] = $hpresults[$i]['userpart2'];
$return[$j+$i]['user_id'] = $results[$i]['userid']; $return[$i]['last_name'] = $hpresults[$i]['userpart1'];
//$return[$i]['user_id'] = $results[$i]['userid'];
} }
$return[$j+$i]['title'] = $title; $return[$i]['title'] = $title;
$return[$j+$i]['time'] = api_convert_and_format_date($hpresults[$i]['exdate'], null, date_default_timezone_get()); $return[$i]['time'] = api_convert_and_format_date($hpresults[$i]['exdate'], null, date_default_timezone_get());
$return[$j+$i]['result'] = $hpresults[$i]['exresult']; $return[$i]['result'] = $hpresults[$i]['exe_result'];
$return[$j+$i]['max'] = $hpresults[$i]['exweight']; $return[$i]['max'] = $hpresults[$i]['exe_weighting'];
} }
} }
$this->results = $return; $this->results = $return;
return true; return true;
} }
@ -240,25 +228,25 @@ class ExerciseResult
* @param boolean Whether to include user fields or not * @param boolean Whether to include user fields or not
* @return boolean False on error * @return boolean False on error
*/ */
public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields = array(), $export_filter = 0, $exercise_id = 0) public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields = array(), $export_filter = 0, $exercise_id = 0, $hotpotato_name = null) {
{
global $charset; global $charset;
$this->_getExercisesReporting($document_path,$user_id,$export_filter, $exercise_id); $this->_getExercisesReporting($document_path,$user_id,$export_filter, $exercise_id, $hotpotato_name);
$filename = 'exercise_results_'.date('YmdGis').'.csv'; $filename = 'exercise_results_'.date('YmdGis').'.csv';
if(!empty($user_id)) { if(!empty($user_id)) {
$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv'; $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
} }
$data = ''; $data = '';
//build the results
//titles $data .= get_lang('Email').';';
if(!empty($this->results[0]['last_name'])) {
if(!empty($this->results[0]['last_name'])) {
$data .= get_lang('LastName').';'; $data .= get_lang('LastName').';';
} }
if(!empty($this->results[0]['first_name'])) { if(!empty($this->results[0]['first_name'])) {
$data .= get_lang('FirstName').';'; $data .= get_lang('FirstName').';';
} }
if($export_user_fields) { if ($export_user_fields) {
//show user fields section with a big th colspan that spans over all fields //show user fields section with a big th colspan that spans over all fields
$extra_user_fields = UserManager::get_extra_fields(0,0,5,'ASC',false); $extra_user_fields = UserManager::get_extra_fields(0,0,5,'ASC',false);
$num = count($extra_user_fields); $num = count($extra_user_fields);
@ -269,12 +257,14 @@ class ExerciseResult
} }
$data .= get_lang('Title').';'; $data .= get_lang('Title').';';
$data .= get_lang('Date').';'; $data .= get_lang('Date').';';
$data .= get_lang('Results').';'; $data .= get_lang('Score').';';
$data .= get_lang('Weighting').';'; $data .= get_lang('Total').';';
$data .= "\n"; $data .= "\n";
//results //results
foreach($this->results as $row) { foreach($this->results as $row) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
if(!empty($row['last_name'])) { if(!empty($row['last_name'])) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';'; $data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
} }
@ -285,8 +275,7 @@ class ExerciseResult
if($export_user_fields) { if($export_user_fields) {
//show user fields data, if any, for this user //show user fields data, if any, for this user
$user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false); $user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false);
foreach($user_fields_values as $value) foreach($user_fields_values as $value) {
{
$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";'; $data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
} }
} }
@ -320,9 +309,9 @@ class ExerciseResult
* Exports the complete report as an XLS file * Exports the complete report as an XLS file
* @return boolean False on error * @return boolean False on error
*/ */
public function exportCompleteReportXLS($document_path='',$user_id=null, $export_user_fields=array(), $export_filter = 0, $exercise_id=0) { public function exportCompleteReportXLS($document_path='',$user_id=null, $export_user_fields=array(), $export_filter = 0, $exercise_id=0, $hotpotato_name = null) {
global $charset; global $charset;
$this->_getExercisesReporting($document_path,$user_id,$export_filter, $exercise_id); $this->_getExercisesReporting($document_path,$user_id,$export_filter, $exercise_id,$hotpotato_name);
$filename = 'exercise_results_'.date('YmdGis').'.xls'; $filename = 'exercise_results_'.date('YmdGis').'.xls';
if(!empty($user_id)) { if(!empty($user_id)) {
$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.xls'; $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.xls';
@ -347,7 +336,9 @@ class ExerciseResult
} }
} }
if($with_column_user) { if ($with_column_user) {
$worksheet->write($line,$column,get_lang('Email'));
$column++;
$worksheet->write($line,$column,get_lang('LastName')); $worksheet->write($line,$column,get_lang('LastName'));
$column++; $column++;
$worksheet->write($line,$column,get_lang('FirstName')); $worksheet->write($line,$column,get_lang('FirstName'));
@ -368,14 +359,16 @@ class ExerciseResult
$column++; $column++;
$worksheet->write($line,$column,get_lang('Date')); $worksheet->write($line,$column,get_lang('Date'));
$column++; $column++;
$worksheet->write($line,$column,get_lang('Results')); $worksheet->write($line,$column,get_lang('Score'));
$column++; $column++;
$worksheet->write($line,$column,get_lang('Weighting')); $worksheet->write($line,$column,get_lang('Total'));
$line++; $line++;
foreach($this->results as $row) { foreach($this->results as $row) {
$column = 0; $column = 0;
if(!empty($row['last_name']) && !empty($row['first_name'])) { if(!empty($row['last_name']) && !empty($row['first_name'])) {
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
$column++;
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)); $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$column++; $column++;
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)); $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));

Loading…
Cancel
Save