123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782 |
- <?php
- $TABLETRACK_LOGIN = $_configuration['statistics_database'].".track_e_login";
- $TABLETRACK_OPEN = $_configuration['statistics_database'].".track_e_open";
- $TABLETRACK_ACCESS = $_configuration['statistics_database'].".track_e_access";
- $TABLETRACK_DOWNLOADS = $_configuration['statistics_database'].".track_e_downloads";
- $TABLETRACK_UPLOADS = $_configuration['statistics_database'].".track_e_uploads";
- $TABLETRACK_LINKS = $_configuration['statistics_database'].".track_e_links";
- $TABLETRACK_EXERCICES = $_configuration['statistics_database'].".track_e_exercices";
- $TABLETRACK_SUBSCRIPTIONS = $_configuration['statistics_database'].".track_e_subscriptions";
- $TABLETRACK_LASTACCESS = $_configuration['statistics_database'].".track_e_lastaccess";
- $TABLETRACK_DEFAULT = $_configuration['statistics_database'].".track_e_default";
- function event_open() {
- global $_configuration;
- global $TABLETRACK_OPEN;
-
- if (!$_configuration['tracking_enabled']) {
- return 0;
- }
-
-
-
- if(isset($_SERVER['HTT_REFERER']))
- {
- $referer = Database::escape_string($_SERVER['HTTP_REFERER']);
- } else {
- $referer = '';
- }
-
-
- $pos = strpos($referer, $_configuration['root_web']);
- if ($pos === false && $referer != '') {
- $remhost = @ getHostByAddr($_SERVER['REMOTE_ADDR']);
- if ($remhost == $_SERVER['REMOTE_ADDR'])
- $remhost = "Unknown";
- $reallyNow = api_get_utc_datetime();
- $sql = "INSERT INTO ".$TABLETRACK_OPEN."
- (open_remote_host,
- open_agent,
- open_referer,
- open_date)
- VALUES
- ('".$remhost."',
- '".Database::escape_string($_SERVER['HTTP_USER_AGENT'])."', '".Database::escape_string($referer)."', '$reallyNow')";
- $res = Database::query($sql);
- }
- return 1;
- }
- function event_login() {
- global $_configuration;
- global $_user;
- global $TABLETRACK_LOGIN;
-
- if (!$_configuration['tracking_enabled']) {
- return 0;
- }
- $reallyNow = api_get_utc_datetime();
- $sql = "INSERT INTO ".$TABLETRACK_LOGIN." (login_user_id, login_ip, login_date, logout_date)
- VALUES ('".$_user['user_id']."',
- '".Database::escape_string($_SERVER['REMOTE_ADDR'])."',
- '".$reallyNow."',
- '".$reallyNow."'
- )";
- $res = Database::query($sql);
- }
- function event_access_course() {
- global $_configuration;
- global $_user;
- global $_cid;
- global $TABLETRACK_ACCESS;
- global $TABLETRACK_LASTACCESS;
-
- if (!$_configuration['tracking_enabled']){
- return 0;
- }
- $id_session = api_get_session_id();
- $reallyNow = api_get_utc_datetime();
- if ($_user['user_id']) {
- $user_id = "'".$_user['user_id']."'";
- } else {
- $user_id = "0";
- }
- $sql = "INSERT INTO ".$TABLETRACK_ACCESS."
- (access_user_id,
- access_cours_code,
- access_date,
- access_session_id)
- VALUES
- (".$user_id.",
- '".$_cid."',
- '".$reallyNow."',
- '".$id_session."')";
- $res = Database::query($sql);
-
- $sql = "UPDATE $TABLETRACK_LASTACCESS
- SET access_date = '$reallyNow'
- WHERE access_user_id = $user_id AND access_cours_code = '$_cid' AND access_tool IS NULL AND access_session_id=".$id_session;
- $res = Database::query($sql);
- if (Database::affected_rows() == 0) {
- $sql = "INSERT INTO $TABLETRACK_LASTACCESS (access_user_id, access_cours_code, access_date, access_session_id)
- VALUES (".$user_id.", '".$_cid."', '$reallyNow', '".$id_session."')";
- $res = Database::query($sql);
- }
-
- return 1;
- }
- function event_access_tool($tool, $id_session=0) {
- global $_configuration;
-
-
- global $_user;
- global $_cid;
- global $TABLETRACK_ACCESS;
- global $_configuration;
- global $_course;
- global $TABLETRACK_LASTACCESS;
-
- $id_session = api_get_session_id();
- $tool = Database::escape_string($tool);
- $reallyNow = api_get_utc_datetime();
- $user_id = $_user['user_id'] ? "'".$_user['user_id']."'" : "0";
-
-
-
-
- $pos = strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower(api_get_path(WEB_COURSE_PATH).$_course['path']));
-
- $pos2 = strpos(strtolower($_SERVER['HTTP_REFERER']), strtolower($_configuration['root_web']."index"));
-
- if ($_configuration['tracking_enabled'] && ($pos !== false || $pos2 !== false)) {
- $sql = "INSERT INTO ".$TABLETRACK_ACCESS."
- (access_user_id,
- access_cours_code,
- access_tool,
- access_date,
- access_session_id
- )
- VALUES
- (".$user_id.",".
- "'".$_cid."' ,
- '".$tool."',
- '".$reallyNow."',
- '".$id_session."')";
- $res = Database::query($sql);
- }
-
- $sql = "UPDATE $TABLETRACK_LASTACCESS
- SET access_date = '$reallyNow'
- WHERE access_user_id = ".$user_id." AND access_cours_code = '".$_cid."' AND access_tool = '".$tool."' AND access_session_id=".$id_session;
- $res = Database::query($sql);
- if (Database::affected_rows() == 0) {
- $sql = "INSERT INTO $TABLETRACK_LASTACCESS (access_user_id,access_cours_code,access_tool, access_date, access_session_id)
- VALUES (".$user_id.", '".$_cid."' , '$tool', '$reallyNow', $id_session)";
- $res = Database::query($sql);
- }
- return 1;
- }
- function event_download($doc_url) {
- global $_configuration, $_user, $_cid;
- $tbl_stats_downloads = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
-
- if (!$_configuration['tracking_enabled']) {
- return 0;
- }
- $doc_url = Database::escape_string($doc_url);
- $reallyNow = api_get_utc_datetime();
- if ($_user['user_id']) {
- $user_id = "'".$_user['user_id']."'";
- } else {
- $user_id = "0";
- }
- $sql = "INSERT INTO $tbl_stats_downloads (
- down_user_id,
- down_cours_id,
- down_doc_path,
- down_date,
- down_session_id
- )
- VALUES (
- ".$user_id.",
- '".$_cid."',
- '".$doc_url."',
- '".$reallyNow."',
- '".api_get_session_id()."'
- )";
- $res = Database::query($sql);
- return 1;
- }
- function event_upload($doc_id) {
- global $_configuration;
- global $_user;
- global $_cid;
- global $TABLETRACK_UPLOADS;
-
- if (!$_configuration['tracking_enabled']) {
- return 0;
- }
- $reallyNow = api_get_utc_datetime();
- if (isset($_user['user_id']) && $_user['user_id']!='') {
- $user_id = "'".$_user['user_id']."'";
- } else {
- $user_id = "0";
- }
- $sql = "INSERT INTO ".$TABLETRACK_UPLOADS."
- ( upload_user_id,
- upload_cours_id,
- upload_work_id,
- upload_date,
- upload_session_id
- )
- VALUES (
- ".$user_id.",
- '".$_cid."',
- '".$doc_id."',
- '".$reallyNow."',
- '".api_get_session_id()."'
- )";
- $res = Database::query($sql);
- return 1;
- }
- function event_link($link_id) {
- global $_configuration, $_user, $TABLETRACK_LINKS;
-
- if (!$_configuration['tracking_enabled']) {
- return 0;
- }
- $reallyNow = api_get_utc_datetime();
- if (isset($_user['user_id']) && $_user['user_id']!='') {
- $user_id = "'".Database::escape_string($_user['user_id'])."'";
- } else {
-
- $user_id = "0";
- }
- $sql = "INSERT INTO ".$TABLETRACK_LINKS."
- ( links_user_id,
- links_cours_id,
- links_link_id,
- links_date,
- links_session_id
- ) VALUES (
- ".$user_id.",
- '".api_get_course_id()."',
- '".Database::escape_string($link_id)."',
- '".$reallyNow."',
- '".api_get_session_id()."'
- )";
- $res = Database::query($sql);
- return 1;
- }
- function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$learnpath_id=0, $learnpath_item_id=0, $learnpath_item_view_id = 0, $duration) {
- if ($exeid!='') {
-
-
- if (!exercise_time_control_is_valid($exo_id)) {
- $score = 0;
- }
- $now = time();
-
- if (isset($_SESSION['exercice_start_date'])) {
- $start_date = $_SESSION['exercice_start_date'];
- $diff = abs($start_date - $now);
- if ($diff > 14400) {
- $start_date = $now - 1800;
- }
- }
- $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $sql = "UPDATE $TABLETRACK_EXERCICES SET
- exe_exo_id = '".Database::escape_string($exo_id)."',
- exe_result = '".Database::escape_string($score)."',
- exe_weighting = '".Database::escape_string($weighting)."',
- session_id = '".Database::escape_string($session_id)."',
- orig_lp_id = '".Database::escape_string($learnpath_id)."',
- orig_lp_item_id = '".Database::escape_string($learnpath_item_id)."',
- orig_lp_item_view_id = '".Database::escape_string($learnpath_item_view_id)."',
- exe_duration = '".Database::escape_string($duration)."',
- exe_date = '".api_get_utc_datetime()."',
- status = '',
- start_date = '".api_get_utc_datetime($start_date)."'
- WHERE exe_id = '".Database::escape_string($exeid)."'";
- $res = @Database::query($sql);
-
-
- exercise_time_control_delete($exo_id);
- error_log('update_event_exercice');
- error_log($sql);
- return $res;
-
- } else
- return false;
- }
- function create_event_exercice($exo_id) {
- global $_user, $_configuration;
- error_log('create_event_exercice');
- $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
- $reallyNow = time();
- if (isset($_user['user_id']) && $_user['user_id']!='') {
- $user_id = "'".$_user['user_id']."'";
- } else {
-
- $user_id = "0";
- }
-
- if(defined('ENABLED_LIVE_EXERCISE_TRACKING')){
- $condition = ' WHERE ' .
- 'exe_exo_id = '."'".Database::escape_string($exo_id)."'".' AND ' .
- 'exe_user_id = '."'".api_get_user_id()."'".' AND ' .
- 'exe_cours_id = '."'".api_get_course_id()."'".' AND ' .
- 'status = '."'incomplete'".' AND '.
- 'session_id = '."'".api_get_session_id()."'";
- $sql = Database::query('SELECT exe_id FROM '.$TABLETRACK_EXERCICES.$condition);
- $row = Database::fetch_array($sql);
- return $row['exe_id'];
- }
-
- $sql_exe_id='SELECT exercises.id FROM '.$TBL_EXERCICES.' as exercises, '.$TABLETRACK_EXERCICES.' as track_exercises WHERE exercises.id=track_exercises.exe_exo_id AND track_exercises.exe_id="'.Database::escape_string($exo_id).'"';
- $res_exe_id=Database::query($sql_exe_id);
- $row_exe_id=Database::fetch_row($res_exe_id);
- $exercise_id = intval($row_exe_id[0]);
-
- $current_expired_time_key = get_time_control_key($exercise_id);
- if (isset($_SESSION['expired_time'][$current_expired_time_key])) {
- $expired_date = $_SESSION['expired_time'][$current_expired_time_key];
- } else {
- $expired_date = '0000-00-00 00:00:00';
- }
- $sql = "INSERT INTO $TABLETRACK_EXERCICES ( exe_user_id, exe_cours_id, expired_time_control, exe_exo_id, session_id)
- VALUES ( ".$user_id.", '".api_get_course_id()."' ,'".$expired_date."','".$exo_id."','".api_get_session_id()."')";
- $res = Database::query($sql);
- $id= Database::insert_id();
- return $id;
- }
- function exercise_attempt($score, $answer, $quesId, $exeId, $j, $exercise_id = 0) {
- global $_configuration;
-
- if (!$_configuration['tracking_enabled']) {
- return 0;
- }
- $score = Database::escape_string($score);
- $answer = Database::escape_string($answer);
- $quesId = Database::escape_string($quesId);
- $exeId = Database::escape_string($exeId);
- $j = Database::escape_string($j);
-
- $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
-
-
- if (!exercise_time_control_is_valid($exercise_id)) {
- $score = 0;
- $answer = 0;
- $j = 0;
- }
- $reallyNow = api_get_utc_datetime();
- $user_id = api_get_user_id();
- if (!empty($user_id)) {
- $user_id = "'".$user_id."'";
- } else {
-
- $user_id = api_get_anonymous_id();
- }
-
- $sql = "INSERT INTO $TBL_TRACK_ATTEMPT (exe_id, user_id, question_id, answer, marks, course_code, position, tms )
- VALUES (
- ".$exeId.",
- ".$user_id.",
- '".$quesId."',
- '".$answer."',
- '".$score."',
- '".api_get_course_id()."',
- '".$j."',
- '".$reallyNow."'
- )";
- error_log($sql);
- if (!empty($quesId) && !empty($exeId) && !empty($user_id)) {
- $res = Database::query($sql);
- if (defined('ENABLED_LIVE_EXERCISE_TRACKING')){
- $TBL_RECORDING = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
- $recording_changes = "INSERT INTO $TBL_RECORDING (exe_id, question_id, marks, insert_date, author) VALUES ('$exeId','$quesId','$score','".api_get_utc_datetime()."','') ";
- Database::query($recording_changes);
- }
- return $res;
- } else {
- return false;
- }
- }
- function exercise_attempt_hotspot($exe_id, $question_id, $answer_id, $correct, $coords, $exerciseId = 0) {
- global $_configuration, $_user;
-
- if (!$_configuration['tracking_enabled']) {
- return 0;
- }
-
- if (!exercise_time_control_is_valid($exerciseId)) {
- $correct = 0;
- }
- $tbl_track_e_hotspot = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
- $sql = "INSERT INTO $tbl_track_e_hotspot " .
- "(hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate)".
- " VALUES ('" . Database :: escape_string($_user['user_id']) . "'," .
- " '" . api_get_course_id() . "', " .
- " '" . Database :: escape_string($exe_id) . "', " .
- " '" . Database :: escape_string($question_id) . "'," .
- " '" . Database :: escape_string($answer_id) . "'," .
- " '" . Database :: escape_string($correct) . "'," .
- " '" . Database :: escape_string($coords) . "')";
- return $result = Database::query($sql);
- }
- function event_system($event_type, $event_value_type, $event_value, $timestamp = null, $user_id=null, $course_code=null) {
- global $_configuration;
- global $_user;
- global $TABLETRACK_DEFAULT;
- $event_type = Database::escape_string($event_type);
- $event_value_type = Database::escape_string($event_value_type);
- $event_value = Database::escape_string($event_value);
- $timestamp = Database::escape_string($timestamp);
- $user_id = Database::escape_string($user_id);
- $course_code = Database::escape_string($course_code);
-
-
- if (!$_configuration['tracking_enabled']) {
- return 0;
- }
-
- if(!isset($timestamp)) {
- $timestamp = api_get_utc_datetime();
- }
- if(!isset($user_id)) {
- $user_id = 0;
- }
- if(!isset($course_code)) {
- $course_code = '';
- }
- $sql = "INSERT INTO $TABLETRACK_DEFAULT
- (default_user_id,
- default_cours_code,
- default_date,
- default_event_type,
- default_value_type,
- default_value
- )
- VALUES
- ('$user_id.',
- '$course_code',
- '$timestamp',
- '$event_type',
- '$event_value_type',
- '$event_value')";
- $res = Database::query($sql);
- return true;
- }
- function get_last_attempt_date_of_exercise($exe_id) {
- $exe_id = intval($exe_id);
- $track_attempts = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $track_exercises = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
-
- $sql_track_attempt = 'SELECT max(tms) as last_attempt_date FROM '.$track_attempts.' WHERE exe_id='.$exe_id;
-
- $rs_last_attempt = Database::query($sql_track_attempt);
- $row_last_attempt = Database::fetch_array($rs_last_attempt);
- $last_attempt_date = $row_last_attempt['last_attempt_date'];
- return $last_attempt_date;
- }
- function get_attempt_count($user_id, $exerciseId, $lp_id, $lp_item_id) {
- $stat_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $user_id = intval($user_id);
- $exerciseId = intval($exerciseId);
- $lp_id = intval($lp_id);
- $lp_item_id = intval($lp_item_id);
-
- $sql = "SELECT count(*) as count FROM $stat_table WHERE exe_exo_id = '$exerciseId'
- AND exe_user_id = '$user_id' AND status != 'incomplete'
- AND orig_lp_id = $lp_id AND orig_lp_item_id = $lp_item_id AND exe_cours_id = '".api_get_course_id()."' AND session_id = '" . api_get_session_id() . "'";
- $query = Database::query($sql);
- if (Database::num_rows($query) > 0 ) {
- $attempt = Database :: fetch_array($query,'ASSOC');
- return $attempt['count'];
- } else {
- return 0;
- }
- }
- function delete_student_lp_events($user_id, $lp_id, $course, $session_id) {
-
- $lp_view_table = Database::get_course_table(TABLE_LP_VIEW, $course['dbName']);
- $lp_item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW, $course['dbName']);
-
- $track_e_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $track_attempts = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $TBL_RECORDING = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
-
- $user_id = intval($user_id);
- $lp_id = intval($lp_id);
- $session_id = intval($session_id);
-
-
- $sqlview = "SELECT id FROM $lp_view_table WHERE user_id = $user_id AND lp_id = $lp_id AND session_id = $session_id ";
- $resultview = Database::query($sqlview);
- $view = Database::fetch_array($resultview, 'ASSOC');
- $lp_view_id = $view['id'];
-
- $sql_delete = "DELETE FROM $lp_item_view_table WHERE lp_view_id = $view_id ";
- $result = Database::query($sql_delete);
-
- $sql_delete = "DELETE FROM $lp_view_table WHERE user_id = $user_id AND lp_id= $lp_id AND session_id= $session_id ";
- $result = Database::query($sql_delete);
-
- $select_all_attempts = "SELECT exe_id FROM $track_e_exercises WHERE exe_user_id = $user_id AND session_id= $session_id AND exe_cours_id = '{$course['id']}' AND orig_lp_id = $lp_id";
- $result = Database::query($select_all_attempts);
- $exe_list = array();
- while ($row = Database::fetch_array($result, 'ASSOC')) {
- $exe_list[] = $row['exe_id'];
- }
-
- if (!empty($exe_list) && is_array($exe_list) && count($exe_list) > 1) {
- $sql_delete = "DELETE FROM $track_e_exercises WHERE exe_id IN (".implode(',',$exe_list).")";
- $result = Database::query($sql_delete);
-
- $sql_delete = "DELETE FROM $track_attempts WHERE exe_id IN (".implode(',',$exe_list).")";
- $result = Database::query($sql_delete);
-
- $sql_delete = "DELETE FROM $TBL_RECORDING WHERE exe_id IN (".implode(',',$exe_list).")";
- $result = Database::query($sql_delete);
- }
- }
- function get_all_exercise_event($exercise_id, $course_code, $session_id = 0) {
- $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $course_code = Database::escape_string($course_code);
- $exercise_id = intval($exercise_id);
- $session_id = intval($session_id);
-
- $sql = "SELECT * FROM $TABLETRACK_EXERCICES WHERE status = '' AND exe_cours_id = '$course_code' AND exe_exo_id = '$exercise_id' AND session_id = $session_id AND orig_lp_id =0 AND orig_lp_item_id = 0 ORDER BY exe_id";
-
- $res = api_sql_query($sql,__FILE__,__LINE__);
- $list = array();
- while($row = Database::fetch_array($res,'ASSOC')) {
- $list[$row['exe_id']] = $row;
- $sql = "SELECT * FROM $TBL_TRACK_ATTEMPT WHERE exe_id = {$row['exe_id']}";
- $res_question = api_sql_query($sql,__FILE__,__LINE__);
- while($row_q = Database::fetch_array($res_question,'ASSOC')) {
- $list[$row['exe_id']]['question_list'][$row_q['question_id']] = $row_q;
- }
- }
-
- return $list;
- }
- function get_all_exercise_event_from_lp($exercise_id, $course_code, $session_id = 0) {
- $TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
- $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $course_code = Database::escape_string($course_code);
- $exercise_id = intval($exercise_id);
- $session_id = intval($session_id);
-
-
- $sql = "SELECT * FROM $TABLETRACK_EXERCICES WHERE status = '' AND exe_cours_id = '$course_code' AND exe_exo_id = '$exercise_id' AND session_id = $session_id AND orig_lp_id !=0 AND orig_lp_item_id != 0";
-
- $res = api_sql_query($sql,__FILE__,__LINE__);
- $list = array();
- while($row = Database::fetch_array($res,'ASSOC')) {
- $list[$row['exe_id']] = $row;
- $sql = "SELECT * FROM $TBL_TRACK_ATTEMPT WHERE exe_id = {$row['exe_id']}";
- $res_question = api_sql_query($sql,__FILE__,__LINE__);
- while($row_q = Database::fetch_array($res_question,'ASSOC')) {
- $list[$row['exe_id']]['question_list'][$row_q['question_id']] = $row_q;
- }
- }
- return $list;
- }
- function get_all_exercises_from_lp($lp_id, $course_db) {
- $lp_item_table = Database :: get_course_table(TABLE_LP_ITEM,$course_db);
- $lp_id = intval($lp_id);
- $sql = "SELECT * FROM $lp_item_table WHERE lp_id = '".$lp_id."' ORDER BY parent_item_id, display_order";
- $res = api_sql_query($sql, __FILE__, __LINE__);
- $my_exercise_list = array();
- while($row = Database::fetch_array($res,'ASSOC')) {
- if ($row['item_type'] == 'quiz') {
- $my_exercise_list[] = $row;
- }
- }
- return $my_exercise_list;
- }
- function get_comments($id,$question_id)
- {
- $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $sql = "SELECT teacher_comment FROM ".$TBL_TRACK_ATTEMPT." where exe_id='".Database::escape_string($id)."' and question_id = '".Database::escape_string($question_id)."' ORDER by question_id";
- $sqlres = Database::query($sql);
- $comm = Database::result($sqlres,0,"teacher_comment");
- return $comm;
- }
|