From dbb55f9048b8e8acf8000efef5316ded14ad76ab Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Tue, 4 Jul 2017 14:09:47 +0200 Subject: [PATCH] Minor - format code --- main/admin/ldap_import_students.php | 392 ++++++++-------------------- main/admin/user_move_stats.php | 244 ++++++++++------- main/inc/lib/attendance.lib.php | 56 ++-- main/inc/lib/exercise.lib.php | 8 +- 4 files changed, 299 insertions(+), 401 deletions(-) diff --git a/main/admin/ldap_import_students.php b/main/admin/ldap_import_students.php index dfa3a8cbde..bfe4ebb9d2 100755 --- a/main/admin/ldap_import_students.php +++ b/main/admin/ldap_import_students.php @@ -1,5 +1,6 @@ 'index.php', 'name' => get_lang('PlatformAdmin')); -$htmlHeadXtra[] = ''; @@ -47,276 +48,107 @@ $annee = $_GET['annee']; $composante = $_GET['composante']; $etape = $_GET['etape']; $course = $_POST['course']; - - // form1 annee = 0; composante= 0 etape = 0 //if ($annee == "" && $composante == "" && $etape == "") { -if (empty($annee) && empty($course)) -{ - Display::display_header($tool_name); - echo '
'; - Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')); - echo get_lang('LDAPSelectFilterOnUsersOU'); - //echo ''.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'
'; - ///echo get_lang('FollowEachOfTheseStepsStepByStep').'
'; - - echo '

'; - echo ''.get_lang('LDAPOUAttributeFilter').' : '; - echo '
'; - echo ''; - echo '
'; - echo '
'; - -} -/* -elseif ($annee <> "" && $composante == "" && $etape == "") // form 2 annee != 0; composante= 0 etape = 0 -{ - Display::display_header($tool_name); - - $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); - ldap_set_version($ds); - - if ($ds) { - $r = false; - $res = ldap_handle_bind($ds, $r); - - //$sr = @ ldap_search($ds, "o=groups,$ldap_basedn", "(&(description=etape*)(cn=*$annee))", array ('cn')); - //$sr = @ ldap_search($ds, "ou=$annee, ou=diploma, o=paris1, $ldap_basedn", "ou=02*", array ('description')); - //$sr = @ ldap_search($ds, "ou=structures, o=paris1, $ldap_basedn", "businessCategory=pedagogy", array ('ou','description')); - $sr = ldap_search($ds, $ldap_basedn, "(ou=*$annee)", array ('ou','description')); - // "ou=2006,ou=diploma,o=Paris1,dc=univ-paris1,dc=fr - - $info = ldap_get_entries($ds, $sr); - $composante = array(); - for($i = 0; $i < $info['count']; $i ++) - { - //presupose LDAP server is UTF-8 - $composante[$info[$i]['ou'][0]] = api_utf8_decode($info[$i]['description'][0], api_get_system_encoding()); - } - $oucompotab3=$composante; - - echo '
'; - echo '
'; - echo '

'.Display::return_icon('group.gif', get_lang('SelectComponent')).' '.get_lang('SelectComponent').'

'; - echo '
'; - echo ''.get_lang('RegistrationYear').' : '; - echo ''; - echo ''.get_lang('Component').' : '; - echo ''; - echo '
'; - echo '
'; - echo ''; - echo '
'; - ldap_close($ds); - - } - echo '
'; - echo '
'; - echo '
'; - echo ''.get_lang('BackToNewSearch').''; - echo '
'; - echo '
'; -} -elseif ($annee <> "" && $composante <> "" && $etape == "") // form3 :annee!=0composante=0etape=0 -{ - - Display::display_header($tool_name); - echo '
'; - echo '

'.Display::return_icon('group.gif', get_lang('SearchResults')).' '.get_lang('SearchResults').'

'; - $ds = ldap_connect($ldap_host, $ldap_port); - ldap_set_version($ds); - - if ($ds) { - - $r = false; - $res = ldap_handle_bind($ds, $r); - - // $sr = @ ldap_search($ds, "ou=groups, $LDAPbasedn", "(&(cn=*$annee*)(cn=*$composante*))"); - - $sr = @ ldap_search($ds, $ldap_basedn, "ou=$composante", array ('ou','description')); - - //echo "Le nombre de resultats est : ".ldap_count_entries($ds,$sr)."

