diff --git a/documentation/changelog.html b/documentation/changelog.html index cf1aa68b48..c17733fcef 100755 --- a/documentation/changelog.html +++ b/documentation/changelog.html @@ -98,6 +98,13 @@ + +
  • Exercises tool + +
  • +

    Dokeos 1.8.6.1 - August 2009

    diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index 796859b7f8..022e596395 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -471,7 +471,7 @@ if (!empty ($_POST['export_report']) && $_POST['export_report'] == 'export_repor switch ($_POST['export_format']) { case 'xls' : $export = new ExerciseResult(); - $export->exportCompleteReportXLS($documentPath, $user_id, $_SESSION['export_user_fields']); + $export->exportCompleteReportXLS($documentPath, $user_id, $_SESSION['export_user_fields'], $_POST['export_filter']); exit; break; case 'csv' : @@ -795,9 +795,11 @@ if (($is_allowedToEdit) and ($origin != 'learnpath')) { echo '
    '; echo ''; echo ''; + echo ''; echo '
    '; echo '
    '; echo ''; + echo ''; echo ''; echo '
    '; //echo '
    '; @@ -1130,12 +1132,8 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) { --> $_user['user_id'] clause has been removed + $sql="SELECT ".(api_is_western_name_order() ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)").", ce.title, te.exe_result , - te.exe_weighting, UNIX_TIMESTAMP(te.exe_date),te.exe_id, user.email, user.user_id - FROM $TBL_EXERCISES ce , $TBL_TRACK_EXERCISES te, $TBL_USER user - WHERE te.exe_exo_id = ce.id AND user_id=te.exe_user_id AND te.exe_cours_id='$cid' - ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC"; + te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id, user.email, user.user_id + FROM $TBL_EXERCISES AS ce , $TBL_TRACK_EXERCISES AS te, $TBL_USER AS user,$TBL_COURSE_REL_USER AS cuser + WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string($cid) . "' + AND cuser.status<>1 $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 + AND cuser.course_code=te.exe_cours_id ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC"; $hpsql="SELECT ".(api_is_western_name_order() ? "CONCAT(tu.firstname,' ',tu.lastname)" : "CONCAT(tu.lastname,' ',tu.firstname)").", tth.exe_name, - tth.exe_result , tth.exe_weighting, UNIX_TIMESTAMP(tth.exe_date), tu.email, tu.user_id - FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu - WHERE tu.user_id=tth.exe_user_id AND tth.exe_cours_id = '".$cid."' - ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC"; - + tth.exe_result , tth.exe_weighting, UNIX_TIMESTAMP(tth.exe_date), tu.email, tu.user_id + 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) . " $user_id_and ' + ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC"; + + } else { // get only this user's results - $sql="SELECT '',ce.title, te.exe_result , te.exe_weighting, " . - "UNIX_TIMESTAMP(te.exe_date),te.exe_id - FROM $TBL_EXERCISES ce , $TBL_TRACK_EXERCISES te - WHERE te.exe_exo_id = ce.id AND te.exe_user_id='".Database::escape_string($user_id)."' AND te.exe_cours_id='".Database::escape_string($cid)."' - ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date ASC"; - $hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date) - FROM $TBL_TRACK_HOTPOTATOES - WHERE exe_user_id = '".Database::escape_string($user_id)."' AND exe_cours_id = '".Database::escape_string($cid)."' - ORDER BY exe_cours_id ASC, exe_date ASC"; + $sql="SELECT '', ce.title, te.exe_result , + te.exe_weighting, UNIX_TIMESTAMP(te.exe_date), te.exe_id + FROM $TBL_EXERCISES AS ce , $TBL_TRACK_EXERCISES AS te, $TBL_USER AS user,$TBL_COURSE_REL_USER AS cuser + WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id AND te.exe_cours_id='" . Database :: escape_string($cid) . "' + AND cuser.status<>1 AND te.exe_user_id='".Database::escape_string($user_id)."' $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 + AND cuser.course_code=te.exe_cours_id ORDER BY te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC"; + + $hpsql = "SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date) + FROM $TBL_TRACK_HOTPOTATOES + WHERE exe_user_id = '" . $user_id . "' AND exe_cours_id = '" . Database :: escape_string($cid) . "' + ORDER BY exe_cours_id ASC, exe_date DESC"; } @@ -160,12 +166,36 @@ class ExerciseResult $NoTestRes = 0; $NoHPTestRes = 0; - $j=0; + $j=0; + + if ($filter) { + switch ($filter) { + case 1 : + $filter_by_not_revised = true; + break; + case 2 : + $filter_by_revised = true; + break; + default : + null; + } + } + //Print the results of tests if(is_array($results)) { for($i = 0; $i < sizeof($results); $i++) { + + $revised = false; + $sql_exe = 'SELECT exe_id FROM ' . Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING) . ' + WHERE author != ' . "''" . ' AND exe_id = ' . "'" . Database :: escape_string($results[$i][5]) . "'" . ' LIMIT 1'; + $query = Database::query($sql_exe, __FILE__, __LINE__); + + if (Database :: num_rows($query) > 0) $revised = true; + if ($filter_by_not_revised && $revised == true) continue; + if ($filter_by_revised && $revised == false) continue; + $return[$i] = array(); $id = $results[$i][5]; $mailid = $results[$i][6]; @@ -210,7 +240,7 @@ class ExerciseResult $return[$j+$i]['max'] = $hpresults[$i][3]; } } - $this->results = $return; + $this->results = $return; return true; } /** @@ -220,10 +250,10 @@ class ExerciseResult * @param boolean Whether to include user fields or not * @return boolean False on error */ - public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields) + public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields = array(), $export_filter = 0) { global $charset; - $this->_getExercisesReporting($document_path,$user_id); + $this->_getExercisesReporting($document_path,$user_id,$export_filter); $filename = 'exercise_results_'.date('YmdGis').'.csv'; if(!empty($user_id)) { @@ -302,10 +332,10 @@ class ExerciseResult * Exports the complete report as an XLS file * @return boolean False on error */ - public function exportCompleteReportXLS($document_path='',$user_id=null, $export_user_fields) + public function exportCompleteReportXLS($document_path='',$user_id=null, $export_user_fields=array(), $export_filter = 0) { global $charset; - $this->_getExercisesReporting($document_path,$user_id); + $this->_getExercisesReporting($document_path,$user_id,$export_filter); $filename = 'exercise_results_'.date('YmdGis').'.xls'; if(!empty($user_id)) { @@ -317,11 +347,23 @@ class ExerciseResult $worksheet =& $workbook->addWorksheet('Report '.date('YmdGis')); $line = 0; $column = 0; //skip the first column (row titles) - if(!empty($this->results[0]['user'])) - { - $worksheet->write($line,$column,get_lang('User')); - $column++; + + // check if exists column 'user' + $with_column_user = false; + foreach ($this->results as $result) { + if (!empty($result['user'])) { + $with_column_user = true; + break; + } + } + + if($with_column_user) { + $worksheet->write($line,$column,get_lang('User')); + $column++; } + + $export_user_fields = true; + if($export_user_fields) { //show user fields section with a big th colspan that spans over all fields @@ -350,12 +392,16 @@ class ExerciseResult $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['user']), ENT_QUOTES, $charset)); $column++; } - //show user fields data, if any, for this user - $user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false); - foreach($user_fields_values as $value) - { - $worksheet->write($line,$column,api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); - $column++; + + if($export_user_fields) + { + //show user fields data, if any, for this user + $user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false); + foreach($user_fields_values as $value) + { + $worksheet->write($line,$column,api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)); + $column++; + } } $worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)); $column++; diff --git a/tests/procedures/spanish/tests.xls b/tests/procedures/spanish/tests.xls index 4c3e173d50..246119b2e1 100644 Binary files a/tests/procedures/spanish/tests.xls and b/tests/procedures/spanish/tests.xls differ