@@ -2,62 +2,62 @@ |
||
| 2 | 2 | |
| 3 | 3 | // get fields informations |
| 4 | 4 | function multiquery_query($array) { |
| 5 | - $result = array(); |
|
| 6 | - $field = 0; |
|
| 7 | - for ($i = 0; $i <sizeof($array); $i++) { |
|
| 8 | - // mysql handler |
|
| 9 | - $result[$i]['mysql'] = mysql_query($array[$i]); |
|
| 10 | - |
|
| 11 | - if (! $result[$i]['mysql']) |
|
| 12 | - die("error in query $i : ".$array[$i]); |
|
| 13 | - |
|
| 14 | - // fields |
|
| 15 | - $result[$i]['num_fields'] = mysql_num_fields($result[$i]['mysql']); |
|
| 16 | - for ($j = 0; $j < $result[$i]['num_fields']; $j++) { |
|
| 17 | - $name = mysql_field_name($result[$i]['mysql'], $j); |
|
| 18 | - $result['field'][$field]['query']=$i; |
|
| 19 | - $result['field'][$field]['name']=$name; |
|
| 20 | - $result['field'][$field]['id']=$j; |
|
| 21 | - $result['field_assoc'][$name][$field]; |
|
| 22 | - $field++; |
|
| 23 | - } |
|
| 24 | - } |
|
| 25 | - $result['num_queries'] = sizeof($array); |
|
| 26 | - // rows |
|
| 27 | - $numberOfResult = mysql_num_rows($result[0]['mysql']); |
|
| 28 | - for ($i = 1; $i <$result['num_queries']; $i++) |
|
| 29 | - if ($numberOfResult != mysql_num_rows($result[$i]['mysql'])) |
|
| 30 | - die("wrong number of row: $numberOfResult vs ". |
|
| 31 | - mysql_num_rows($result[$i]['mysql'])." on query $i"); |
|
| 32 | - |
|
| 33 | - $result['num_rows'] = $numberOfResult; |
|
| 34 | - $result['num_fields'] = $field; |
|
| 35 | - |
|
| 36 | - return $result; |
|
| 5 | + $result = array(); |
|
| 6 | + $field = 0; |
|
| 7 | + for ($i = 0; $i <sizeof($array); $i++) { |
|
| 8 | + // mysql handler |
|
| 9 | + $result[$i]['mysql'] = mysql_query($array[$i]); |
|
| 10 | + |
|
| 11 | + if (! $result[$i]['mysql']) |
|
| 12 | + die("error in query $i : ".$array[$i]); |
|
| 13 | + |
|
| 14 | + // fields |
|
| 15 | + $result[$i]['num_fields'] = mysql_num_fields($result[$i]['mysql']); |
|
| 16 | + for ($j = 0; $j < $result[$i]['num_fields']; $j++) { |
|
| 17 | + $name = mysql_field_name($result[$i]['mysql'], $j); |
|
| 18 | + $result['field'][$field]['query']=$i; |
|
| 19 | + $result['field'][$field]['name']=$name; |
|
| 20 | + $result['field'][$field]['id']=$j; |
|
| 21 | + $result['field_assoc'][$name][$field]; |
|
| 22 | + $field++; |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | + $result['num_queries'] = sizeof($array); |
|
| 26 | + // rows |
|
| 27 | + $numberOfResult = mysql_num_rows($result[0]['mysql']); |
|
| 28 | + for ($i = 1; $i <$result['num_queries']; $i++) |
|
| 29 | + if ($numberOfResult != mysql_num_rows($result[$i]['mysql'])) |
|
| 30 | + die("wrong number of row: $numberOfResult vs ". |
|
| 31 | + mysql_num_rows($result[$i]['mysql'])." on query $i"); |
|
| 32 | + |
|
| 33 | + $result['num_rows'] = $numberOfResult; |
|
| 34 | + $result['num_fields'] = $field; |
|
| 35 | + |
|
| 36 | + return $result; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | function multiquery_num_rows(&$mq_h) { |
| 40 | - return $mq_h['num_rows']; |
|
| 40 | + return $mq_h['num_rows']; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | function multiquery_num_fields(&$mq_h) { |
| 44 | - return $mq_h['num_fields']; |
|
| 44 | + return $mq_h['num_fields']; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | function multiquery_field_name(&$mq_h, $id) { |
| 48 | - return $mq_h['field'][$id]['name']; |
|
| 48 | + return $mq_h['field'][$id]['name']; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | function multiquery_fetch_row(&$mq_h) { |
| 52 | - $result = array(); |
|
| 53 | - $pos = 0; |
|
| 54 | - for ($i = 0; $i < $mq_h['num_queries']; $i++) { |
|
| 55 | - $row = mysql_fetch_row($mq_h[$i]['mysql']); |
|
| 56 | - if (!$row) return false; // last line |
|
| 57 | - for ($j = 0; $j < sizeof($row); $j++) { |
|
| 58 | - $result[$pos] = $row[$j]; |
|
| 59 | - $pos++; |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - return $result; |
|
| 52 | + $result = array(); |
|
| 53 | + $pos = 0; |
|
| 54 | + for ($i = 0; $i < $mq_h['num_queries']; $i++) { |
|
| 55 | + $row = mysql_fetch_row($mq_h[$i]['mysql']); |
|
| 56 | + if (!$row) return false; // last line |
|
| 57 | + for ($j = 0; $j < sizeof($row); $j++) { |
|
| 58 | + $result[$pos] = $row[$j]; |
|
| 59 | + $pos++; |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + return $result; |
|
| 63 | 63 | } |
@@ -4,20 +4,20 @@ discard block |
||
| 4 | 4 | function multiquery_query($array) { |
| 5 | 5 | $result = array(); |
| 6 | 6 | $field = 0; |
| 7 | - for ($i = 0; $i <sizeof($array); $i++) { |
|
| 7 | + for ($i = 0; $i < sizeof($array); $i++) { |
|
| 8 | 8 | // mysql handler |
| 9 | 9 | $result[$i]['mysql'] = mysql_query($array[$i]); |
| 10 | 10 | |
| 11 | - if (! $result[$i]['mysql']) |
|
| 11 | + if (!$result[$i]['mysql']) |
|
| 12 | 12 | die("error in query $i : ".$array[$i]); |
| 13 | 13 | |
| 14 | 14 | // fields |
| 15 | 15 | $result[$i]['num_fields'] = mysql_num_fields($result[$i]['mysql']); |
| 16 | 16 | for ($j = 0; $j < $result[$i]['num_fields']; $j++) { |
| 17 | 17 | $name = mysql_field_name($result[$i]['mysql'], $j); |
| 18 | - $result['field'][$field]['query']=$i; |
|
| 19 | - $result['field'][$field]['name']=$name; |
|
| 20 | - $result['field'][$field]['id']=$j; |
|
| 18 | + $result['field'][$field]['query'] = $i; |
|
| 19 | + $result['field'][$field]['name'] = $name; |
|
| 20 | + $result['field'][$field]['id'] = $j; |
|
| 21 | 21 | $result['field_assoc'][$name][$field]; |
| 22 | 22 | $field++; |
| 23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $result['num_queries'] = sizeof($array); |
| 26 | 26 | // rows |
| 27 | 27 | $numberOfResult = mysql_num_rows($result[0]['mysql']); |
| 28 | - for ($i = 1; $i <$result['num_queries']; $i++) |
|
| 28 | + for ($i = 1; $i < $result['num_queries']; $i++) |
|
| 29 | 29 | if ($numberOfResult != mysql_num_rows($result[$i]['mysql'])) |
| 30 | 30 | die("wrong number of row: $numberOfResult vs ". |
| 31 | 31 | mysql_num_rows($result[$i]['mysql'])." on query $i"); |
@@ -8,8 +8,9 @@ discard block |
||
| 8 | 8 | // mysql handler |
| 9 | 9 | $result[$i]['mysql'] = mysql_query($array[$i]); |
| 10 | 10 | |
| 11 | - if (! $result[$i]['mysql']) |
|
| 12 | - die("error in query $i : ".$array[$i]); |
|
| 11 | + if (! $result[$i]['mysql']) { |
|
| 12 | + die("error in query $i : ".$array[$i]); |
|
| 13 | + } |
|
| 13 | 14 | |
| 14 | 15 | // fields |
| 15 | 16 | $result[$i]['num_fields'] = mysql_num_fields($result[$i]['mysql']); |
@@ -25,10 +26,11 @@ discard block |
||
| 25 | 26 | $result['num_queries'] = sizeof($array); |
| 26 | 27 | // rows |
| 27 | 28 | $numberOfResult = mysql_num_rows($result[0]['mysql']); |
| 28 | - for ($i = 1; $i <$result['num_queries']; $i++) |
|
| 29 | - if ($numberOfResult != mysql_num_rows($result[$i]['mysql'])) |
|
| 29 | + for ($i = 1; $i <$result['num_queries']; $i++) { |
|
| 30 | + if ($numberOfResult != mysql_num_rows($result[$i]['mysql'])) |
|
| 30 | 31 | die("wrong number of row: $numberOfResult vs ". |
| 31 | 32 | mysql_num_rows($result[$i]['mysql'])." on query $i"); |
| 33 | + } |
|
| 32 | 34 | |
| 33 | 35 | $result['num_rows'] = $numberOfResult; |
| 34 | 36 | $result['num_fields'] = $field; |
@@ -53,7 +55,10 @@ discard block |
||
| 53 | 55 | $pos = 0; |
| 54 | 56 | for ($i = 0; $i < $mq_h['num_queries']; $i++) { |
| 55 | 57 | $row = mysql_fetch_row($mq_h[$i]['mysql']); |
| 56 | - if (!$row) return false; // last line |
|
| 58 | + if (!$row) { |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 61 | + // last line |
|
| 57 | 62 | for ($j = 0; $j < sizeof($row); $j++) { |
| 58 | 63 | $result[$pos] = $row[$j]; |
| 59 | 64 | $pos++; |
@@ -7,27 +7,27 @@ |
||
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | function reports_modules_quiz_init_forEachCourses($course_code, $course_id, $course_db) { |
| 10 | - global $reports_modules; |
|
| 10 | + global $reports_modules; |
|
| 11 | 11 | |
| 12 | - $reports_modules_quiz_toolid = reports_getToolId(TOOL_QUIZ); |
|
| 12 | + $reports_modules_quiz_toolid = reports_getToolId(TOOL_QUIZ); |
|
| 13 | 13 | |
| 14 | - array_push($reports_modules['quiz'], |
|
| 15 | - array('keys_query' => |
|
| 16 | - 'select '.$course_id.' as course_id, '. |
|
| 17 | - $reports_modules_quiz_toolid.' as tool_id, '. |
|
| 18 | - 'q.id as child_id, q.title as child_name, '. |
|
| 19 | - "'".$course_code."'".' as course_code from '.Database::get_course_table(TABLE_QUIZ_TEST).' q ', |
|
| 20 | - 'values_query_function' => 'reports_modules_quiz_quizVal')); |
|
| 14 | + array_push($reports_modules['quiz'], |
|
| 15 | + array('keys_query' => |
|
| 16 | + 'select '.$course_id.' as course_id, '. |
|
| 17 | + $reports_modules_quiz_toolid.' as tool_id, '. |
|
| 18 | + 'q.id as child_id, q.title as child_name, '. |
|
| 19 | + "'".$course_code."'".' as course_code from '.Database::get_course_table(TABLE_QUIZ_TEST).' q ', |
|
| 20 | + 'values_query_function' => 'reports_modules_quiz_quizVal')); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | function reports_modules_quiz_quizVal($quiz, $key_id) { |
| 24 | - $courseId = api_get_course_int_id($quiz['course_code']); |
|
| 25 | - return array('type'=> 'sql', 'sql' => |
|
| 26 | - 'select '.$key_id.', exe_user_id as uid, '. |
|
| 27 | - 'session_id, -1 as attempt, exe_result as score, '. |
|
| 28 | - REPORTS_PROGRESS_COMPLETED.' as progress, '. |
|
| 29 | - 'exe_duration as time, exe_date as ts from '. |
|
| 30 | - Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES). |
|
| 31 | - ' where c_id = ' . $courseId . |
|
| 32 | - ' and exe_exo_id='.$quiz['child_id']); |
|
| 24 | + $courseId = api_get_course_int_id($quiz['course_code']); |
|
| 25 | + return array('type'=> 'sql', 'sql' => |
|
| 26 | + 'select '.$key_id.', exe_user_id as uid, '. |
|
| 27 | + 'session_id, -1 as attempt, exe_result as score, '. |
|
| 28 | + REPORTS_PROGRESS_COMPLETED.' as progress, '. |
|
| 29 | + 'exe_duration as time, exe_date as ts from '. |
|
| 30 | + Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES). |
|
| 31 | + ' where c_id = ' . $courseId . |
|
| 32 | + ' and exe_exo_id='.$quiz['child_id']); |
|
| 33 | 33 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$reports_modules['quiz'] = array (); |
|
| 3 | +$reports_modules['quiz'] = array(); |
|
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | function reports_modules_quiz_init() { |
@@ -28,6 +28,6 @@ discard block |
||
| 28 | 28 | REPORTS_PROGRESS_COMPLETED.' as progress, '. |
| 29 | 29 | 'exe_duration as time, exe_date as ts from '. |
| 30 | 30 | Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES). |
| 31 | - ' where c_id = ' . $courseId . |
|
| 31 | + ' where c_id = '.$courseId. |
|
| 32 | 32 | ' and exe_exo_id='.$quiz['child_id']); |
| 33 | 33 | } |
@@ -7,117 +7,117 @@ |
||
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | function reports_modules_scorm_init_forEachCourses($course_code, $course_id, $course_db) { |
| 10 | - global $reports_modules; |
|
| 10 | + global $reports_modules; |
|
| 11 | 11 | |
| 12 | - $reports_modules_scorm_toolid = reports_getToolId(TOOL_LEARNPATH); |
|
| 12 | + $reports_modules_scorm_toolid = reports_getToolId(TOOL_LEARNPATH); |
|
| 13 | 13 | |
| 14 | - // package level |
|
| 15 | - array_push($reports_modules['scorm'], |
|
| 16 | - array('keys_query' => |
|
| 17 | - 'select '.$course_id.' as course_id, '. |
|
| 18 | - $reports_modules_scorm_toolid.' as tool_id, '. |
|
| 19 | - 'lp.id as child_id, lp.name as child_name, '. |
|
| 20 | - "'".$course_db."'".' as course_db from '. |
|
| 21 | - Database::get_course_table(TABLE_LP_MAIN).' lp', |
|
| 22 | - 'values_query_function' => 'reports_modules_scorm_packageVal')); |
|
| 14 | + // package level |
|
| 15 | + array_push($reports_modules['scorm'], |
|
| 16 | + array('keys_query' => |
|
| 17 | + 'select '.$course_id.' as course_id, '. |
|
| 18 | + $reports_modules_scorm_toolid.' as tool_id, '. |
|
| 19 | + 'lp.id as child_id, lp.name as child_name, '. |
|
| 20 | + "'".$course_db."'".' as course_db from '. |
|
| 21 | + Database::get_course_table(TABLE_LP_MAIN).' lp', |
|
| 22 | + 'values_query_function' => 'reports_modules_scorm_packageVal')); |
|
| 23 | 23 | |
| 24 | - // sco level |
|
| 25 | - array_push($reports_modules['scorm'], |
|
| 26 | - array('keys_query' => |
|
| 27 | - 'select '.$course_id.' as course_id, '. |
|
| 28 | - $reports_modules_scorm_toolid.' as tool_id, '. |
|
| 29 | - 'lp.id as child_id, lp.name as child_name, '. |
|
| 30 | - 'lpi.id as subchild_id, lpi.title as subchild_name, '. |
|
| 31 | - "'".$course_db."'".' as course_db from '. |
|
| 32 | - Database::get_course_table(TABLE_LP_MAIN, $course_db). |
|
| 33 | - ' lp,'. |
|
| 34 | - Database::get_course_table(TABLE_LP_ITEM, $course_db). |
|
| 35 | - ' lpi where lp.id = lpi.lp_id', |
|
| 36 | - 'values_query_function' => 'reports_modules_scorm_scoVal')); |
|
| 24 | + // sco level |
|
| 25 | + array_push($reports_modules['scorm'], |
|
| 26 | + array('keys_query' => |
|
| 27 | + 'select '.$course_id.' as course_id, '. |
|
| 28 | + $reports_modules_scorm_toolid.' as tool_id, '. |
|
| 29 | + 'lp.id as child_id, lp.name as child_name, '. |
|
| 30 | + 'lpi.id as subchild_id, lpi.title as subchild_name, '. |
|
| 31 | + "'".$course_db."'".' as course_db from '. |
|
| 32 | + Database::get_course_table(TABLE_LP_MAIN, $course_db). |
|
| 33 | + ' lp,'. |
|
| 34 | + Database::get_course_table(TABLE_LP_ITEM, $course_db). |
|
| 35 | + ' lpi where lp.id = lpi.lp_id', |
|
| 36 | + 'values_query_function' => 'reports_modules_scorm_scoVal')); |
|
| 37 | 37 | |
| 38 | - // objectives level |
|
| 39 | - array_push($reports_modules['scorm'], |
|
| 40 | - array('keys_query' => |
|
| 41 | - 'select distinct '.$course_id.' as course_id, '. |
|
| 42 | - $reports_modules_scorm_toolid.' as tool_id, '. |
|
| 43 | - 'lp.id as child_id, lp.name as child_name, '. |
|
| 44 | - 'lpi.id as subchild_id, '. |
|
| 45 | - 'lpi.title as subchild_name, '. |
|
| 46 | - 'null as subsubchild_id, '. |
|
| 47 | - 'lpivo.objective_id as subsubchild_name, '. |
|
| 48 | - "'".$course_db."'".' as course_db from '. |
|
| 49 | - Database::get_course_table(TABLE_LP_MAIN, $course_db). |
|
| 50 | - ' lp,'. |
|
| 51 | - Database::get_course_table(TABLE_LP_ITEM, $course_db). |
|
| 52 | - ' lpi, '. |
|
| 53 | - Database::get_course_table(TABLE_LP_ITEM_VIEW, $course_db). |
|
| 54 | - ' lpiv, '. |
|
| 55 | - Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $course_db). |
|
| 56 | - ' lpivo '. |
|
| 57 | - 'where lp.id = lpi.lp_id '. |
|
| 58 | - 'and lpi.id = lpiv.lp_item_id '. |
|
| 59 | - 'and lpiv.id = lpivo.lp_iv_id ', |
|
| 60 | - 'values_query_function' => 'reports_modules_scorm_objVal')); |
|
| 38 | + // objectives level |
|
| 39 | + array_push($reports_modules['scorm'], |
|
| 40 | + array('keys_query' => |
|
| 41 | + 'select distinct '.$course_id.' as course_id, '. |
|
| 42 | + $reports_modules_scorm_toolid.' as tool_id, '. |
|
| 43 | + 'lp.id as child_id, lp.name as child_name, '. |
|
| 44 | + 'lpi.id as subchild_id, '. |
|
| 45 | + 'lpi.title as subchild_name, '. |
|
| 46 | + 'null as subsubchild_id, '. |
|
| 47 | + 'lpivo.objective_id as subsubchild_name, '. |
|
| 48 | + "'".$course_db."'".' as course_db from '. |
|
| 49 | + Database::get_course_table(TABLE_LP_MAIN, $course_db). |
|
| 50 | + ' lp,'. |
|
| 51 | + Database::get_course_table(TABLE_LP_ITEM, $course_db). |
|
| 52 | + ' lpi, '. |
|
| 53 | + Database::get_course_table(TABLE_LP_ITEM_VIEW, $course_db). |
|
| 54 | + ' lpiv, '. |
|
| 55 | + Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $course_db). |
|
| 56 | + ' lpivo '. |
|
| 57 | + 'where lp.id = lpi.lp_id '. |
|
| 58 | + 'and lpi.id = lpiv.lp_item_id '. |
|
| 59 | + 'and lpiv.id = lpivo.lp_iv_id ', |
|
| 60 | + 'values_query_function' => 'reports_modules_scorm_objVal')); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | function reports_modules_scorm_packageVal($scorm, $key_id) { |
| 64 | - return array('type'=> 'sql', 'sql' => |
|
| 65 | - 'select '.$key_id.', user_id as uid, '. |
|
| 66 | - 'session_id, view_count as attempt, null as score, '. |
|
| 67 | - 'progress as progress, '. |
|
| 68 | - 'null as time, null as ts from '. |
|
| 69 | - Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']). |
|
| 70 | - ' where lp_id = '.$scorm['child_id']); |
|
| 64 | + return array('type'=> 'sql', 'sql' => |
|
| 65 | + 'select '.$key_id.', user_id as uid, '. |
|
| 66 | + 'session_id, view_count as attempt, null as score, '. |
|
| 67 | + 'progress as progress, '. |
|
| 68 | + 'null as time, null as ts from '. |
|
| 69 | + Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']). |
|
| 70 | + ' where lp_id = '.$scorm['child_id']); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | function reports_modules_scorm_scoVal($scorm, $key_id) { |
| 74 | - return array('type'=> 'sql', 'sql' => |
|
| 75 | - 'select '.$key_id.', lpv.user_id as uid, '. |
|
| 76 | - 'lpv.session_id, lpiv.view_count as attempt, '. |
|
| 77 | - 'lpiv.score as score, '. |
|
| 78 | - '(case lpiv.status '. |
|
| 79 | - 'when "incomplete" then 0 '. |
|
| 80 | - 'when "completed" then 1 '. |
|
| 81 | - 'when "passed" then 2 '. |
|
| 82 | - 'when "failed" then 3 '. |
|
| 83 | - 'when "browsed" then 4 '. |
|
| 84 | - 'when "not attempted" then 5 '. |
|
| 85 | - 'else 6 '. |
|
| 86 | - 'end) as progress, '. |
|
| 87 | - 'lpiv.total_time as time, null as ts from '. |
|
| 88 | - Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']). |
|
| 89 | - ' lpv, '. |
|
| 90 | - Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']). |
|
| 91 | - ' lpiv '. |
|
| 92 | - ' where lpv.lp_id = '.$scorm['child_id']. |
|
| 93 | - ' and lpiv.lp_item_id = '.$scorm['subchild_id']. |
|
| 94 | - ' and lpiv.lp_view_id = lpv.id'); |
|
| 74 | + return array('type'=> 'sql', 'sql' => |
|
| 75 | + 'select '.$key_id.', lpv.user_id as uid, '. |
|
| 76 | + 'lpv.session_id, lpiv.view_count as attempt, '. |
|
| 77 | + 'lpiv.score as score, '. |
|
| 78 | + '(case lpiv.status '. |
|
| 79 | + 'when "incomplete" then 0 '. |
|
| 80 | + 'when "completed" then 1 '. |
|
| 81 | + 'when "passed" then 2 '. |
|
| 82 | + 'when "failed" then 3 '. |
|
| 83 | + 'when "browsed" then 4 '. |
|
| 84 | + 'when "not attempted" then 5 '. |
|
| 85 | + 'else 6 '. |
|
| 86 | + 'end) as progress, '. |
|
| 87 | + 'lpiv.total_time as time, null as ts from '. |
|
| 88 | + Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']). |
|
| 89 | + ' lpv, '. |
|
| 90 | + Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']). |
|
| 91 | + ' lpiv '. |
|
| 92 | + ' where lpv.lp_id = '.$scorm['child_id']. |
|
| 93 | + ' and lpiv.lp_item_id = '.$scorm['subchild_id']. |
|
| 94 | + ' and lpiv.lp_view_id = lpv.id'); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | function reports_modules_scorm_objVal($scorm, $key_id) { |
| 98 | - return array('type'=> 'sql', 'sql' => |
|
| 99 | - 'select '.$key_id.', lpv.user_id as uid, '. |
|
| 100 | - 'lpv.session_id, lpiv.view_count as attempt, '. |
|
| 101 | - 'lpivo.score_raw as score, '. |
|
| 102 | - '(case lpivo.status '. |
|
| 103 | - 'when "incomplete" then 0 '. |
|
| 104 | - 'when "completed" then 1 '. |
|
| 105 | - 'when "passed" then 2 '. |
|
| 106 | - 'when "failed" then 3 '. |
|
| 107 | - 'when "browsed" then 4 '. |
|
| 108 | - 'when "not attempted" then 5 '. |
|
| 109 | - 'else 6 '. |
|
| 110 | - 'end) as progress, '. |
|
| 111 | - 'null as time, null as ts from '. |
|
| 112 | - Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']). |
|
| 113 | - ' lpv, '. |
|
| 114 | - Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']). |
|
| 115 | - ' lpiv, '. |
|
| 116 | - Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $scorm['course_db']). |
|
| 117 | - ' lpivo '. |
|
| 118 | - ' where lpv.lp_id = '.$scorm['child_id']. |
|
| 119 | - ' and lpiv.lp_item_id = '.$scorm['subchild_id']. |
|
| 120 | - ' and lpivo.objective_id = "'.$scorm['subsubchild_name'].'" '. |
|
| 121 | - ' and lpiv.lp_view_id = lpv.id'. |
|
| 122 | - ' and lpivo.lp_iv_id=lpiv.id'); |
|
| 98 | + return array('type'=> 'sql', 'sql' => |
|
| 99 | + 'select '.$key_id.', lpv.user_id as uid, '. |
|
| 100 | + 'lpv.session_id, lpiv.view_count as attempt, '. |
|
| 101 | + 'lpivo.score_raw as score, '. |
|
| 102 | + '(case lpivo.status '. |
|
| 103 | + 'when "incomplete" then 0 '. |
|
| 104 | + 'when "completed" then 1 '. |
|
| 105 | + 'when "passed" then 2 '. |
|
| 106 | + 'when "failed" then 3 '. |
|
| 107 | + 'when "browsed" then 4 '. |
|
| 108 | + 'when "not attempted" then 5 '. |
|
| 109 | + 'else 6 '. |
|
| 110 | + 'end) as progress, '. |
|
| 111 | + 'null as time, null as ts from '. |
|
| 112 | + Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']). |
|
| 113 | + ' lpv, '. |
|
| 114 | + Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']). |
|
| 115 | + ' lpiv, '. |
|
| 116 | + Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $scorm['course_db']). |
|
| 117 | + ' lpivo '. |
|
| 118 | + ' where lpv.lp_id = '.$scorm['child_id']. |
|
| 119 | + ' and lpiv.lp_item_id = '.$scorm['subchild_id']. |
|
| 120 | + ' and lpivo.objective_id = "'.$scorm['subsubchild_name'].'" '. |
|
| 121 | + ' and lpiv.lp_view_id = lpv.id'. |
|
| 122 | + ' and lpivo.lp_iv_id=lpiv.id'); |
|
| 123 | 123 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$reports_modules['scorm'] = array (); |
|
| 3 | +$reports_modules['scorm'] = array(); |
|
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | function reports_modules_scorm_init() { |
@@ -7,23 +7,23 @@ |
||
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | function reports_modules_course_init_forEachCourses($course_code, $course_id, $course_db) { |
| 10 | - global $reports_modules; |
|
| 10 | + global $reports_modules; |
|
| 11 | 11 | |
| 12 | 12 | // $reports_modules_course_toolid = reports_getToolId(TOOL_QUIZ); |
| 13 | 13 | |
| 14 | - array_push($reports_modules['course'], |
|
| 15 | - array('keys_query' => |
|
| 16 | - 'select '.$course_id.' as course_id, "'.$course_code.'" as course_code', |
|
| 17 | - 'values_query_function' => 'reports_modules_course_val')); |
|
| 14 | + array_push($reports_modules['course'], |
|
| 15 | + array('keys_query' => |
|
| 16 | + 'select '.$course_id.' as course_id, "'.$course_code.'" as course_code', |
|
| 17 | + 'values_query_function' => 'reports_modules_course_val')); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | function reports_modules_course_val($course, $key_id) { |
| 21 | - return array('type'=> 'sql', 'sql' => |
|
| 22 | - 'select '.$key_id.', user_id as uid, '. |
|
| 23 | - '-1 as session_id, -1 as attempt, null as score, '. |
|
| 24 | - 'NULL as progress, '. |
|
| 25 | - '(sum(logout_course_date) - sum(login_course_date)) as time, null as ts from '. |
|
| 26 | - Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS). |
|
| 27 | - ' where c_id = ' . $course['real_id'] . |
|
| 28 | - ' group by user_id'); |
|
| 21 | + return array('type'=> 'sql', 'sql' => |
|
| 22 | + 'select '.$key_id.', user_id as uid, '. |
|
| 23 | + '-1 as session_id, -1 as attempt, null as score, '. |
|
| 24 | + 'NULL as progress, '. |
|
| 25 | + '(sum(logout_course_date) - sum(login_course_date)) as time, null as ts from '. |
|
| 26 | + Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS). |
|
| 27 | + ' where c_id = ' . $course['real_id'] . |
|
| 28 | + ' group by user_id'); |
|
| 29 | 29 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$reports_modules['course'] = array (); |
|
| 3 | +$reports_modules['course'] = array(); |
|
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | function reports_modules_course_init() { |
@@ -24,6 +24,6 @@ discard block |
||
| 24 | 24 | 'NULL as progress, '. |
| 25 | 25 | '(sum(logout_course_date) - sum(login_course_date)) as time, null as ts from '. |
| 26 | 26 | Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS). |
| 27 | - ' where c_id = ' . $course['real_id'] . |
|
| 27 | + ' where c_id = '.$course['real_id']. |
|
| 28 | 28 | ' group by user_id'); |
| 29 | 29 | } |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $reports_template['CourseArticulate'] = array( |
| 4 | - 'description' => 'CourseArticulate', |
|
| 5 | - 'getSQL' => 'reports_template_CourseArticulate_getSQL', |
|
| 6 | - 'wizard' => |
|
| 4 | + 'description' => 'CourseArticulate', |
|
| 5 | + 'getSQL' => 'reports_template_CourseArticulate_getSQL', |
|
| 6 | + 'wizard' => |
|
| 7 | 7 | ' |
| 8 | 8 | <span id="CourseArticulate" class="step"> |
| 9 | 9 | <span class="font_normal_07em_black">This report does not need any particular settings</span><br /> |
@@ -12,113 +12,113 @@ discard block |
||
| 12 | 12 | '); |
| 13 | 13 | |
| 14 | 14 | function reports_template_CourseArticulate_getSQL() { |
| 15 | - // settings |
|
| 15 | + // settings |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | - // Nom, prenom |
|
| 19 | - $query = 'select u.lastname as "Last name", u.firstname as "First name" '; |
|
| 20 | - $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 21 | - $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 22 | - $query .= ' order by u.user_id '; |
|
| 23 | - $queries[0] = $query; |
|
| 24 | - $extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE; |
|
| 25 | - // Custom Field |
|
| 26 | - foreach (array("tags" => "tags") as $k => $v) { // FIXME |
|
| 27 | - $query = 'select ufv.value as "'.$v.'" '; |
|
| 28 | - $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 29 | - $query .= 'left join'.Database::get_main_table(TABLE_EXTRA_FIELD).' uf '; |
|
| 30 | - $query .= ' on uf.variable ="'.$k.'" '; |
|
| 31 | - $query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv '; |
|
| 32 | - $query .= ' on ufv.item_id = u.user_id and ufv.field_id = uf.id '; |
|
| 33 | - $query .= 'where ufv.extra_field_type = '.$extraFieldType.' AND u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 34 | - $query .= ' order by u.user_id '; |
|
| 35 | - $queries[] = $query; |
|
| 36 | - } |
|
| 18 | + // Nom, prenom |
|
| 19 | + $query = 'select u.lastname as "Last name", u.firstname as "First name" '; |
|
| 20 | + $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 21 | + $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 22 | + $query .= ' order by u.user_id '; |
|
| 23 | + $queries[0] = $query; |
|
| 24 | + $extraFieldType = \Chamilo\CoreBundle\Entity\ExtraField::USER_FIELD_TYPE; |
|
| 25 | + // Custom Field |
|
| 26 | + foreach (array("tags" => "tags") as $k => $v) { // FIXME |
|
| 27 | + $query = 'select ufv.value as "'.$v.'" '; |
|
| 28 | + $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 29 | + $query .= 'left join'.Database::get_main_table(TABLE_EXTRA_FIELD).' uf '; |
|
| 30 | + $query .= ' on uf.variable ="'.$k.'" '; |
|
| 31 | + $query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv '; |
|
| 32 | + $query .= ' on ufv.item_id = u.user_id and ufv.field_id = uf.id '; |
|
| 33 | + $query .= 'where ufv.extra_field_type = '.$extraFieldType.' AND u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 34 | + $query .= ' order by u.user_id '; |
|
| 35 | + $queries[] = $query; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - // Stored Value |
|
| 40 | - $sv = array(); |
|
| 41 | - foreach ($sv as $k => $v) { |
|
| 39 | + // Stored Value |
|
| 40 | + $sv = array(); |
|
| 41 | + foreach ($sv as $k => $v) { |
|
| 42 | 42 | if (!isset($v['sql'])) |
| 43 | 43 | $v['sql'] = 'FIELD'; |
| 44 | 44 | $sqlField = str_replace('FIELD', 'sv.sv_value', $v['sql']); |
| 45 | 45 | $query = 'select '.$sqlField.' as "'.$v['title'].'" '; |
| 46 | 46 | // $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" '; |
| 47 | - $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 48 | - $query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv '; |
|
| 49 | - $query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" '; |
|
| 50 | - $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 51 | - $query .= ' group by u.user_id '; |
|
| 52 | - $query .= ' order by u.user_id '; |
|
| 53 | - $queries[] = $query; |
|
| 54 | - } |
|
| 47 | + $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 48 | + $query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv '; |
|
| 49 | + $query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" '; |
|
| 50 | + $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 51 | + $query .= ' group by u.user_id '; |
|
| 52 | + $query .= ' order by u.user_id '; |
|
| 53 | + $queries[] = $query; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - // first and last connection |
|
| 57 | - $query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" '; |
|
| 58 | - $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 59 | - $query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel '; |
|
| 60 | - $query .= ' on tel.login_user_id = u.user_id '; |
|
| 61 | - $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 62 | - $query .= ' group by u.user_id '; |
|
| 63 | - $query .= ' order by u.user_id '; |
|
| 64 | - $queries[] = $query; |
|
| 56 | + // first and last connection |
|
| 57 | + $query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" '; |
|
| 58 | + $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 59 | + $query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel '; |
|
| 60 | + $query .= ' on tel.login_user_id = u.user_id '; |
|
| 61 | + $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 62 | + $query .= ' group by u.user_id '; |
|
| 63 | + $query .= ' order by u.user_id '; |
|
| 64 | + $queries[] = $query; |
|
| 65 | 65 | |
| 66 | - // SCORM Data |
|
| 67 | - $scormData = array(); |
|
| 66 | + // SCORM Data |
|
| 67 | + $scormData = array(); |
|
| 68 | 68 | $course_list = CourseManager::get_courses_list(); |
| 69 | - foreach ($course_list as $code => $details) { |
|
| 70 | - $courseId = $details['id']; |
|
| 71 | - $list = Database::query('SELECT l.id as lid, l.name as lname, li.id as liid, li.title as lititle '. |
|
| 72 | - ' FROM '.Database::get_course_table(TABLE_LP_MAIN).' l, '.Database::get_course_table(TABLE_LP_ITEM).' li '. |
|
| 73 | - ' WHERE l.c_id = '.$courseId.' AND li.c_id = '.$courseId.' AND l.id = li.lp_id'); |
|
| 74 | - while ($lpItem = Database::fetch_assoc($list)) { |
|
| 75 | - $scormData[] = array( |
|
| 76 | - //'coursedb' => $details['db_name'], |
|
| 77 | - 'lid' => $lpItem['lid'], |
|
| 78 | - 'liid' => $lpItem['liid'], |
|
| 79 | - 'target_view_count' => 1, |
|
| 80 | - 'target_indicator' => 'score', |
|
| 81 | - 'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/1/score', |
|
| 82 | - 'sql' => 'FIELD'); |
|
| 83 | - $scormData[] = array( |
|
| 84 | - //'coursedb' => $details['db_name'], |
|
| 85 | - 'lid' => $lpItem['lid'], |
|
| 86 | - 'liid' => $lpItem['liid'], |
|
| 87 | - 'target_view_count' => 2, |
|
| 88 | - 'target_indicator' => 'score', |
|
| 89 | - 'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/2/score', |
|
| 90 | - 'sql' => 'FIELD'); |
|
| 91 | - $scormData[] = array( |
|
| 92 | - //'coursedb' => $details['db_name'], |
|
| 93 | - 'lid' => $lpItem['lid'], |
|
| 94 | - 'liid' => $lpItem['liid'], |
|
| 95 | - 'target_view_count' => null, |
|
| 96 | - 'target_indicator' => 'score', |
|
| 97 | - 'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/all/score', |
|
| 98 | - 'sql' => 'avg(FIELD)'); |
|
| 99 | - } |
|
| 100 | - } |
|
| 69 | + foreach ($course_list as $code => $details) { |
|
| 70 | + $courseId = $details['id']; |
|
| 71 | + $list = Database::query('SELECT l.id as lid, l.name as lname, li.id as liid, li.title as lititle '. |
|
| 72 | + ' FROM '.Database::get_course_table(TABLE_LP_MAIN).' l, '.Database::get_course_table(TABLE_LP_ITEM).' li '. |
|
| 73 | + ' WHERE l.c_id = '.$courseId.' AND li.c_id = '.$courseId.' AND l.id = li.lp_id'); |
|
| 74 | + while ($lpItem = Database::fetch_assoc($list)) { |
|
| 75 | + $scormData[] = array( |
|
| 76 | + //'coursedb' => $details['db_name'], |
|
| 77 | + 'lid' => $lpItem['lid'], |
|
| 78 | + 'liid' => $lpItem['liid'], |
|
| 79 | + 'target_view_count' => 1, |
|
| 80 | + 'target_indicator' => 'score', |
|
| 81 | + 'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/1/score', |
|
| 82 | + 'sql' => 'FIELD'); |
|
| 83 | + $scormData[] = array( |
|
| 84 | + //'coursedb' => $details['db_name'], |
|
| 85 | + 'lid' => $lpItem['lid'], |
|
| 86 | + 'liid' => $lpItem['liid'], |
|
| 87 | + 'target_view_count' => 2, |
|
| 88 | + 'target_indicator' => 'score', |
|
| 89 | + 'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/2/score', |
|
| 90 | + 'sql' => 'FIELD'); |
|
| 91 | + $scormData[] = array( |
|
| 92 | + //'coursedb' => $details['db_name'], |
|
| 93 | + 'lid' => $lpItem['lid'], |
|
| 94 | + 'liid' => $lpItem['liid'], |
|
| 95 | + 'target_view_count' => null, |
|
| 96 | + 'target_indicator' => 'score', |
|
| 97 | + 'title' => $details['title'].'/'.$lpItem['lname'].'/'.$lpItem['lititle'].'/all/score', |
|
| 98 | + 'sql' => 'avg(FIELD)'); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - foreach ($scormData as $v) { |
|
| 102 | + foreach ($scormData as $v) { |
|
| 103 | 103 | if (!isset($v['sql'])) { |
| 104 | 104 | $v['sql'] = 'FIELD'; |
| 105 | 105 | } |
| 106 | 106 | $sqlField = str_replace('FIELD', $v['target_indicator'], $v['sql']); |
| 107 | 107 | $query = 'select '.$sqlField.' as "'.$v['title'].'" '; |
| 108 | 108 | $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
| 109 | - $query .= 'left outer join '.Database::get_course_table(TABLE_LP_VIEW).' lv '; |
|
| 110 | - $query .= ' on u.user_id = lv.user_id and lv.lp_id = '.$v['lid']; |
|
| 111 | - $query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW).' liv '; |
|
| 112 | - $query .= ' on lv.id = liv.lp_view_id '; |
|
| 113 | - if ($v['target_view_count']) |
|
| 114 | - $query .= ' and liv.view_count = '.$v['target_view_count']; |
|
| 115 | - $query .= ' and liv.lp_item_id = '.$v['liid'].' '; |
|
| 116 | - $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 117 | - $query .= ' group by u.user_id '; |
|
| 118 | - $query .= ' order by u.user_id '; |
|
| 119 | - $queries[] = $query; |
|
| 120 | - } |
|
| 109 | + $query .= 'left outer join '.Database::get_course_table(TABLE_LP_VIEW).' lv '; |
|
| 110 | + $query .= ' on u.user_id = lv.user_id and lv.lp_id = '.$v['lid']; |
|
| 111 | + $query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW).' liv '; |
|
| 112 | + $query .= ' on lv.id = liv.lp_view_id '; |
|
| 113 | + if ($v['target_view_count']) |
|
| 114 | + $query .= ' and liv.view_count = '.$v['target_view_count']; |
|
| 115 | + $query .= ' and liv.lp_item_id = '.$v['liid'].' '; |
|
| 116 | + $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 117 | + $query .= ' group by u.user_id '; |
|
| 118 | + $query .= ' order by u.user_id '; |
|
| 119 | + $queries[] = $query; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - return $queries; |
|
| 122 | + return $queries; |
|
| 123 | 123 | } |
| 124 | 124 | |
@@ -39,8 +39,9 @@ discard block |
||
| 39 | 39 | // Stored Value |
| 40 | 40 | $sv = array(); |
| 41 | 41 | foreach ($sv as $k => $v) { |
| 42 | - if (!isset($v['sql'])) |
|
| 43 | - $v['sql'] = 'FIELD'; |
|
| 42 | + if (!isset($v['sql'])) { |
|
| 43 | + $v['sql'] = 'FIELD'; |
|
| 44 | + } |
|
| 44 | 45 | $sqlField = str_replace('FIELD', 'sv.sv_value', $v['sql']); |
| 45 | 46 | $query = 'select '.$sqlField.' as "'.$v['title'].'" '; |
| 46 | 47 | // $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" '; |
@@ -110,8 +111,9 @@ discard block |
||
| 110 | 111 | $query .= ' on u.user_id = lv.user_id and lv.lp_id = '.$v['lid']; |
| 111 | 112 | $query .= ' left outer join '.Database::get_course_table(TABLE_LP_ITEM_VIEW).' liv '; |
| 112 | 113 | $query .= ' on lv.id = liv.lp_view_id '; |
| 113 | - if ($v['target_view_count']) |
|
| 114 | - $query .= ' and liv.view_count = '.$v['target_view_count']; |
|
| 114 | + if ($v['target_view_count']) { |
|
| 115 | + $query .= ' and liv.view_count = '.$v['target_view_count']; |
|
| 116 | + } |
|
| 115 | 117 | $query .= ' and liv.lp_item_id = '.$v['liid'].' '; |
| 116 | 118 | $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
| 117 | 119 | $query .= ' group by u.user_id '; |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | $reports_template['Generic'] = array( |
| 4 | - 'description' => 'Generic', |
|
| 5 | - 'getSQL' => 'reports_template_Generic_getSQL', |
|
| 6 | - 'wizard' => |
|
| 4 | + 'description' => 'Generic', |
|
| 5 | + 'getSQL' => 'reports_template_Generic_getSQL', |
|
| 6 | + 'wizard' => |
|
| 7 | 7 | ' |
| 8 | 8 | <span id="Generic" class="step"> |
| 9 | 9 | <span class="font_normal_07em_black">This report does not need any particular settings</span><br /> |
@@ -12,49 +12,49 @@ discard block |
||
| 12 | 12 | '); |
| 13 | 13 | |
| 14 | 14 | function reports_template_Generic_getSQL() { |
| 15 | - // settings |
|
| 16 | - |
|
| 17 | - |
|
| 18 | - // Nom, prenom |
|
| 19 | - $query = 'select u.lastname as "Last name", u.firstname as "First name" '; |
|
| 20 | - $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 21 | - $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 22 | - $query .= ' order by u.user_id '; |
|
| 23 | - $queries[0] = $query; |
|
| 24 | - |
|
| 25 | - // Custom Field |
|
| 26 | - foreach (array(10 => "description") as $k => $v) { |
|
| 27 | - $query = 'select ufv.value as "'.$v.'" '; |
|
| 28 | - $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 29 | - $query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv '; |
|
| 30 | - $query .= ' on ufv.item_id = u.user_id and ufv.field_id = '.$k; |
|
| 31 | - $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 32 | - $query .= ' order by u.user_id '; |
|
| 33 | - $queries[] = $query; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - // Stored Value |
|
| 37 | - $sv = array(); |
|
| 38 | - foreach ($sv as $k => $v) { |
|
| 39 | - $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" '; |
|
| 40 | - $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 41 | - $query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv '; |
|
| 42 | - $query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" '; |
|
| 43 | - $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 44 | - $query .= ' order by u.user_id '; |
|
| 45 | - $queries[] = $query; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - // premiere connexion |
|
| 49 | - $query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" '; |
|
| 50 | - $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 51 | - $query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel '; |
|
| 52 | - $query .= ' on tel.login_user_id = u.user_id '; |
|
| 53 | - $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 54 | - $query .= ' group by u.user_id '; |
|
| 55 | - $query .= ' order by u.user_id '; |
|
| 56 | - $queries[] = $query; |
|
| 57 | - |
|
| 58 | - return $queries; |
|
| 15 | + // settings |
|
| 16 | + |
|
| 17 | + |
|
| 18 | + // Nom, prenom |
|
| 19 | + $query = 'select u.lastname as "Last name", u.firstname as "First name" '; |
|
| 20 | + $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 21 | + $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 22 | + $query .= ' order by u.user_id '; |
|
| 23 | + $queries[0] = $query; |
|
| 24 | + |
|
| 25 | + // Custom Field |
|
| 26 | + foreach (array(10 => "description") as $k => $v) { |
|
| 27 | + $query = 'select ufv.value as "'.$v.'" '; |
|
| 28 | + $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 29 | + $query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv '; |
|
| 30 | + $query .= ' on ufv.item_id = u.user_id and ufv.field_id = '.$k; |
|
| 31 | + $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 32 | + $query .= ' order by u.user_id '; |
|
| 33 | + $queries[] = $query; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + // Stored Value |
|
| 37 | + $sv = array(); |
|
| 38 | + foreach ($sv as $k => $v) { |
|
| 39 | + $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" '; |
|
| 40 | + $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 41 | + $query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv '; |
|
| 42 | + $query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" '; |
|
| 43 | + $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 44 | + $query .= ' order by u.user_id '; |
|
| 45 | + $queries[] = $query; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + // premiere connexion |
|
| 49 | + $query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" '; |
|
| 50 | + $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 51 | + $query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel '; |
|
| 52 | + $query .= ' on tel.login_user_id = u.user_id '; |
|
| 53 | + $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') '; |
|
| 54 | + $query .= ' group by u.user_id '; |
|
| 55 | + $query .= ' order by u.user_id '; |
|
| 56 | + $queries[] = $query; |
|
| 57 | + |
|
| 58 | + return $queries; |
|
| 59 | 59 | } |
| 60 | 60 | |
@@ -12,30 +12,30 @@ |
||
| 12 | 12 | ');*/ |
| 13 | 13 | |
| 14 | 14 | function reports_template_courseTime_getSQL() { |
| 15 | - // fetch columns |
|
| 16 | - $result = array(); |
|
| 17 | - $query = 'select r.id as kid, c.title as course '. |
|
| 18 | - 'from '. |
|
| 19 | - Database::get_main_table(TABLE_MAIN_REPORTS_KEYS).' r, '. |
|
| 20 | - Database::get_main_table(TABLE_MAIN_COURSE).' c '. |
|
| 21 | - 'where r.course_id=c.id and r.tool_id is null and r.child_id is null'. |
|
| 22 | - ' order by c.title'; |
|
| 23 | - $columns = Database::query($query); |
|
| 24 | - if (Database::num_rows($columns) == 0) |
|
| 25 | - die('<b>'.get_lang('no data found: '.$query).'</b>'); |
|
| 26 | - $columns = Database::store_result($columns); |
|
| 15 | + // fetch columns |
|
| 16 | + $result = array(); |
|
| 17 | + $query = 'select r.id as kid, c.title as course '. |
|
| 18 | + 'from '. |
|
| 19 | + Database::get_main_table(TABLE_MAIN_REPORTS_KEYS).' r, '. |
|
| 20 | + Database::get_main_table(TABLE_MAIN_COURSE).' c '. |
|
| 21 | + 'where r.course_id=c.id and r.tool_id is null and r.child_id is null'. |
|
| 22 | + ' order by c.title'; |
|
| 23 | + $columns = Database::query($query); |
|
| 24 | + if (Database::num_rows($columns) == 0) |
|
| 25 | + die('<b>'.get_lang('no data found: '.$query).'</b>'); |
|
| 26 | + $columns = Database::store_result($columns); |
|
| 27 | 27 | |
| 28 | - // fetch data |
|
| 29 | - $query = 'select u.lastname Name, u.firstname Firstname'; |
|
| 30 | - foreach ($columns as $key => $column) |
|
| 31 | - $query .= ', sec_to_time(k'.$key.'.report_time) as `'. |
|
| 32 | - $column['course'].'` '; |
|
| 33 | - $query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 34 | - foreach ($columns as $key => $column) // fixme sessions |
|
| 35 | - $query .= 'left outer join '. |
|
| 36 | - Database::get_main_table(TABLE_MAIN_REPORTS_VALUES). |
|
| 37 | - ' k'.$key. |
|
| 38 | - ' on k'.$key.'.key_id = '.$column['kid']. |
|
| 39 | - ' and k'.$key.'.user_id = u.user_id '; |
|
| 40 | - return $query; |
|
| 28 | + // fetch data |
|
| 29 | + $query = 'select u.lastname Name, u.firstname Firstname'; |
|
| 30 | + foreach ($columns as $key => $column) |
|
| 31 | + $query .= ', sec_to_time(k'.$key.'.report_time) as `'. |
|
| 32 | + $column['course'].'` '; |
|
| 33 | + $query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
|
| 34 | + foreach ($columns as $key => $column) // fixme sessions |
|
| 35 | + $query .= 'left outer join '. |
|
| 36 | + Database::get_main_table(TABLE_MAIN_REPORTS_VALUES). |
|
| 37 | + ' k'.$key. |
|
| 38 | + ' on k'.$key.'.key_id = '.$column['kid']. |
|
| 39 | + ' and k'.$key.'.user_id = u.user_id '; |
|
| 40 | + return $query; |
|
| 41 | 41 | } |
@@ -21,21 +21,25 @@ |
||
| 21 | 21 | 'where r.course_id=c.id and r.tool_id is null and r.child_id is null'. |
| 22 | 22 | ' order by c.title'; |
| 23 | 23 | $columns = Database::query($query); |
| 24 | - if (Database::num_rows($columns) == 0) |
|
| 25 | - die('<b>'.get_lang('no data found: '.$query).'</b>'); |
|
| 24 | + if (Database::num_rows($columns) == 0) { |
|
| 25 | + die('<b>'.get_lang('no data found: '.$query).'</b>'); |
|
| 26 | + } |
|
| 26 | 27 | $columns = Database::store_result($columns); |
| 27 | 28 | |
| 28 | 29 | // fetch data |
| 29 | 30 | $query = 'select u.lastname Name, u.firstname Firstname'; |
| 30 | - foreach ($columns as $key => $column) |
|
| 31 | - $query .= ', sec_to_time(k'.$key.'.report_time) as `'. |
|
| 32 | - $column['course'].'` '; |
|
| 31 | + foreach ($columns as $key => $column) { |
|
| 32 | + $query .= ', sec_to_time(k'.$key.'.report_time) as `'. |
|
| 33 | + $column['course'].'` '; |
|
| 34 | + } |
|
| 33 | 35 | $query .= ' from '.Database::get_main_table(TABLE_MAIN_USER).' u '; |
| 34 | - foreach ($columns as $key => $column) // fixme sessions |
|
| 36 | + foreach ($columns as $key => $column) { |
|
| 37 | + // fixme sessions |
|
| 35 | 38 | $query .= 'left outer join '. |
| 36 | 39 | Database::get_main_table(TABLE_MAIN_REPORTS_VALUES). |
| 37 | 40 | ' k'.$key. |
| 38 | 41 | ' on k'.$key.'.key_id = '.$column['kid']. |
| 39 | 42 | ' and k'.$key.'.user_id = u.user_id '; |
| 43 | + } |
|
| 40 | 44 | return $query; |
| 41 | 45 | } |
@@ -4,55 +4,55 @@ |
||
| 4 | 4 | require_once 'reports.lib.php'; |
| 5 | 5 | |
| 6 | 6 | $longopts = array( |
| 7 | - 'course:', |
|
| 8 | - 'tool:', |
|
| 9 | - 'ci:', |
|
| 10 | - 'cn:', |
|
| 11 | - 'sci:', |
|
| 12 | - 'scn:', |
|
| 13 | - 'ssci:', |
|
| 14 | - 'sscn:', |
|
| 15 | - 'link:', |
|
| 16 | - 'addValue', |
|
| 17 | - 'addKey', |
|
| 18 | - 'help', |
|
| 19 | - 'clearAll', |
|
| 20 | - 'score:', |
|
| 21 | - 'progress:', |
|
| 22 | - 'time:', |
|
| 23 | - 'attempt:', |
|
| 24 | - 'session:', |
|
| 25 | - 'attempt:', |
|
| 26 | - 'uid:', |
|
| 27 | - 'key:', |
|
| 28 | - 'addDBKeys', |
|
| 29 | - 'build'); |
|
| 7 | + 'course:', |
|
| 8 | + 'tool:', |
|
| 9 | + 'ci:', |
|
| 10 | + 'cn:', |
|
| 11 | + 'sci:', |
|
| 12 | + 'scn:', |
|
| 13 | + 'ssci:', |
|
| 14 | + 'sscn:', |
|
| 15 | + 'link:', |
|
| 16 | + 'addValue', |
|
| 17 | + 'addKey', |
|
| 18 | + 'help', |
|
| 19 | + 'clearAll', |
|
| 20 | + 'score:', |
|
| 21 | + 'progress:', |
|
| 22 | + 'time:', |
|
| 23 | + 'attempt:', |
|
| 24 | + 'session:', |
|
| 25 | + 'attempt:', |
|
| 26 | + 'uid:', |
|
| 27 | + 'key:', |
|
| 28 | + 'addDBKeys', |
|
| 29 | + 'build'); |
|
| 30 | 30 | |
| 31 | 31 | $options = getopt("", $longopts); |
| 32 | 32 | |
| 33 | 33 | echo "\n\n"; |
| 34 | 34 | |
| 35 | 35 | if (array_key_exists('help', $options)) |
| 36 | - echo "help message\n"; |
|
| 36 | + echo "help message\n"; |
|
| 37 | 37 | else if (array_key_exists('clearAll', $options)) { |
| 38 | - reports_clearAll(); |
|
| 38 | + reports_clearAll(); |
|
| 39 | 39 | } else if (array_key_exists('build', $options)) { |
| 40 | - reports_build(); |
|
| 40 | + reports_build(); |
|
| 41 | 41 | } else if (array_key_exists('addDBKeys', $options)) { |
| 42 | - reports_addDBKeys(); |
|
| 42 | + reports_addDBKeys(); |
|
| 43 | 43 | } else if (array_key_exists('addValue', $options)) { |
| 44 | - reports_addValue($options['key'], $options['session'], $options['uid'], |
|
| 45 | - $options['attempt'], $options['score'], |
|
| 46 | - $options['progress'], $options['time']); |
|
| 44 | + reports_addValue($options['key'], $options['session'], $options['uid'], |
|
| 45 | + $options['attempt'], $options['score'], |
|
| 46 | + $options['progress'], $options['time']); |
|
| 47 | 47 | } else if (array_key_exists('addKey', $options)) { |
| 48 | - echo reports_addKey($options['course'], $options['tool'], |
|
| 49 | - $options['ci'], $options['cn'], |
|
| 50 | - $options['sci'], $options['scn'], |
|
| 51 | - $options['ssci'], $options['sscn'], |
|
| 52 | - $options['link']); |
|
| 53 | - echo "\n"; |
|
| 48 | + echo reports_addKey($options['course'], $options['tool'], |
|
| 49 | + $options['ci'], $options['cn'], |
|
| 50 | + $options['sci'], $options['scn'], |
|
| 51 | + $options['ssci'], $options['sscn'], |
|
| 52 | + $options['link']); |
|
| 53 | + echo "\n"; |
|
| 54 | 54 | } else |
| 55 | - echo "action not found\n"; |
|
| 55 | + echo "action not found\n"; |
|
| 56 | 56 | |
| 57 | 57 | echo "\n"; |
| 58 | 58 | ?> |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | echo "\n\n"; |
| 34 | 34 | |
| 35 | -if (array_key_exists('help', $options)) |
|
| 35 | +if (array_key_exists('help', $options)) { |
|
| 36 | 36 | echo "help message\n"; |
| 37 | -else if (array_key_exists('clearAll', $options)) { |
|
| 37 | +} else if (array_key_exists('clearAll', $options)) { |
|
| 38 | 38 | reports_clearAll(); |
| 39 | 39 | } else if (array_key_exists('build', $options)) { |
| 40 | 40 | reports_build(); |
@@ -51,8 +51,9 @@ discard block |
||
| 51 | 51 | $options['ssci'], $options['sscn'], |
| 52 | 52 | $options['link']); |
| 53 | 53 | echo "\n"; |
| 54 | -} else |
|
| 54 | +} else { |
|
| 55 | 55 | echo "action not found\n"; |
| 56 | +} |
|
| 56 | 57 | |
| 57 | 58 | echo "\n"; |
| 58 | 59 | ?> |
@@ -34,21 +34,21 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | // "Link" type |
| 36 | 36 | if ($_REQUEST['format'] == 'link') { |
| 37 | - // converting post vars to get uri |
|
| 38 | - $params = ''; |
|
| 39 | - $kv = array(); |
|
| 40 | - foreach ($_POST as $key => $value) |
|
| 41 | - if ($key != 'format') |
|
| 42 | - $kv[] = $key.'='.urlencode($value); |
|
| 43 | - $query_string = join("&", $kv); |
|
| 44 | - die('<a href="reports.php?format=directlink&'.$query_string.'">'.get_lang('ReportTypeLink').'</a>'); |
|
| 37 | + // converting post vars to get uri |
|
| 38 | + $params = ''; |
|
| 39 | + $kv = array(); |
|
| 40 | + foreach ($_POST as $key => $value) |
|
| 41 | + if ($key != 'format') |
|
| 42 | + $kv[] = $key.'='.urlencode($value); |
|
| 43 | + $query_string = join("&", $kv); |
|
| 44 | + die('<a href="reports.php?format=directlink&'.$query_string.'">'.get_lang('ReportTypeLink').'</a>'); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | if ($_REQUEST['format'] == 'directlink') { |
| 48 | - foreach (array('jquery.dataTables.min.js') as $js) |
|
| 49 | - $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n"; |
|
| 48 | + foreach (array('jquery.dataTables.min.js') as $js) |
|
| 49 | + $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n"; |
|
| 50 | 50 | |
| 51 | - $htmlCSSXtra[] = 'dataTable.css'; |
|
| 51 | + $htmlCSSXtra[] = 'dataTable.css'; |
|
| 52 | 52 | |
| 53 | 53 | ?> |
| 54 | 54 | <script type="text/javascript"> |
@@ -63,62 +63,62 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | </script> |
| 65 | 65 | <?php |
| 66 | - Display::display_header($tool_name); |
|
| 67 | - echo '<div id="result" class="result">'; |
|
| 66 | + Display::display_header($tool_name); |
|
| 67 | + echo '<div id="result" class="result">'; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // outputing a link to csv file instead of outputing csv data directly |
| 71 | 71 | if ($_REQUEST['format'] == 'csv') { |
| 72 | - // converting post vars to get uri |
|
| 73 | - $params = ''; |
|
| 74 | - $kv = array(); |
|
| 75 | - foreach ($_POST as $key => $value) |
|
| 76 | - if ($key != 'format') |
|
| 77 | - $kv[] = $key.'='.urlencode($value); |
|
| 78 | - $query_string = join("&", $kv); |
|
| 79 | - die('<a href="reports.php?format=downloadcsv&'.$query_string.'">'.get_lang('DownloadFile').'</a>'); |
|
| 72 | + // converting post vars to get uri |
|
| 73 | + $params = ''; |
|
| 74 | + $kv = array(); |
|
| 75 | + foreach ($_POST as $key => $value) |
|
| 76 | + if ($key != 'format') |
|
| 77 | + $kv[] = $key.'='.urlencode($value); |
|
| 78 | + $query_string = join("&", $kv); |
|
| 79 | + die('<a href="reports.php?format=downloadcsv&'.$query_string.'">'.get_lang('DownloadFile').'</a>'); |
|
| 80 | 80 | } else if ($_REQUEST['format'] == 'downloadcsv') { |
| 81 | - if ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') == false)) { |
|
| 82 | - header("Pragma: must-revalidate"); |
|
| 83 | - header("Cache-Control: must-revalidate"); |
|
| 84 | - header("Content-type: application/vnd.ms-excel"); |
|
| 85 | - } |
|
| 86 | - else { |
|
| 87 | - header("Content-type: text/csv"); |
|
| 88 | - } |
|
| 89 | - $date = date("Y-m-d"); |
|
| 90 | - $filename = "reporting-$date.csv"; |
|
| 91 | - header("Content-Disposition: attachment; filename=$filename"); |
|
| 92 | - $_REQUEST['format'] = 'csv'; |
|
| 81 | + if ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') == false)) { |
|
| 82 | + header("Pragma: must-revalidate"); |
|
| 83 | + header("Cache-Control: must-revalidate"); |
|
| 84 | + header("Content-type: application/vnd.ms-excel"); |
|
| 85 | + } |
|
| 86 | + else { |
|
| 87 | + header("Content-type: text/csv"); |
|
| 88 | + } |
|
| 89 | + $date = date("Y-m-d"); |
|
| 90 | + $filename = "reporting-$date.csv"; |
|
| 91 | + header("Content-Disposition: attachment; filename=$filename"); |
|
| 92 | + $_REQUEST['format'] = 'csv'; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | |
| 97 | 97 | if (is_array($reports_template[$_REQUEST['type']])) { |
| 98 | - $query = $reports_template[$_REQUEST['type']]['getSQL'](); |
|
| 99 | - if (! is_array($query)) |
|
| 100 | - $query = array($query); |
|
| 101 | - if ($_REQUEST['format'] == 'sql') |
|
| 102 | - die(var_export($query, true)); |
|
| 98 | + $query = $reports_template[$_REQUEST['type']]['getSQL'](); |
|
| 99 | + if (! is_array($query)) |
|
| 100 | + $query = array($query); |
|
| 101 | + if ($_REQUEST['format'] == 'sql') |
|
| 102 | + die(var_export($query, true)); |
|
| 103 | 103 | |
| 104 | - $result = multiquery_query($query); |
|
| 104 | + $result = multiquery_query($query); |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | - // check number of result |
|
| 108 | - $numberOfResult = multiquery_num_rows($result); |
|
| 109 | - if ($numberOfResult == 0) { |
|
| 110 | - // This case should be taken care of by the display template itself, we should let the script run |
|
| 111 | - //die(get_lang('NoDataAvailable')); |
|
| 112 | - } |
|
| 107 | + // check number of result |
|
| 108 | + $numberOfResult = multiquery_num_rows($result); |
|
| 109 | + if ($numberOfResult == 0) { |
|
| 110 | + // This case should be taken care of by the display template itself, we should let the script run |
|
| 111 | + //die(get_lang('NoDataAvailable')); |
|
| 112 | + } |
|
| 113 | 113 | } else { |
| 114 | - die('<b>'.get_lang('ErrorWhileBuildingReport').'</b>'); |
|
| 114 | + die('<b>'.get_lang('ErrorWhileBuildingReport').'</b>'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') { |
| 118 | - if (isset($reports_template[$_REQUEST['type']]['html_header'])) { |
|
| 119 | - echo $reports_template[$_REQUEST['type']]['html_header']; |
|
| 120 | - } |
|
| 121 | - echo '<script type="text/javascript" charset="utf-8"> |
|
| 118 | + if (isset($reports_template[$_REQUEST['type']]['html_header'])) { |
|
| 119 | + echo $reports_template[$_REQUEST['type']]['html_header']; |
|
| 120 | + } |
|
| 121 | + echo '<script type="text/javascript" charset="utf-8"> |
|
| 122 | 122 | $(document).ready(function() { |
| 123 | 123 | |
| 124 | 124 | $("#reportsData'.$idsuffix.'").dataTable({ |
@@ -143,50 +143,50 @@ discard block |
||
| 143 | 143 | }); |
| 144 | 144 | } ); |
| 145 | 145 | </script>'; |
| 146 | - echo '<table id="reportsData'.$idsuffix.'" class="display">'; // FIXME style |
|
| 147 | - |
|
| 148 | - // counting fields |
|
| 149 | - $nfields = multiquery_num_fields($result); |
|
| 150 | - $columns = array(); |
|
| 151 | - $columns_islink = array(); |
|
| 152 | - echo '<thead><tr>'; |
|
| 153 | - for ($i=0; $i < $nfields; $i++) { |
|
| 154 | - $columns[$i] = multiquery_field_name($result, $i); |
|
| 155 | - if (substr($columns[$i], -5, 5) != '_link') { |
|
| 156 | - $column_islink[$i] = false; |
|
| 157 | - echo '<th>'.$columns[$i].'</th>'; |
|
| 158 | - } else |
|
| 159 | - $columns_islink[$i] = true; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - // checking resolving link column id |
|
| 163 | - $columns_flip = array_flip($columns); |
|
| 164 | - $columns_link = array(); |
|
| 165 | - for ($i=0; $i < $nfields; $i++) |
|
| 166 | - if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip)) |
|
| 167 | - $columns_link[$i] = $columns_flip[$columns[$i].'_link']; |
|
| 168 | - else |
|
| 169 | - $columns_link[$i] = ''; |
|
| 170 | - echo '</tr></thead><tbody>'; |
|
| 171 | - while ($row = multiquery_fetch_row($result)) { |
|
| 172 | - echo '<tr>'; |
|
| 173 | - for ($i = 0; $i<$nfields; $i++) |
|
| 174 | - if (!$columns_islink[$i]){ // ignore links |
|
| 175 | - if ($columns_link[$i] != '') // link is defined |
|
| 176 | - if (substr($columns_link[$i],0,10) == 'javascript') { |
|
| 177 | - echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
|
| 178 | - } |
|
| 179 | - else { |
|
| 180 | - echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
|
| 181 | - } |
|
| 182 | - else |
|
| 183 | - echo '<td>'.$row[$i].'</td>'; |
|
| 184 | - } |
|
| 185 | - echo "</tr>\n"; |
|
| 186 | - } |
|
| 187 | - echo '</tbody></table>'; |
|
| 188 | - if ($_REQUEST['format'] == 'directlink') { |
|
| 189 | - echo '</div> |
|
| 146 | + echo '<table id="reportsData'.$idsuffix.'" class="display">'; // FIXME style |
|
| 147 | + |
|
| 148 | + // counting fields |
|
| 149 | + $nfields = multiquery_num_fields($result); |
|
| 150 | + $columns = array(); |
|
| 151 | + $columns_islink = array(); |
|
| 152 | + echo '<thead><tr>'; |
|
| 153 | + for ($i=0; $i < $nfields; $i++) { |
|
| 154 | + $columns[$i] = multiquery_field_name($result, $i); |
|
| 155 | + if (substr($columns[$i], -5, 5) != '_link') { |
|
| 156 | + $column_islink[$i] = false; |
|
| 157 | + echo '<th>'.$columns[$i].'</th>'; |
|
| 158 | + } else |
|
| 159 | + $columns_islink[$i] = true; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + // checking resolving link column id |
|
| 163 | + $columns_flip = array_flip($columns); |
|
| 164 | + $columns_link = array(); |
|
| 165 | + for ($i=0; $i < $nfields; $i++) |
|
| 166 | + if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip)) |
|
| 167 | + $columns_link[$i] = $columns_flip[$columns[$i].'_link']; |
|
| 168 | + else |
|
| 169 | + $columns_link[$i] = ''; |
|
| 170 | + echo '</tr></thead><tbody>'; |
|
| 171 | + while ($row = multiquery_fetch_row($result)) { |
|
| 172 | + echo '<tr>'; |
|
| 173 | + for ($i = 0; $i<$nfields; $i++) |
|
| 174 | + if (!$columns_islink[$i]){ // ignore links |
|
| 175 | + if ($columns_link[$i] != '') // link is defined |
|
| 176 | + if (substr($columns_link[$i],0,10) == 'javascript') { |
|
| 177 | + echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
|
| 178 | + } |
|
| 179 | + else { |
|
| 180 | + echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
|
| 181 | + } |
|
| 182 | + else |
|
| 183 | + echo '<td>'.$row[$i].'</td>'; |
|
| 184 | + } |
|
| 185 | + echo "</tr>\n"; |
|
| 186 | + } |
|
| 187 | + echo '</tbody></table>'; |
|
| 188 | + if ($_REQUEST['format'] == 'directlink') { |
|
| 189 | + echo '</div> |
|
| 190 | 190 | <div id="result2" class="result" style="margin: 50px;"> |
| 191 | 191 | </div> |
| 192 | 192 | <div id="result3" class="result" style="margin: 100px;"> |
@@ -194,36 +194,36 @@ discard block |
||
| 194 | 194 | <div id="result4" class="result" style="margin: 150px;"> |
| 195 | 195 | </div>'; |
| 196 | 196 | |
| 197 | - Display::display_footer(); |
|
| 197 | + Display::display_footer(); |
|
| 198 | 198 | |
| 199 | - } |
|
| 199 | + } |
|
| 200 | 200 | } else if ($_REQUEST['format'] == 'csv') { |
| 201 | - $nfields = multiquery_num_fields($result); |
|
| 202 | - $columns = array(); |
|
| 203 | - $columns_islink = array(); |
|
| 204 | - for ($i=0; $i < $nfields; $i++) { |
|
| 205 | - $columns[$i] = multiquery_field_name($result, $i); |
|
| 206 | - if (substr($columns[$i], -5, 5) != '_link') { |
|
| 207 | - $column_islink[$i] = false; |
|
| 208 | - echo csv_escaping($columns[$i]).','; |
|
| 209 | - } else |
|
| 210 | - $columns_islink[$i] = true; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - echo "\n"; |
|
| 214 | - while ($row = multiquery_fetch_row($result)) { |
|
| 215 | - for ($i = 0; $i<$nfields; $i++) |
|
| 216 | - if (!$columns_islink[$i]) // ignore links |
|
| 217 | - echo csv_escaping($row[$i]).','; // fixme |
|
| 218 | - echo "\n"; |
|
| 219 | - } |
|
| 201 | + $nfields = multiquery_num_fields($result); |
|
| 202 | + $columns = array(); |
|
| 203 | + $columns_islink = array(); |
|
| 204 | + for ($i=0; $i < $nfields; $i++) { |
|
| 205 | + $columns[$i] = multiquery_field_name($result, $i); |
|
| 206 | + if (substr($columns[$i], -5, 5) != '_link') { |
|
| 207 | + $column_islink[$i] = false; |
|
| 208 | + echo csv_escaping($columns[$i]).','; |
|
| 209 | + } else |
|
| 210 | + $columns_islink[$i] = true; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + echo "\n"; |
|
| 214 | + while ($row = multiquery_fetch_row($result)) { |
|
| 215 | + for ($i = 0; $i<$nfields; $i++) |
|
| 216 | + if (!$columns_islink[$i]) // ignore links |
|
| 217 | + echo csv_escaping($row[$i]).','; // fixme |
|
| 218 | + echo "\n"; |
|
| 219 | + } |
|
| 220 | 220 | } else die(get_lang('UnknownFormat')); |
| 221 | 221 | |
| 222 | 222 | function csv_escaping($value, $csv_separator = ',') { |
| 223 | - $value = str_replace('"','""',$value); |
|
| 224 | - if (strpos($value, '""') or strpos($value, $csv_separator) or $value != trim($value) ) { |
|
| 225 | - $value = '"'.$value.'"'; |
|
| 226 | - } |
|
| 227 | - return $value; |
|
| 223 | + $value = str_replace('"','""',$value); |
|
| 224 | + if (strpos($value, '""') or strpos($value, $csv_separator) or $value != trim($value) ) { |
|
| 225 | + $value = '"'.$value.'"'; |
|
| 226 | + } |
|
| 227 | + return $value; |
|
| 228 | 228 | } |
| 229 | 229 | ?> |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $this_section = SECTION_REPORTS; |
| 25 | 25 | |
| 26 | 26 | // setting the name of the tool |
| 27 | -$tool_name=get_lang('Reports'); |
|
| 27 | +$tool_name = get_lang('Reports'); |
|
| 28 | 28 | |
| 29 | 29 | // loading templates |
| 30 | 30 | reports_loadTemplates(); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // outputing a link to csv file instead of outputing csv data directly |
| 71 | -if ($_REQUEST['format'] == 'csv') { |
|
| 71 | +if ($_REQUEST['format'] == 'csv') { |
|
| 72 | 72 | // converting post vars to get uri |
| 73 | 73 | $params = ''; |
| 74 | 74 | $kv = array(); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | if (is_array($reports_template[$_REQUEST['type']])) { |
| 98 | 98 | $query = $reports_template[$_REQUEST['type']]['getSQL'](); |
| 99 | - if (! is_array($query)) |
|
| 99 | + if (!is_array($query)) |
|
| 100 | 100 | $query = array($query); |
| 101 | 101 | if ($_REQUEST['format'] == 'sql') |
| 102 | 102 | die(var_export($query, true)); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $columns = array(); |
| 151 | 151 | $columns_islink = array(); |
| 152 | 152 | echo '<thead><tr>'; |
| 153 | - for ($i=0; $i < $nfields; $i++) { |
|
| 153 | + for ($i = 0; $i < $nfields; $i++) { |
|
| 154 | 154 | $columns[$i] = multiquery_field_name($result, $i); |
| 155 | 155 | if (substr($columns[$i], -5, 5) != '_link') { |
| 156 | 156 | $column_islink[$i] = false; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | // checking resolving link column id |
| 163 | 163 | $columns_flip = array_flip($columns); |
| 164 | 164 | $columns_link = array(); |
| 165 | - for ($i=0; $i < $nfields; $i++) |
|
| 165 | + for ($i = 0; $i < $nfields; $i++) |
|
| 166 | 166 | if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip)) |
| 167 | 167 | $columns_link[$i] = $columns_flip[$columns[$i].'_link']; |
| 168 | 168 | else |
@@ -170,10 +170,10 @@ discard block |
||
| 170 | 170 | echo '</tr></thead><tbody>'; |
| 171 | 171 | while ($row = multiquery_fetch_row($result)) { |
| 172 | 172 | echo '<tr>'; |
| 173 | - for ($i = 0; $i<$nfields; $i++) |
|
| 174 | - if (!$columns_islink[$i]){ // ignore links |
|
| 173 | + for ($i = 0; $i < $nfields; $i++) |
|
| 174 | + if (!$columns_islink[$i]) { // ignore links |
|
| 175 | 175 | if ($columns_link[$i] != '') // link is defined |
| 176 | - if (substr($columns_link[$i],0,10) == 'javascript') { |
|
| 176 | + if (substr($columns_link[$i], 0, 10) == 'javascript') { |
|
| 177 | 177 | echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
| 178 | 178 | } |
| 179 | 179 | else { |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $nfields = multiquery_num_fields($result); |
| 202 | 202 | $columns = array(); |
| 203 | 203 | $columns_islink = array(); |
| 204 | - for ($i=0; $i < $nfields; $i++) { |
|
| 204 | + for ($i = 0; $i < $nfields; $i++) { |
|
| 205 | 205 | $columns[$i] = multiquery_field_name($result, $i); |
| 206 | 206 | if (substr($columns[$i], -5, 5) != '_link') { |
| 207 | 207 | $column_islink[$i] = false; |
@@ -212,16 +212,16 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | echo "\n"; |
| 214 | 214 | while ($row = multiquery_fetch_row($result)) { |
| 215 | - for ($i = 0; $i<$nfields; $i++) |
|
| 215 | + for ($i = 0; $i < $nfields; $i++) |
|
| 216 | 216 | if (!$columns_islink[$i]) // ignore links |
| 217 | - echo csv_escaping($row[$i]).','; // fixme |
|
| 217 | + echo csv_escaping($row[$i]).','; // fixme |
|
| 218 | 218 | echo "\n"; |
| 219 | 219 | } |
| 220 | 220 | } else die(get_lang('UnknownFormat')); |
| 221 | 221 | |
| 222 | 222 | function csv_escaping($value, $csv_separator = ',') { |
| 223 | - $value = str_replace('"','""',$value); |
|
| 224 | - if (strpos($value, '""') or strpos($value, $csv_separator) or $value != trim($value) ) { |
|
| 223 | + $value = str_replace('"', '""', $value); |
|
| 224 | + if (strpos($value, '""') or strpos($value, $csv_separator) or $value != trim($value)) { |
|
| 225 | 225 | $value = '"'.$value.'"'; |
| 226 | 226 | } |
| 227 | 227 | return $value; |
@@ -37,16 +37,18 @@ discard block |
||
| 37 | 37 | // converting post vars to get uri |
| 38 | 38 | $params = ''; |
| 39 | 39 | $kv = array(); |
| 40 | - foreach ($_POST as $key => $value) |
|
| 41 | - if ($key != 'format') |
|
| 40 | + foreach ($_POST as $key => $value) { |
|
| 41 | + if ($key != 'format') |
|
| 42 | 42 | $kv[] = $key.'='.urlencode($value); |
| 43 | + } |
|
| 43 | 44 | $query_string = join("&", $kv); |
| 44 | 45 | die('<a href="reports.php?format=directlink&'.$query_string.'">'.get_lang('ReportTypeLink').'</a>'); |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | if ($_REQUEST['format'] == 'directlink') { |
| 48 | - foreach (array('jquery.dataTables.min.js') as $js) |
|
| 49 | - $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n"; |
|
| 49 | + foreach (array('jquery.dataTables.min.js') as $js) { |
|
| 50 | + $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n"; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | $htmlCSSXtra[] = 'dataTable.css'; |
| 52 | 54 | |
@@ -72,9 +74,10 @@ discard block |
||
| 72 | 74 | // converting post vars to get uri |
| 73 | 75 | $params = ''; |
| 74 | 76 | $kv = array(); |
| 75 | - foreach ($_POST as $key => $value) |
|
| 76 | - if ($key != 'format') |
|
| 77 | + foreach ($_POST as $key => $value) { |
|
| 78 | + if ($key != 'format') |
|
| 77 | 79 | $kv[] = $key.'='.urlencode($value); |
| 80 | + } |
|
| 78 | 81 | $query_string = join("&", $kv); |
| 79 | 82 | die('<a href="reports.php?format=downloadcsv&'.$query_string.'">'.get_lang('DownloadFile').'</a>'); |
| 80 | 83 | } else if ($_REQUEST['format'] == 'downloadcsv') { |
@@ -82,8 +85,7 @@ discard block |
||
| 82 | 85 | header("Pragma: must-revalidate"); |
| 83 | 86 | header("Cache-Control: must-revalidate"); |
| 84 | 87 | header("Content-type: application/vnd.ms-excel"); |
| 85 | - } |
|
| 86 | - else { |
|
| 88 | + } else { |
|
| 87 | 89 | header("Content-type: text/csv"); |
| 88 | 90 | } |
| 89 | 91 | $date = date("Y-m-d"); |
@@ -96,10 +98,12 @@ discard block |
||
| 96 | 98 | |
| 97 | 99 | if (is_array($reports_template[$_REQUEST['type']])) { |
| 98 | 100 | $query = $reports_template[$_REQUEST['type']]['getSQL'](); |
| 99 | - if (! is_array($query)) |
|
| 100 | - $query = array($query); |
|
| 101 | - if ($_REQUEST['format'] == 'sql') |
|
| 102 | - die(var_export($query, true)); |
|
| 101 | + if (! is_array($query)) { |
|
| 102 | + $query = array($query); |
|
| 103 | + } |
|
| 104 | + if ($_REQUEST['format'] == 'sql') { |
|
| 105 | + die(var_export($query, true)); |
|
| 106 | + } |
|
| 103 | 107 | |
| 104 | 108 | $result = multiquery_query($query); |
| 105 | 109 | |
@@ -155,32 +159,35 @@ discard block |
||
| 155 | 159 | if (substr($columns[$i], -5, 5) != '_link') { |
| 156 | 160 | $column_islink[$i] = false; |
| 157 | 161 | echo '<th>'.$columns[$i].'</th>'; |
| 158 | - } else |
|
| 159 | - $columns_islink[$i] = true; |
|
| 162 | + } else { |
|
| 163 | + $columns_islink[$i] = true; |
|
| 164 | + } |
|
| 160 | 165 | } |
| 161 | 166 | |
| 162 | 167 | // checking resolving link column id |
| 163 | 168 | $columns_flip = array_flip($columns); |
| 164 | 169 | $columns_link = array(); |
| 165 | - for ($i=0; $i < $nfields; $i++) |
|
| 166 | - if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip)) |
|
| 170 | + for ($i=0; $i < $nfields; $i++) { |
|
| 171 | + if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip)) |
|
| 167 | 172 | $columns_link[$i] = $columns_flip[$columns[$i].'_link']; |
| 168 | - else |
|
| 169 | - $columns_link[$i] = ''; |
|
| 173 | + } |
|
| 174 | + else { |
|
| 175 | + $columns_link[$i] = ''; |
|
| 176 | + } |
|
| 170 | 177 | echo '</tr></thead><tbody>'; |
| 171 | 178 | while ($row = multiquery_fetch_row($result)) { |
| 172 | 179 | echo '<tr>'; |
| 173 | - for ($i = 0; $i<$nfields; $i++) |
|
| 174 | - if (!$columns_islink[$i]){ // ignore links |
|
| 180 | + for ($i = 0; $i<$nfields; $i++) { |
|
| 181 | + if (!$columns_islink[$i]){ // ignore links |
|
| 175 | 182 | if ($columns_link[$i] != '') // link is defined |
| 176 | 183 | if (substr($columns_link[$i],0,10) == 'javascript') { |
| 177 | 184 | echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
| 178 | - } |
|
| 179 | - else { |
|
| 185 | + } |
|
| 186 | + } else { |
|
| 180 | 187 | echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
| 181 | - } |
|
| 182 | - else |
|
| 183 | - echo '<td>'.$row[$i].'</td>'; |
|
| 188 | + } else { |
|
| 189 | + echo '<td>'.$row[$i].'</td>'; |
|
| 190 | + } |
|
| 184 | 191 | } |
| 185 | 192 | echo "</tr>\n"; |
| 186 | 193 | } |
@@ -206,18 +213,23 @@ discard block |
||
| 206 | 213 | if (substr($columns[$i], -5, 5) != '_link') { |
| 207 | 214 | $column_islink[$i] = false; |
| 208 | 215 | echo csv_escaping($columns[$i]).','; |
| 209 | - } else |
|
| 210 | - $columns_islink[$i] = true; |
|
| 216 | + } else { |
|
| 217 | + $columns_islink[$i] = true; |
|
| 218 | + } |
|
| 211 | 219 | } |
| 212 | 220 | |
| 213 | 221 | echo "\n"; |
| 214 | 222 | while ($row = multiquery_fetch_row($result)) { |
| 215 | - for ($i = 0; $i<$nfields; $i++) |
|
| 216 | - if (!$columns_islink[$i]) // ignore links |
|
| 217 | - echo csv_escaping($row[$i]).','; // fixme |
|
| 223 | + for ($i = 0; $i<$nfields; $i++) { |
|
| 224 | + if (!$columns_islink[$i]) // ignore links |
|
| 225 | + echo csv_escaping($row[$i]).','; |
|
| 226 | + } |
|
| 227 | + // fixme |
|
| 218 | 228 | echo "\n"; |
| 219 | 229 | } |
| 220 | -} else die(get_lang('UnknownFormat')); |
|
| 230 | +} else { |
|
| 231 | + die(get_lang('UnknownFormat')); |
|
| 232 | +} |
|
| 221 | 233 | |
| 222 | 234 | function csv_escaping($value, $csv_separator = ',') { |
| 223 | 235 | $value = str_replace('"','""',$value); |