"; - $info = ldap_get_entries($ds, $sr); - - for ($i = 0; $i <= $info['count']; $i ++) { - - $description = $info[$i]['description']; - $ouetapetab[$i] = $description[0]; - $description2 = $info[$i]['ou']; - $ouetapetab2[$i] = $description2[0]; - - } - - asort($ouetapetab); - reset($ouetapetab); - - echo '

'; - - echo ''.get_lang('RegistrationYear').':'; - echo '

'; - echo ''.get_lang('Component').' :'; - echo '
'; - echo '

'.get_lang('SelectStepAcademicYear').'

'; - echo '
'; - - echo ''.get_lang('Step').': '; - echo ''; - echo ''; - - echo '
'; - echo ''; - echo '
'; - - ldap_close($ds); - - } else { - // echo "

Unable to connect to LDAP server

"; - } - echo '
'; - echo '
'; - echo ''.get_lang('BackToNewSearch').''; - echo '
'; -} -*/ -elseif (!empty($annee) && empty($course)) -{ - Display::display_header($tool_name); - echo '
'; - echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'
'; - echo '

'; - echo ''; - echo ''; - echo '
'; - echo '
'; -} -// form4 annee != 0; composante != 0 etape != 0 -//elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') { -elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed'])) -{ - Display::display_header($tool_name); - echo '
'; - echo '
'; - echo '
'; - echo '

'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'

'; - //echo "Connection ..."; - $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); - ldap_set_version($ds); - - if ($ds) { - - $r = false; - $res = ldap_handle_bind($ds, $r); - - //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))"); - //echo "(ou=*$annee,ou=$composante)"; - $sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)"); - - $info = ldap_get_entries($ds, $sr); - - for ($key = 0; $key < $info["count"]; $key++) { - $nom_form[] = $info[$key]["sn"][0]; - $prenom_form[] = $info[$key]["givenname"][0]; - $email_form[] = $info[$key]["mail"][0]; - // Get uid from dn - //$dn_array=ldap_explode_dn($info[$key]["dn"],1); - //$username_form[] = $dn_array[0]; // uid is first key - $username_form[] = $info[$key]['uid'][0]; - $outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student" - //$val = ldap_get_values_len($ds, $entry, "userPassword"); - //$password_form[] = $val[0]; - $password_form[] = $info[$key]['userPassword'][0]; - } - ldap_unbind($ds); - - /*-----------------------------------------------*/ - - asort($nom_form); - reset($nom_form); - - $statut = 5; - include ('ldap_form_add_users_group.php'); - } else { - echo '

'.get_lang('UnableToConnectTo').' '.$host.'

'; - } - echo '

'; +if (empty($annee) && empty($course)) { + Display::display_header($tool_name); + echo '
'; + Display::display_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')); + echo get_lang('LDAPSelectFilterOnUsersOU'); + //echo ''.get_lang('ToDoThisYouMustEnterYearComponentAndComponentStep').'
'; + ///echo get_lang('FollowEachOfTheseStepsStepByStep').'
'; + + echo '

'; + echo ''.get_lang('LDAPOUAttributeFilter').' : '; + echo '
'; + echo ''; + echo '
'; + echo '
'; +} elseif (!empty($annee) && empty($course)) { + Display::display_header($tool_name); + echo '
'; + echo Display::return_icon('course.png', get_lang('SelectCourseToImportUsersTo')).' '.get_lang('SelectCourseToImportUsersTo').'
'; + echo '

