@ -87,18 +87,10 @@ class ExerciseResult
$return = array();
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_EXERCISE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TBL_TRACK_EXERCISES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$TBL_TRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
$TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$TBL_TRACK_ATTEMPT_RECORDING= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
$TBL_COURSE_REL_USER = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$cid = api_get_course_id();
$course_id = api_get_course_int_id();
@ -112,8 +104,17 @@ class ExerciseResult
}
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,
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
$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 duration
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 ce.c_id = $course_id AND
@ -122,8 +123,12 @@ class ExerciseResult
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").", email, 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
WHERE tu.user_id=tth.exe_user_id AND
tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND
@ -133,9 +138,18 @@ class ExerciseResult
} else {
$user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
// 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, " .
"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
$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 duration,
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)
WHERE ce.c_id = $course_id AND
te.status != 'incomplete' AND
@ -204,7 +218,9 @@ class ExerciseResult
$return[$i]['email'] = $results[$i]['exemail'];
}
$return[$i]['title'] = $results[$i]['extitle'];
$return[$i]['time'] = api_convert_and_format_date($results[$i]['exdate']);
$return[$i]['start_date'] = api_get_local_time($results[$i]['exstart']);
$return[$i]['end_date'] = api_get_local_time($results[$i]['exdate']);
$return[$i]['duration'] = $results[$i]['duration'];
$return[$i]['result'] = $results[$i]['exresult'];
$return[$i]['max'] = $results[$i]['exweight'];
$return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('NotValidated');
@ -225,7 +241,10 @@ class ExerciseResult
$return[$i]['last_name'] = $hpresults[$i]['userpart2'];
}
$return[$i]['title'] = $title;
$return[$i]['time'] = api_convert_and_format_date($hpresults[$i]['exdate']);
$return[$i]['start_date'] = api_get_local_time($results[$i]['exstart']);
$return[$i]['end_date'] = api_get_local_time($results[$i]['exdate']);
$return[$i]['duration'] = $results[$i]['duration'];
$return[$i]['result'] = $hpresults[$i]['exe_result'];
$return[$i]['max'] = $hpresults[$i]['exe_weighting'];
}
@ -249,6 +268,7 @@ class ExerciseResult
}
$data = '';
if (api_is_western_name_order()) {
if(!empty($this->results[0]['first_name'])) {
$data .= get_lang('FirstName').';';
@ -277,6 +297,8 @@ class ExerciseResult
$data .= get_lang('Title').';';
$data .= get_lang('StartDate').';';
$data .= get_lang('EndDate').';';
$data .= get_lang('Duration'). ' ('.get_lang('MinMinutes').') ;';
$data .= get_lang('Score').';';
$data .= get_lang('Total').';';
$data .= get_lang('Status').';';
@ -284,21 +306,15 @@ class ExerciseResult
//results
foreach($this->results as $row) {
if (api_is_western_name_order()) {
if(!empty($row['first_name'])) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
}
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['first_name']), ENT_QUOTES, $charset)).';';
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
} else {
if(!empty($row['last_name'])) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
}
if(!empty($row['first_name'])) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
}
$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['first_name']), ENT_QUOTES, $charset)).';';
}
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
if ($export_user_fields) {
@ -308,8 +324,11 @@ class ExerciseResult
$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";';
}
}
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
$data .= str_replace("\r\n",' ',$row['time']).';';
$data .= str_replace("\r\n",' ',$row['start_date']).';';
$data .= str_replace("\r\n",' ',$row['end_date']).';';
$data .= str_replace("\r\n",' ',$row['duration']).';';
$data .= str_replace("\r\n",' ',$row['result']).';';
$data .= str_replace("\r\n",' ',$row['max']).';';
$data .= str_replace("\r\n",' ',$row['status']).';';
@ -345,11 +364,9 @@ class ExerciseResult
global $charset;
$this->_getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
$filename = 'exercise_results_'.date('YmdGis').'.xls';
if(!empty($user_id)) {
if (!empty($user_id)) {
$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.xls';
}
require_once api_get_path(LIBRARY_PATH).'pear/Spreadsheet_Excel_Writer/Writer.php';
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->setVersion(8); // BIFF8
@ -369,6 +386,8 @@ class ExerciseResult
}
}
if ($with_column_user) {
$worksheet->write($line,$column,get_lang('Email'));
@ -392,32 +411,45 @@ class ExerciseResult
$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
//show the fields names for user fields
foreach($extra_user_fields as $field) {
foreach ($extra_user_fields as $field) {
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
$column++;
}
}
$worksheet->write($line,$column,get_lang('Title'));
$worksheet->write($line,$column, get_lang('Title'));
$column++;
$worksheet->write($line,$column,get_lang('StartDate'));
$worksheet->write($line,$column, get_lang('StartDate'));
$column++;
$worksheet->write($line,$column, get_lang('EndDate'));
$column++;
$worksheet->write($line,$column, get_lang('Duration').' ('.get_lang('MinMinutes').')');
$column++;
$worksheet->write($line,$column,get_lang('Score'));
$worksheet->write($line,$column, get_lang('Score'));
$column++;
$worksheet->write($line,$column,get_lang('Total'));
$worksheet->write($line,$column, get_lang('Total'));
$column++;
$worksheet->write($line,$column,get_lang('Status'));
$worksheet->write($line,$column, get_lang('Status'));
$line++;
foreach($this->results as $row) {
foreach ($this->results as $row) {
$column = 0;
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));
$column++;
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$column++;
if ($with_column_user) {
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
$column++;
if (api_is_western_name_order()) {
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$column++;
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$column++;
} else {
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$column++;
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$column++;
}
}
if ($export_user_fields) {
@ -428,9 +460,14 @@ class ExerciseResult
$column++;
}
}
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
$column++;
$worksheet->write($line,$column,$row['time']);
$worksheet->write($line,$column,$row['start_date']);
$column++;
$worksheet->write($line,$column,$row['end_date']);
$column++;
$worksheet->write($line,$column,$row['duration']);
$column++;
$worksheet->write($line,$column,$row['result']);
$column++;