'; + echo ''; + echo ''; + echo '
'; + echo '
'; +} elseif (!empty($annee) && !empty($course) && empty($_POST['confirmed'])) { + // form4 annee != 0; composante != 0 etape != 0 + //elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') { + Display::display_header($tool_name); + echo '
'; + echo '
'; + echo '
'; + echo '

'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'

'; + //echo "Connection ..."; + $ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError')); + ldap_set_version($ds); + + if ($ds) { + $r = false; + $res = ldap_handle_bind($ds, $r); + + //$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))"); + //echo "(ou=*$annee,ou=$composante)"; + $sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)"); + + $info = ldap_get_entries($ds, $sr); + + for ($key = 0; $key < $info["count"]; $key++) { + $nom_form[] = $info[$key]["sn"][0]; + $prenom_form[] = $info[$key]["givenname"][0]; + $email_form[] = $info[$key]["mail"][0]; + // Get uid from dn + //$dn_array=ldap_explode_dn($info[$key]["dn"],1); + //$username_form[] = $dn_array[0]; // uid is first key + $username_form[] = $info[$key]['uid'][0]; + $outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student" + //$val = ldap_get_values_len($ds, $entry, "userPassword"); + //$password_form[] = $val[0]; + $password_form[] = $info[$key]['userPassword'][0]; + } + ldap_unbind($ds); + asort($nom_form); + reset($nom_form); + + $statut = 5; + include 'ldap_form_add_users_group.php'; + } else { + echo '

'.get_lang('UnableToConnectTo').' '.$host.'

'; + } + echo '

'; echo ''.get_lang('BackToNewSearch').''; echo '

'; echo '
'; - -} -elseif (!empty($annee) && !empty($course) && ($_POST['confirmed'] == 'yes')) -{ - $id = $_POST['username_form']; - $UserList = array(); - $userid_match_login = array(); - foreach ($id as $form_index=>$user_id) - { - if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes']))) - { - $tmp = ldap_add_user($user_id); - $UserList[] = $tmp; - $userid_match_login[$tmp] = $user_id; - } - } - if (!empty($_POST['course'])) - { - foreach ($UserList as $user_id) - { - CourseManager::add_user_to_course($user_id, $_POST['course']); - } - header('Location: course_information.php?code='.Security::remove_XSS($_POST['course'])); - } - /* - else - { - Display :: display_header($tool_name); - if(count($userid_match_login)>0) - { - $message=get_lang('LDAPUsersAddedOrUpdated').':
'; - foreach($userid_match_login as $user_id => $login) - { - $message .= '- '.$login.'
'; - } - } - else - { - $message=get_lang('NoUserAdded'); - } - Display::addFlash(Display::return_message($message, 'normal', false)); - } - */ - else - { - $message = get_lang('NoUserAdded'); - Display::addFlash(Display::return_message($message, 'normal', false)); +} elseif (!empty($annee) && !empty($course) && ($_POST['confirmed'] == 'yes')) { + $id = $_POST['username_form']; + $UserList = array(); + $userid_match_login = array(); + foreach ($id as $form_index => $user_id) { + if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes']))) { + $tmp = ldap_add_user($user_id); + $UserList[] = $tmp; + $userid_match_login[$tmp] = $user_id; + } + } + if (!empty($_POST['course'])) { + foreach ($UserList as $user_id) { + CourseManager::add_user_to_course($user_id, $_POST['course']); + } + header('Location: course_information.php?code='.Security::remove_XSS($_POST['course'])); + } else { + $message = get_lang('NoUserAdded'); + Display::addFlash(Display::return_message($message, 'normal', false)); Display::display_header($tool_name); - } - echo '

'; + } + echo '

'; echo ''.get_lang('BackToNewSearch').''; echo '

'; } Display::display_footer(); -?> diff --git a/main/admin/user_move_stats.php b/main/admin/user_move_stats.php index 401fc2adb2..31a3923657 100755 --- a/main/admin/user_move_stats.php +++ b/main/admin/user_move_stats.php @@ -15,9 +15,9 @@ api_protect_admin_script(); $interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); $debug = 0; -function compare_data($result_message) { - foreach ($result_message as $table=>$data) { - +function compare_data($result_message) +{ + foreach ($result_message as $table => $data) { $title = $table; if ($table == 'TRACK_E_EXERCISES') { $title = get_lang('Exercises'); @@ -30,7 +30,6 @@ function compare_data($result_message) { if (is_array($data)) { foreach ($data as $id => $item) { - if ($table == 'TRACK_E_EXERCISES' || $table == 'TRACK_E_EXERCISES_IN_LP') { echo "

".get_lang('Attempt')." #$id

"; echo '

'; @@ -42,8 +41,12 @@ function compare_data($result_message) { echo '

'; } //Process data - $array = array('exe_date' =>get_lang('Date'), 'exe_result' =>get_lang('Score'), 'exe_weighting'=>get_lang('Weighting')); - foreach ($item as $key=> $value) { + $array = array( + 'exe_date' => get_lang('Date'), + 'exe_result' => get_lang('Score'), + 'exe_weighting' => get_lang('Weighting') + ); + foreach ($item as $key => $value) { if (in_array($key, array_keys($array))) { $key = $array[$key]; echo "$key = $value
"; @@ -52,7 +55,7 @@ function compare_data($result_message) { } else { echo "

".get_lang('Id')." #$id

"; //process data - foreach ($item as $key=> $value) { + foreach ($item as $key => $value) { echo "$key = $value
"; } } @@ -64,16 +67,18 @@ function compare_data($result_message) { } if (isset($_REQUEST['load_ajax'])) { - //Checking the variable $_SESSION['combination'] that has all the information of the selected course (instead of using a lots of hidden variables ... ) + //Checking the variable $_SESSION['combination'] that has all the + // information of the selected course (instead of using a lots of + // hidden variables ... ) if (isset($_SESSION['combination']) && !empty($_SESSION['combination'])) { $combinations = $_SESSION['combination']; $combination_result = $combinations[$_REQUEST['unique_id']]; if (empty($combination_result)) { echo get_lang('ThereWasAnError'); } else { - $origin_course_code = $combination_result['course_code']; - $origin_session_id = intval($combination_result['session_id']); - $new_session_id = intval($_REQUEST['session_id']); + $origin_course_code = $combination_result['course_code']; + $origin_session_id = intval($combination_result['session_id']); + $new_session_id = intval($_REQUEST['session_id']); $session = $em->find('ChamiloCoreBundle:Session', $new_session_id); //if (!isset($_REQUEST['view_stat'])) { @@ -93,7 +98,7 @@ if (isset($_REQUEST['load_ajax'])) { } } - $result_message = array(); + $result_message = array(); $result_message_compare = array(); $update_database = true; @@ -103,29 +108,34 @@ if (isset($_REQUEST['load_ajax'])) { //Check if the same course exist in the session destination if ($course_founded) { - //Check if the user is registered in the session otherwise we will add it $result = SessionManager::get_users_by_session($new_session_id); if (empty($result) || !in_array($user_id, array_keys($result))) { - if ($debug) echo 'User added to the session'; + if ($debug) { + echo 'User added to the session'; + } //Registering user to the new session - SessionManager::subscribe_users_to_session($new_session_id, array($user_id), false); + SessionManager::subscribe_users_to_session( + $new_session_id, + array($user_id), + false + ); } //Begin with the import process $course_info = api_get_course_info($origin_course_code); $course_id = $course_info['real_id']; - $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); - $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); - $TBL_TRACK_E_COURSE_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); - $TBL_TRACK_E_LAST_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); + $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); + $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); + $TBL_TRACK_E_COURSE_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); + $TBL_TRACK_E_LAST_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); - $TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW); - $TBL_NOTEBOOK = Database::get_course_table(TABLE_NOTEBOOK); - $TBL_STUDENT_PUBLICATION = Database::get_course_table(TABLE_STUDENT_PUBLICATION); + $TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW); + $TBL_NOTEBOOK = Database::get_course_table(TABLE_NOTEBOOK); + $TBL_STUDENT_PUBLICATION = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $TBL_STUDENT_PUBLICATION_ASSIGNMENT = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); - $TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); + $TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE); $TBL_DROPBOX_POST = Database::get_course_table(TABLE_DROPBOX_POST); @@ -142,8 +152,8 @@ if (isset($_REQUEST['load_ajax'])) { $list[$row['exe_id']] = $row; } - if (!empty($list)) - foreach ($list as $exe_id =>$data) { + if (!empty($list)) { + foreach ($list as $exe_id => $data) { if ($update_database) { $sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id"; $res = Database::query($sql); @@ -156,23 +166,27 @@ if (isset($_REQUEST['load_ajax'])) { } } } + } - //DESTINY COURSE - + // DESTINY COURSE if (!$update_database) { - $sql = "SELECT * FROM $TABLETRACK_EXERCICES - WHERE c_id = $course_id AND session_id = $new_session_id AND exe_user_id = $user_id "; + WHERE + c_id = $course_id AND + session_id = $new_session_id AND + exe_user_id = $user_id "; $res = Database::query($sql); $list = array(); while ($row = Database::fetch_array($res, 'ASSOC')) { $list[$row['exe_id']] = $row; } - if (!empty($list)) - foreach ($list as $exe_id =>$data) { + if (!empty($list)) { + foreach ($list as $exe_id => $data) { if ($update_database) { - $sql = "UPDATE $TABLETRACK_EXERCICES SET session_id = '$new_session_id' WHERE exe_id = $exe_id"; + $sql = "UPDATE $TABLETRACK_EXERCICES + SET session_id = '$new_session_id' + WHERE exe_id = $exe_id"; $res = Database::query($sql); $result_message[$TABLETRACK_EXERCICES]++; } else { @@ -183,6 +197,7 @@ if (isset($_REQUEST['load_ajax'])) { } } } + } } //2.track_e_attempt, track_e_attempt_recording, track_e_downloads @@ -197,10 +212,12 @@ if (isset($_REQUEST['load_ajax'])) { $list[$row['course_access_id']] = $row; } - if (!empty($list)) + if (!empty($list)) { foreach ($list as $id => $data) { if ($update_database) { - $sql = "UPDATE $TBL_TRACK_E_COURSE_ACCESS SET session_id = $new_session_id WHERE course_access_id = $id"; + $sql = "UPDATE $TBL_TRACK_E_COURSE_ACCESS + SET session_id = $new_session_id + WHERE course_access_id = $id"; if ($debug) { echo $sql; } @@ -208,8 +225,9 @@ if (isset($_REQUEST['load_ajax'])) { $result_message[$TBL_TRACK_E_COURSE_ACCESS]++; } } - //4. track_e_lastaccess + } + //4. track_e_lastaccess $sql = "SELECT access_id FROM $TBL_TRACK_E_LAST_ACCESS WHERE c_id = $course_id AND access_session_id = $origin_session_id @@ -219,20 +237,24 @@ if (isset($_REQUEST['load_ajax'])) { while ($row = Database::fetch_array($res, 'ASSOC')) { $list[] = $row['access_id']; } - if (!empty($list)) + if (!empty($list)) { foreach ($list as $id) { if ($update_database) { - $sql = "UPDATE $TBL_TRACK_E_LAST_ACCESS SET access_session_id = $new_session_id WHERE access_id = $id"; - if ($debug) echo $sql; + $sql = "UPDATE $TBL_TRACK_E_LAST_ACCESS + SET access_session_id = $new_session_id + WHERE access_id = $id"; + if ($debug) { + echo $sql; + } $res = Database::query($sql); //if ($debug) var_dump($res); $result_message[$TBL_TRACK_E_LAST_ACCESS]++; } } + } //5. lp_item_view //CHECK ORIGIN - $sql = "SELECT * FROM $TBL_LP_VIEW WHERE user_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id "; $res = Database::query($sql); @@ -249,22 +271,41 @@ if (isset($_REQUEST['load_ajax'])) { } } - if (!empty($list)) - foreach ($list as $id=>$data) { + if (!empty($list)) { + foreach ($list as $id => $data) { if ($update_database) { - $sql = "UPDATE $TBL_LP_VIEW SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id "; - if ($debug) var_dump($sql); + $sql = "UPDATE $TBL_LP_VIEW + SET session_id = $new_session_id + WHERE c_id = $course_id AND id = $id "; + if ($debug) { + var_dump($sql); + } $res = Database::query($sql); - if ($debug) var_dump($res); + if ($debug) { + var_dump($res); + } $result_message[$TBL_LP_VIEW]++; } else { //Getting all information of that lp_item_id - $score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $origin_session_id); - $progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $origin_session_id); - $result_message['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress); + $score = Tracking::get_avg_student_score( + $user_id, + $origin_course_code, + array($data['lp_id']), + $origin_session_id + ); + $progress = Tracking::get_avg_student_progress( + $user_id, + $origin_course_code, + array($data['lp_id']), + $origin_session_id + ); + $result_message['LP_VIEW'][$data['lp_id']] = array( + 'score' => $score, + 'progress' => $progress + ); } } - + } //CHECk DESTINY if (!$update_database) { @@ -282,20 +323,33 @@ if (isset($_REQUEST['load_ajax'])) { $list[$row['id']] = $row; } } - if (!empty($list)) - foreach ($list as $id=>$data) { + if (!empty($list)) { + foreach ($list as $id => $data) { //Getting all information of that lp_item_id - $score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); - $progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); - $result_message_compare['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress); + $score = Tracking::get_avg_student_score( + $user_id, + $origin_course_code, + array($data['lp_id']), + $new_session_id + ); + $progress = Tracking::get_avg_student_progress( + $user_id, + $origin_course_code, + array($data['lp_id']), + $new_session_id + ); + $result_message_compare['LP_VIEW'][$data['lp_id']] = array( + 'score' => $score, + 'progress' => $progress + ); } + } } - //6. Agenda - //calendar_event_attachment no problems no session_id - $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'calendar_event' AND insert_user_id = $user_id AND c_id = $course_id "; + $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY + WHERE tool = 'calendar_event' AND insert_user_id = $user_id AND c_id = $course_id "; $res = Database::query($sql); while ($row = Database::fetch_array($res, 'ASSOC')) { $id = $row['ref']; @@ -309,12 +363,9 @@ if (isset($_REQUEST['load_ajax'])) { } //7. Forum ?? So much problems when trying to import data - //8. Student publication - Works - - //echo '

Student publication

'; - - $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'work' AND insert_user_id = $user_id AND c_id = $course_id"; + $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY + WHERE tool = 'work' AND insert_user_id = $user_id AND c_id = $course_id"; if ($debug) echo $sql; $res = Database::query($sql); while ($row = Database::fetch_array($res, 'ASSOC')) { @@ -327,18 +378,23 @@ if (isset($_REQUEST['load_ajax'])) { if ($debug) var_dump($data); $parent_id = $data['parent_id']; if (isset($data['parent_id']) && !empty($data['parent_id'])) { - $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $parent_id AND c_id = $course_id"; - $select_res = Database::query($sql); - $parent_data = Database::fetch_array($select_res, 'ASSOC'); - if ($debug) var_dump($parent_data); + $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION + WHERE id = $parent_id AND c_id = $course_id"; + $select_res = Database::query($sql); + $parent_data = Database::fetch_array( + $select_res, + 'ASSOC' + ); + if ($debug) { + var_dump($parent_data); + } $sys_course_path = api_get_path(SYS_COURSE_PATH); $course_dir = $sys_course_path.$course_info['path']; $base_work_dir = $course_dir.'/work'; require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php'; - //Creating the parent folder in the session if does not exists already - + // Creating the parent folder in the session if does not exists already //@todo ugly fix $search_this = "folder_moved_from_session_id_$origin_session_id"; $search_this2 = $parent_data['url']; @@ -354,9 +410,7 @@ if (isset($_REQUEST['load_ajax'])) { $created_dir = $new_result['url']; $new_parent_id = $new_result['id']; } else { - if ($update_database) { - $dir_name = substr($parent_data['url'], 1); $created_dir = create_unexisting_work_directory($base_work_dir, $dir_name); $created_dir = '/'.$created_dir; @@ -411,8 +465,6 @@ if (isset($_REQUEST['load_ajax'])) { WHERE id = ".$new_parent_id; if ($debug) echo $sql_update; $rest_update = Database::query($sql_update); - - if ($debug) var_dump($sql_update); $result_message[$TBL_STUDENT_PUBLICATION_ASSIGNMENT]++; } @@ -445,8 +497,8 @@ if (isset($_REQUEST['load_ajax'])) { api_item_property_update($course_info, 'work', $id, 'DocumentAdded', $user_id); $result_message[$TBL_STUDENT_PUBLICATION]++; - $full_file_name = $course_dir.'/'.$doc_url; - $new_file = $course_dir.'/'.$new_url; + $full_file_name = $course_dir.'/'.$doc_url; + $new_file = $course_dir.'/'.$new_url; if (file_exists($full_file_name)) { //deleting old assignment @@ -461,15 +513,13 @@ if (isset($_REQUEST['load_ajax'])) { } } } - } } //9. Survey Pending - //10. Dropbox - not neccesary to move categories (no presence of session_id) - - $sql = "SELECT id FROM $TBL_DROPBOX_FILE WHERE uploader_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id"; + $sql = "SELECT id FROM $TBL_DROPBOX_FILE + WHERE uploader_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id"; if ($debug) var_dump($sql); $res = Database::query($sql); while ($row = Database::fetch_array($res, 'ASSOC')) { @@ -499,7 +549,9 @@ if (isset($_REQUEST['load_ajax'])) { while ($row = Database::fetch_array($res, 'ASSOC')) { $id = $row['notebook_id']; if ($update_database) { - $sql = "UPDATE $TBL_NOTEBOOK SET session_id = $new_session_id WHERE c_id = $course_id AND notebook_id = $id"; + $sql = "UPDATE $TBL_NOTEBOOK + SET session_id = $new_session_id + WHERE c_id = $course_id AND notebook_id = $id"; if ($debug) var_dump($sql); $res = Database::query($sql); if ($debug) var_dump($res); @@ -509,7 +561,7 @@ if (isset($_REQUEST['load_ajax'])) { if ($update_database) { echo '

'.get_lang('StatsMoved').'

'; if (is_array($result_message)) - foreach ($result_message as $table=>$times) { + foreach ($result_message as $table => $times) { echo 'Table '.$table.' - '.$times.' records updated
'; } } else { @@ -547,8 +599,7 @@ if (isset($_REQUEST['load_ajax'])) { } exit; } -$htmlHeadXtra[] = ''; -function get_courses_list_by_user_id_based_in_exercises($user_id) { +function get_courses_list_by_user_id_based_in_exercises($user_id) +{ $TABLETRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES); $user_id = intval($user_id); $sql = "SELECT DISTINCT exe_user_id, c_id, session_id @@ -598,7 +650,13 @@ function get_courses_list_by_user_id_based_in_exercises($user_id) { return $course_list; } -Display::addFlash(Display::return_message(get_lang('CompareUserResultsBetweenCoursesAndCoursesInASession'), 'normal', false)); +Display::addFlash( + Display::return_message( + get_lang('CompareUserResultsBetweenCoursesAndCoursesInASession'), + 'normal', + false + ) +); Display::display_header(get_lang('MoveUserStats')); echo '
'; echo ''.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM).''; @@ -610,12 +668,11 @@ if (isset($_GET['page']) && !empty($_GET['page'])) { $page = intval($_GET['page']); } $default = 20; -$count = UserManager::get_number_of_users(); -$nro_pages = round($count / $default) + 1; -$begin = $default * ($page - 1); -$end = $default * $page; - -$navigation = "$begin - $end / $count
"; +$count = UserManager::get_number_of_users(); +$nro_pages = round($count / $default) + 1; +$begin = $default * ($page - 1); +$end = $default * $page; +$navigation = "$begin - $end / $count
"; if ($page > 1) { $navigation .= ''.get_lang('Previous').''; @@ -624,14 +681,15 @@ if ($page > 1) { } $navigation .= ' '; $page++; -if ($page < $nro_pages) +if ($page < $nro_pages) { $navigation .= ''.get_lang('Next').''; -else +} else { $navigation .= get_lang('Next'); +} echo $navigation; -$user_list = UserManager::get_user_list(array(), array(), $begin, $default); -$session_list = SessionManager::get_sessions_list(array(), array('name')); +$user_list = UserManager::get_user_list(array(), array(), $begin, $default); +$session_list = SessionManager::get_sessions_list(array(), array('name')); $options = ''; $options .= ''; foreach ($session_list as $session_data) { diff --git a/main/inc/lib/attendance.lib.php b/main/inc/lib/attendance.lib.php index 263144f29e..5e0a2b102d 100755 --- a/main/inc/lib/attendance.lib.php +++ b/main/inc/lib/attendance.lib.php @@ -352,9 +352,9 @@ class Attendance /** * edit attendances inside table - * @param int attendance id - * @param bool true for adding link in gradebook or false otherwise (optional) - * @return int last id + * @param int attendance id + * @param bool true for adding link in gradebook or false otherwise (optional) + * @return int last id */ public function attendance_edit($attendance_id, $link_to_gradebook = false) { @@ -663,7 +663,6 @@ class Attendance $value = array(); $uid = $user_data['user_id']; $userInfo = api_get_user_info($uid); - $status = $user_data['status']; if (!empty($groupId)) { @@ -759,10 +758,10 @@ class Attendance $rs = Database::query($sql); if (Database::num_rows($rs) == 0) { $sql = "INSERT INTO $tbl_attendance_sheet SET - c_id = $course_id, - user_id = '$uid', - attendance_calendar_id = '$calendar_id', - presence = 1"; + c_id = $course_id, + user_id = '$uid', + attendance_calendar_id = '$calendar_id', + presence = 1"; $result = Database::query($sql); $affected_rows += Database::affected_rows($result); @@ -843,7 +842,6 @@ class Attendance $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); $course_id = api_get_course_int_id(); - $attendance_id = intval($attendance_id); // fill results about presence of students $attendance_calendar = $this->get_attendance_calendar( @@ -913,7 +911,6 @@ class Attendance // update attendance qualify max $count_done_calendar = self::get_done_attendance_calendar($attendance_id); - $sql = "UPDATE $tbl_attendance SET attendance_qualify_max = '$count_done_calendar' WHERE c_id = $course_id AND id = '$attendance_id'"; @@ -1123,7 +1120,10 @@ class Attendance $user_id = intval($user_id); $results = array(); $total_faults = $total_weight = $porcent = 0; - $attendances_by_course = $this->get_attendances_list($course_info['real_id'], $session_id); + $attendances_by_course = $this->get_attendances_list( + $course_info['real_id'], + $session_id + ); foreach ($attendances_by_course as $attendance) { // Get total faults and total weight @@ -1157,6 +1157,7 @@ class Attendance * Get registered users' attendance sheet inside current course * @param int $attendance_id * @param int $user_id for showing data for only one user (optional) + * @param int $groupId * @return array users attendance sheet data */ public function get_users_attendance_sheet( @@ -1285,9 +1286,9 @@ class Attendance /** * Get user' score from current attendance - * @param int $user_id - * @param int $attendance_id - * @return int score + * @param int $user_id + * @param int $attendance_id + * @return int score */ public function get_user_score($user_id, $attendance_id, $groupId = null) { @@ -1454,9 +1455,9 @@ class Attendance /** * Get number of attendance calendar inside current attendance - * @param int $attendance_id - * @param int $groupId - * @return int number of dates in attendance calendar + * @param int $attendance_id + * @param int $groupId + * @return int number of dates in attendance calendar */ public static function get_number_of_attendance_calendar( $attendance_id, @@ -1547,8 +1548,8 @@ class Attendance /** * Get count dates inside attendance calendar by attendance id - * @param int $attendance_id - * @return int count of dates + * @param int $attendance_id + * @return int count of dates */ public static function get_count_dates_inside_attendance_calendar($attendance_id) { @@ -1863,11 +1864,14 @@ class Attendance * delete a datetime from attendance calendar table * @param int attendance calendar id * @param int attendance id - * @param bool true for removing all calendar inside current attendance, false for removing by calendar id + * @param bool true for removing all calendar inside current attendance, false for removing by calendar id * @return int affected rows */ - public function attendance_calendar_delete($calendar_id, $attendance_id, $all_delete = false) - { + public function attendance_calendar_delete( + $calendar_id, + $attendance_id, + $all_delete = false + ) { $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); $tbl_attendance_sheet = Database::get_course_table(TABLE_ATTENDANCE_SHEET); @@ -1995,8 +1999,12 @@ class Attendance */ public function getAttendanceLogin($startDate, $endDate) { - if (empty($startDate) || $startDate == '0000-00-00' || $startDate == '0000-00-00 00:00:00' || - empty($endDate) || $endDate == '0000-00-00' || $endDate == '0000-00-00 00:00:00' + if (empty($startDate) || + $startDate == '0000-00-00' || + $startDate == '0000-00-00 00:00:00' || + empty($endDate) || + $endDate == '0000-00-00' || + $endDate == '0000-00-00 00:00:00' ) { return false; } diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index f5b1bc74cf..100b29ae74 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -59,7 +59,10 @@ class ExerciseLib $pictureName = $objQuestionTmp->getPictureFilename(); $s = ''; - if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION && $answerType != ANNOTATION) { + if ($answerType != HOT_SPOT && + $answerType != HOT_SPOT_DELINEATION && + $answerType != ANNOTATION + ) { // Question is not a hotspot if (!$only_questions) { $questionDescription = $objQuestionTmp->selectDescription(); @@ -312,7 +315,6 @@ class ExerciseLib //no break case READING_COMPREHENSION: $input_id = 'choice-'.$questionId.'-'.$answerId; - if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) { $attributes = array( 'id' => $input_id, @@ -1054,9 +1056,7 @@ HTML; } $s .= ''; - $lines_count++; - if (($lines_count - 1) == $num_suggestions) { while (isset($select_items[$lines_count])) { $s .= <<