myStudents.php 102 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once '../inc/global.inc.php';
  4. $allow = api_get_configuration_value('extra');
  5. if (empty($allow)) {
  6. exit;
  7. }
  8. api_block_anonymous_users();
  9. $export_csv = isset($_GET['export']) && $_GET['export'] === 'csv' ? true : false;
  10. $course_code = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null;
  11. $_course = api_get_course_info();
  12. $coment = '';
  13. if (!api_is_allowed_to_create_course() &&
  14. !api_is_session_admin() &&
  15. !api_is_drh() &&
  16. !api_is_student_boss() &&
  17. !api_is_platform_admin()
  18. ) {
  19. // Check if the user is tutor of the course
  20. $user_course_status = CourseManager::get_tutor_in_course_status(
  21. api_get_user_id(),
  22. api_get_course_int_id()
  23. );
  24. // Francois Belisle Kezber...
  25. // If user is NOT a teacher -> student, but IS the teacher of the course... Won't have the global teacher status
  26. // and won't be tutor... So have to check is_course_teacher
  27. if (($user_course_status != 1) && !(CourseManager::is_course_teacher(api_get_user_id(), $course_code))) {
  28. api_not_allowed(true);
  29. }
  30. }
  31. $htmlHeadXtra[] = '<script>
  32. function show_image(image,width,height) {
  33. width = parseInt(width) + 20;
  34. height = parseInt(height) + 20;
  35. window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
  36. }
  37. </script>';
  38. $export = isset($_GET['export']) ? $_GET['export'] : false;
  39. $sessionId = isset($_GET['id_session']) ? intval($_GET['id_session']) : 0;
  40. $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
  41. $studentId = (int) $_GET['student'];
  42. $coachId = isset($_GET['id_coach']) ? (int) $_GET['id_coach'] : 0;
  43. // time spent on the course
  44. $courseInfo = api_get_course_info($course_code);
  45. if ($export) {
  46. ob_start();
  47. }
  48. $csv_content = [];
  49. $from_myspace = false;
  50. if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
  51. $from_myspace = true;
  52. $this_section = SECTION_TRACKING;
  53. } else {
  54. $this_section = SECTION_COURSES;
  55. }
  56. $nameTools = get_lang('StudentDetails');
  57. $em = Database::getManager();
  58. if (isset($_GET['details'])) {
  59. if ($origin === 'user_course') {
  60. if (empty($cidReq)) {
  61. $interbreadcrumb[] = [
  62. "url" => api_get_path(WEB_COURSE_PATH).$courseInfo['directory'],
  63. 'name' => $courseInfo['title'],
  64. ];
  65. }
  66. $interbreadcrumb[] = [
  67. "url" => "../user/user.php?cidReq=".$course_code,
  68. "name" => get_lang('Users'),
  69. ];
  70. } else {
  71. if ($origin === 'tracking_course') {
  72. $interbreadcrumb[] = [
  73. "url" => "../tracking/courseLog.php?cidReq=".$course_code.'&id_session='.api_get_session_id(),
  74. "name" => get_lang('Tracking'),
  75. ];
  76. } else {
  77. if ($origin === 'resume_session') {
  78. $interbreadcrumb[] = [
  79. 'url' => "../session/session_list.php",
  80. "name" => get_lang('SessionList'),
  81. ];
  82. $interbreadcrumb[] = [
  83. 'url' => "../session/resume_session.php?id_session=".$sessionId,
  84. "name" => get_lang('SessionOverview'),
  85. ];
  86. } else {
  87. $interbreadcrumb[] = [
  88. "url" => api_is_student_boss() ? "#" : "index.php",
  89. "name" => get_lang('MySpace'),
  90. ];
  91. if (!empty($coachId)) {
  92. $interbreadcrumb[] = [
  93. "url" => "student.php?id_coach=$coachId",
  94. "name" => get_lang('CoachStudents'),
  95. ];
  96. $interbreadcrumb[] = [
  97. "url" => "myStudents.php?student=$studentId&id_coach=$coachId",
  98. "name" => get_lang("StudentDetails"),
  99. ];
  100. } else {
  101. $interbreadcrumb[] = [
  102. "url" => "student.php",
  103. "name" => get_lang("MyStudents"),
  104. ];
  105. $interbreadcrumb[] = [
  106. "url" => "myStudents.php?student=".$studentId,
  107. "name" => get_lang("StudentDetails"),
  108. ];
  109. }
  110. }
  111. }
  112. }
  113. $nameTools = get_lang("DetailsStudentInCourse");
  114. } else {
  115. if ($origin == 'resume_session') {
  116. $interbreadcrumb[] = [
  117. 'url' => "../session/session_list.php",
  118. "name" => get_lang('SessionList'),
  119. ];
  120. if (!empty($sessionId)) {
  121. $interbreadcrumb[] = [
  122. 'url' => "../session/resume_session.php?id_session=$sessionId",
  123. "name" => get_lang('SessionOverview'),
  124. ];
  125. }
  126. } else {
  127. $interbreadcrumb[] = [
  128. "url" => api_is_student_boss() ? "#" : "index.php",
  129. "name" => get_lang('MySpace'),
  130. ];
  131. if (!empty($coachId)) {
  132. if ($sessionId) {
  133. $interbreadcrumb[] = [
  134. "url" => "student.php?id_coach=$coachId&id_session=$sessionId",
  135. "name" => get_lang("CoachStudents"),
  136. ];
  137. } else {
  138. $interbreadcrumb[] = [
  139. "url" => "student.php?id_coach=$coachId",
  140. "name" => get_lang("CoachStudents"),
  141. ];
  142. }
  143. } else {
  144. $interbreadcrumb[] = [
  145. "url" => "student.php",
  146. "name" => get_lang("MyStudents"),
  147. ];
  148. }
  149. }
  150. }
  151. // Database Table Definitions
  152. //$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  153. //$tbl_stats_exercices = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  154. $tbl_user = Database:: get_main_table(TABLE_MAIN_USER);
  155. $tbl_session_user = Database:: get_main_table(TABLE_MAIN_SESSION_USER);
  156. $tbl_session = Database:: get_main_table(TABLE_MAIN_SESSION);
  157. $tbl_session_course = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE);
  158. $tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  159. $tbl_course = Database:: get_main_table(TABLE_MAIN_COURSE);
  160. $tbl_course_user = Database:: get_main_table(TABLE_MAIN_COURSE_USER);
  161. $tbl_stats_access = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
  162. $tbl_stats_exercices = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  163. $tbl_stats_exercices_attempts = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  164. $tbl_personal_agenda = Database:: get_main_table(TABLE_PERSONAL_AGENDA);
  165. $tbl_course_lp_item = Database:: get_course_table(TABLE_LP_ITEM);
  166. $tbl_course_lp_view = 'lp_view';
  167. $tbl_course_lp_view_item = 'lp_item_view';
  168. $tbl_course_lp_item = 'lp_item';
  169. $tbl_course_lp = 'lp';
  170. $tbl_course_quiz = 'quiz';
  171. $course_quiz_question = 'quiz_question';
  172. $course_quiz_rel_question = 'quiz_rel_question';
  173. $course_quiz_answer = 'quiz_answer';
  174. $course_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
  175. $TABLECALHORAIRE = Database:: get_course_table(TABLE_CAL_HORAIRE);
  176. if (isset($_GET['user_id']) && $_GET['user_id'] != '') {
  177. $user_id = intval($_GET['user_id']);
  178. } else {
  179. $user_id = api_get_user_id();
  180. }
  181. // Action behaviour
  182. $action = isset($_GET['action']) ? $_GET['action'] : '';
  183. switch ($action) {
  184. case 'send_legal':
  185. $subject = get_lang('SendLegalSubject');
  186. $content = sprintf(
  187. get_lang('SendLegalDescriptionToUrlX'),
  188. api_get_path(WEB_PATH)
  189. );
  190. MessageManager::send_message_simple($studentId, $subject, $content);
  191. Display::addFlash(Display::return_message(get_lang('Sent')));
  192. break;
  193. case 'delete_legal':
  194. $extraFieldValue = new ExtraFieldValue('user');
  195. $value = $extraFieldValue->get_values_by_handler_and_field_variable($studentId, 'legal_accept');
  196. $result = $extraFieldValue->delete($value['id']);
  197. if ($result) {
  198. Display::addFlash(Display::return_message(get_lang('Deleted')));
  199. }
  200. break;
  201. case 'reset_lp':
  202. $lp_id = isset($_GET['lp_id']) ? (int) $_GET['lp_id'] : '';
  203. if (api_is_allowed_to_edit() &&
  204. !empty($lp_id) &&
  205. !empty($studentId)
  206. ) {
  207. Event::delete_student_lp_events(
  208. $studentId,
  209. $lp_id,
  210. $courseInfo,
  211. $sessionId
  212. );
  213. // @todo delete the stats.track_e_exercises records.
  214. // First implement this http://support.chamilo.org/issues/1334
  215. $message = Display::return_message(
  216. get_lang('LPWasReset'),
  217. 'success'
  218. );
  219. }
  220. break;
  221. default:
  222. break;
  223. }
  224. // user info
  225. $user_info = api_get_user_info($studentId);
  226. $courses_in_session = [];
  227. //See #4676
  228. $drh_can_access_all_courses = false;
  229. if (api_is_drh() || api_is_platform_admin() || api_is_student_boss()) {
  230. $drh_can_access_all_courses = true;
  231. }
  232. $courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id());
  233. $courses_in_session_by_coach = [];
  234. $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id());
  235. // RRHH or session admin
  236. if (api_is_session_admin() || api_is_drh()) {
  237. $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
  238. $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
  239. if (!empty($session_by_session_admin)) {
  240. foreach ($session_by_session_admin as $session_coached_by_user) {
  241. $courses_followed_by_coach = Tracking:: get_courses_list_from_session($session_coached_by_user['id']);
  242. $courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach;
  243. }
  244. }
  245. }
  246. // Teacher or admin
  247. if (!empty($sessions_coached_by_user)) {
  248. foreach ($sessions_coached_by_user as $session_coached_by_user) {
  249. $sid = (int) $session_coached_by_user['id'];
  250. $courses_followed_by_coach = Tracking::get_courses_followed_by_coach(api_get_user_id(), $sid);
  251. $courses_in_session_by_coach[$sid] = $courses_followed_by_coach;
  252. }
  253. }
  254. $sql = "SELECT c_id
  255. FROM $tbl_course_user
  256. WHERE
  257. relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND
  258. user_id = ".intval($user_info['user_id']);
  259. $rs = Database::query($sql);
  260. while ($row = Database:: fetch_array($rs)) {
  261. if ($drh_can_access_all_courses) {
  262. $courses_in_session[0][] = $row['c_id'];
  263. } else {
  264. if (isset($courses[$row['c_id']])) {
  265. $courses_in_session[0][] = $row['c_id'];
  266. }
  267. }
  268. }
  269. // Get the list of sessions where the user is subscribed as student
  270. $sql = 'SELECT session_id, c_id
  271. FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).'
  272. WHERE user_id='.intval($user_info['user_id']);
  273. $rs = Database::query($sql);
  274. $tmp_sessions = [];
  275. while ($row = Database:: fetch_array($rs, 'ASSOC')) {
  276. $tmp_sessions[] = $row['session_id'];
  277. if ($drh_can_access_all_courses) {
  278. if (in_array($row['session_id'], $tmp_sessions)) {
  279. $courses_in_session[$row['session_id']][] = $row['c_id'];
  280. }
  281. } else {
  282. if (isset($courses_in_session_by_coach[$row['session_id']])) {
  283. if (in_array($row['session_id'], $tmp_sessions)) {
  284. $courses_in_session[$row['session_id']][] = $row['c_id'];
  285. }
  286. }
  287. }
  288. }
  289. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  290. api_get_user_id(),
  291. api_get_course_info()
  292. );
  293. if (api_is_drh() && !api_is_platform_admin()) {
  294. if (!empty($studentId)) {
  295. if (!api_drh_can_access_all_session_content()) {
  296. if (!($isDrhOfCourse)) {
  297. if (api_is_drh() &&
  298. !UserManager::is_user_followed_by_drh($studentId, api_get_user_id())
  299. ) {
  300. api_not_allowed(true);
  301. }
  302. }
  303. }
  304. }
  305. }
  306. Display::display_header($nameTools);
  307. if (isset($message)) {
  308. echo $message;
  309. }
  310. $token = Security::get_token();
  311. if (!empty($studentId)) {
  312. // Actions bar
  313. echo '<div class="actions">';
  314. echo '<a href="javascript: window.history.go(-1);">'.
  315. Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
  316. echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.
  317. Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_MEDIUM).'</a>';
  318. echo '<a href="'.api_get_self().'?'.Security:: remove_XSS($_SERVER['QUERY_STRING']).'&export=csv">'.
  319. Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a> ';
  320. echo '<a href="'.api_get_self().'?'.Security:: remove_XSS($_SERVER['QUERY_STRING']).'&export=xls">'.
  321. Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a> ';
  322. if (!empty($user_info['email'])) {
  323. $send_mail = '<a href="mailto:'.$user_info['email'].'">'.
  324. Display:: return_icon('mail_send.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM).'</a>';
  325. } else {
  326. $send_mail = Display:: return_icon('mail_send_na.png', get_lang('SendMail'), '', ICON_SIZE_MEDIUM);
  327. }
  328. echo $send_mail;
  329. if (!empty($studentId) && !empty($course_code)) {
  330. // Only show link to connection details if course and student were defined in the URL
  331. echo '<a href="access_details.php?student='.$studentId.'&course='.$course_code.'&origin='.$origin.'&cidReq='.$course_code.'&id_session='.$sessionId.'">'.
  332. Display:: return_icon('statistics.png', get_lang('AccessDetails'), '', ICON_SIZE_MEDIUM).'</a>';
  333. }
  334. if (api_can_login_as($studentId)) {
  335. echo '<a href="'.api_get_path(
  336. WEB_CODE_PATH
  337. ).'admin/user_list.php?action=login_as&user_id='.$studentId.'&sec_token='.$token.'">'.
  338. Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM).'</a>&nbsp;&nbsp;';
  339. }
  340. echo Display::url(
  341. Display::return_icon('skill-badges.png', get_lang('AssignSkill'), null, ICON_SIZE_MEDIUM),
  342. api_get_path(WEB_CODE_PATH).'badge/assign.php?'.http_build_query(['user' => $studentId])
  343. );
  344. echo '</div>';
  345. // is the user online ?
  346. if (user_is_online($studentId)) {
  347. $online = get_lang('Yes');
  348. } else {
  349. $online = get_lang('No');
  350. }
  351. // get average of score and average of progress by student
  352. $avg_student_progress = $avg_student_score = 0;
  353. if (CourseManager:: is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) {
  354. $avg_student_progress = Tracking::get_avg_student_progress(
  355. $user_info['user_id'],
  356. $course_code,
  357. [],
  358. $sessionId
  359. );
  360. // the score inside the Reporting table
  361. $avg_student_score = Tracking::get_avg_student_score(
  362. $user_info['user_id'],
  363. $course_code,
  364. [],
  365. $sessionId
  366. );
  367. }
  368. $avg_student_progress = round($avg_student_progress, 2);
  369. $time_spent_on_the_course = 0;
  370. if (!empty($courseInfo)) {
  371. $time_spent_on_the_course = api_time_to_hms(
  372. Tracking:: get_time_spent_on_the_course(
  373. $user_info['user_id'],
  374. $courseInfo['real_id'],
  375. $sessionId
  376. )
  377. );
  378. }
  379. // get information about connections on the platform by student
  380. $first_connection_date = Tracking:: get_first_connection_date($user_info['user_id']);
  381. if ($first_connection_date == '') {
  382. $first_connection_date = get_lang('NoConnexion');
  383. }
  384. $last_connection_date = Tracking:: get_last_connection_date($user_info['user_id'], true);
  385. if ($last_connection_date == '') {
  386. $last_connection_date = get_lang('NoConnexion');
  387. }
  388. // cvs information
  389. $csv_content[] = [
  390. get_lang('Information'),
  391. ];
  392. $csv_content[] = [
  393. get_lang('Name'),
  394. get_lang('Email'),
  395. get_lang('Tel'),
  396. ];
  397. $csv_content[] = [
  398. $user_info['complete_name'],
  399. $user_info['email'],
  400. $user_info['phone'],
  401. ];
  402. $csv_content[] = [];
  403. // csv tracking
  404. $csv_content[] = [
  405. get_lang('Tracking'),
  406. ];
  407. $csv_content[] = [
  408. get_lang('FirstLoginInPlatform'),
  409. get_lang('LatestLoginInPlatform'),
  410. get_lang('TimeSpentInTheCourse'),
  411. get_lang('Progress'),
  412. get_lang('Score'),
  413. ];
  414. $csv_content[] = [
  415. strip_tags($first_connection_date),
  416. strip_tags($last_connection_date),
  417. $time_spent_on_the_course,
  418. $avg_student_progress.'%',
  419. $avg_student_score,
  420. ];
  421. $coachs_name = '';
  422. $session_name = '';
  423. $table_title = Display::return_icon(
  424. 'user.png',
  425. get_lang('User'),
  426. [],
  427. ICON_SIZE_SMALL
  428. ).$user_info['complete_name'];
  429. echo Display::page_subheader($table_title);
  430. $userPicture = UserManager::getUserPicture($user_info['user_id']);
  431. $userGroupManager = new UserGroup();
  432. $userGroups = $userGroupManager->getNameListByUser($user_info['user_id'], UserGroup::NORMAL_CLASS); ?>
  433. <img src="<?php echo $userPicture; ?>">
  434. <div class="row">
  435. <div class="col-sm-6">
  436. <table class="table table-striped table-hover">
  437. <thead>
  438. <tr>
  439. <th><?php echo get_lang('Information'); ?></th>
  440. </tr>
  441. </thead>
  442. <tbody>
  443. <tr>
  444. <td><?php echo get_lang('Name').' : '.$user_info['complete_name']; ?></td>
  445. </tr>
  446. <tr>
  447. <td><?php echo get_lang('Email').' : ';
  448. if (!empty($user_info['email'])) {
  449. echo '<a href="mailto:'.$user_info['email'].'">'.$user_info['email'].'</a>';
  450. } else {
  451. echo get_lang('NoEmail');
  452. } ?>
  453. </td>
  454. </tr>
  455. <tr>
  456. <td> <?php echo get_lang('Tel').' : ';
  457. if (!empty($user_info['phone'])) {
  458. echo $user_info['phone'];
  459. } else {
  460. echo get_lang('NoTel');
  461. } ?>
  462. </td>
  463. </tr>
  464. <tr>
  465. <td><?php echo get_lang('OfficialCode').' : ';
  466. if (!empty($user_info['official_code'])) {
  467. echo $user_info['official_code'];
  468. } else {
  469. echo get_lang('NoOfficialCode');
  470. } ?>
  471. </td>
  472. </tr>
  473. <tr>
  474. <td><?php echo get_lang('OnLine').' : '.$online; ?> </td>
  475. </tr>
  476. <?php
  477. // Display timezone if the user selected one and if the admin allows the use of user's timezone
  478. $timezone = null;
  479. $timezone_user = UserManager::get_extra_user_data_by_field($user_info['user_id'], 'timezone');
  480. $use_users_timezone = api_get_setting('use_users_timezone', 'timezones');
  481. if ($timezone_user['timezone'] != null && $use_users_timezone == 'true') {
  482. $timezone = $timezone_user['timezone'];
  483. }
  484. if ($timezone !== null) {
  485. ?>
  486. <tr>
  487. <td> <?php echo get_lang('Timezone').' : '.$timezone; ?> </td>
  488. </tr>
  489. <?php
  490. } ?>
  491. </tbody>
  492. </table>
  493. </div>
  494. <div class="col-sm-6">
  495. <table class="table table-striped table-hover">
  496. <thead>
  497. <tr>
  498. <th colspan="2" class="text-center"><?php echo get_lang('Tracking'); ?></th>
  499. </tr>
  500. </thead>
  501. <tbody>
  502. <tr>
  503. <td align="right"><?php echo get_lang('FirstLoginInPlatform'); ?></td>
  504. <td align="left"><?php echo $first_connection_date; ?></td>
  505. </tr>
  506. <tr>
  507. <td align="right"><?php echo get_lang('LatestLoginInPlatform'); ?></td>
  508. <td align="left"><?php echo $last_connection_date; ?></td>
  509. </tr>
  510. <?php if (isset($_GET['details']) && $_GET['details'] == 'true') {
  511. ?>
  512. <tr>
  513. <td align="right"><?php echo get_lang('TimeSpentInTheCourse'); ?></td>
  514. <td align="left"><?php echo $time_spent_on_the_course; ?></td>
  515. </tr>
  516. <tr>
  517. <td align="right">
  518. <?php
  519. echo get_lang('Progress').' ';
  520. Display:: display_icon(
  521. 'info3.gif',
  522. get_lang('ScormAndLPProgressTotalAverage'),
  523. ['align' => 'absmiddle', 'hspace' => '3px']
  524. ); ?>
  525. </td>
  526. <td align="left"><?php echo $avg_student_progress.'%'; ?></td>
  527. </tr>
  528. <tr>
  529. <td align="right">
  530. <?php
  531. echo get_lang('Score').' ';
  532. Display:: display_icon(
  533. 'info3.gif',
  534. get_lang('ScormAndLPTestTotalAverage'),
  535. ['align' => 'absmiddle', 'hspace' => '3px']
  536. ); ?>
  537. </td>
  538. <td align="left"><?php
  539. if (is_numeric($avg_student_score)) {
  540. echo $avg_student_score.'%';
  541. } else {
  542. echo $avg_student_score;
  543. } ?>
  544. </td>
  545. </tr>
  546. <?php
  547. }
  548. if (api_get_setting('allow_terms_conditions') === 'true') {
  549. $isBoss = UserManager::userIsBossOfStudent(api_get_user_id(), $studentId);
  550. if ($isBoss || api_is_platform_admin()) {
  551. $extraFieldValue = new ExtraFieldValue('user');
  552. $value = $extraFieldValue->get_values_by_handler_and_field_variable(
  553. $studentId,
  554. 'legal_accept'
  555. );
  556. $icon = Display::return_icon('accept_na.png');
  557. if (isset($value['value'])) {
  558. list($legalId, $legalLanguageId, $legalTime) = explode(':', $value['value']);
  559. $icon = Display::return_icon('accept.png').' '.api_get_local_time($legalTime);
  560. $icon .= ' '.Display::url(
  561. get_lang('DeleteLegal'),
  562. api_get_self().'?action=delete_legal&student='.$studentId.'&course='.$course_code,
  563. ['class' => 'btn btn-danger btn-xs']
  564. );
  565. } else {
  566. $icon .= ' '.Display::url(
  567. get_lang('SendLegal'),
  568. api_get_self().'?action=send_legal&student='.$studentId.'&course='.$course_code,
  569. ['class' => 'btn btn-primary btn-xs']
  570. );
  571. }
  572. echo '<tr>
  573. <td align="right">';
  574. echo get_lang('LegalAccepted').' </td> <td align="left">'.$icon;
  575. echo '</td></tr>';
  576. }
  577. } ?>
  578. </tbody>
  579. </table>
  580. <?php if (!empty($userGroups)) {
  581. ?>
  582. <table class="table table-striped table-hover">
  583. <thead>
  584. <tr>
  585. <th><?php echo get_lang('Classes'); ?></th>
  586. </tr>
  587. </thead>
  588. <tbody>
  589. <?php foreach ($userGroups as $class) {
  590. ?>
  591. <tr>
  592. <td><?php echo $class; ?></td>
  593. </tr>
  594. <?php
  595. } ?>
  596. </tbody>
  597. </table>
  598. <?php
  599. } ?>
  600. </div>
  601. </div>
  602. <?php
  603. if (empty($_GET['details'])) {
  604. $csv_content[] = [];
  605. $csv_content[] = [
  606. get_lang('Session'),
  607. get_lang('Course'),
  608. get_lang('Time'),
  609. get_lang('Progress'),
  610. get_lang('Score'),
  611. get_lang('AttendancesFaults'),
  612. get_lang('Evaluations'),
  613. ];
  614. $attendance = new Attendance();
  615. foreach ($courses_in_session as $sId => $courses) {
  616. $session_name = '';
  617. $access_start_date = '';
  618. $access_end_date = '';
  619. $date_session = '';
  620. $title = Display::return_icon('course.png', get_lang('Courses'), [], ICON_SIZE_SMALL).' '.get_lang('Courses');
  621. $session_info = api_get_session_info($sId);
  622. if ($session_info) {
  623. $session_name = $session_info['name'];
  624. if (!empty($session_info['access_start_date'])) {
  625. $access_start_date = api_format_date($session_info['access_start_date'], DATE_FORMAT_SHORT);
  626. }
  627. if (!empty($session_info['access_end_date'])) {
  628. $access_end_date = api_format_date($session_info['access_end_date'], DATE_FORMAT_SHORT);
  629. }
  630. if (!empty($access_start_date) && !empty($access_end_date)) {
  631. $date_session = get_lang('From').' '.$access_start_date.' '.get_lang('Until').' '.$access_end_date;
  632. }
  633. $title = Display::return_icon(
  634. 'session.png',
  635. get_lang('Session'),
  636. [],
  637. ICON_SIZE_SMALL
  638. ).' '.$session_name.($date_session ? ' ('.$date_session.')' : '');
  639. }
  640. // Courses
  641. echo '<h3>'.$title.'</h3>';
  642. echo '<div class="table-responsive">';
  643. echo '<table class="table table-striped table-hover courses-tracking">';
  644. echo '<thead>';
  645. echo '<tr>
  646. <th>'.get_lang('Course').'</th>
  647. <th>'.get_lang('Time').'</th>
  648. <th>'.get_lang('Progress').'</th>
  649. <th>'.get_lang('Score').'</th>
  650. <th>'.get_lang('AttendancesFaults').'</th>
  651. <th>'.get_lang('Evaluations').'</th>
  652. <th>'.get_lang('Details').'</th>
  653. </tr>';
  654. echo '</thead>';
  655. echo '<tbody>';
  656. if (!empty($courses)) {
  657. foreach ($courses as $courseId) {
  658. $courseInfoItem = api_get_course_info_by_id($courseId);
  659. $courseId = $courseInfoItem['real_id'];
  660. $courseCodeItem = $courseInfoItem['code'];
  661. if (CourseManager:: is_user_subscribed_in_course($studentId, $courseCodeItem, true)) {
  662. $time_spent_on_course = api_time_to_hms(
  663. Tracking:: get_time_spent_on_the_course($user_info['user_id'], $courseId, $sId)
  664. );
  665. // get average of faults in attendances by student
  666. $results_faults_avg = $attendance->get_faults_average_by_course(
  667. $studentId,
  668. $courseCodeItem,
  669. $sId
  670. );
  671. if (!empty($results_faults_avg['total'])) {
  672. if (api_is_drh()) {
  673. $attendances_faults_avg =
  674. '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(
  675. WEB_CODE_PATH
  676. ).'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sId.'&student_id='.$studentId.'">'.
  677. $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
  678. } else {
  679. $attendances_faults_avg =
  680. $results_faults_avg['faults'].'/'.
  681. $results_faults_avg['total'].
  682. ' ('.$results_faults_avg['porcent'].'%)';
  683. }
  684. } else {
  685. $attendances_faults_avg = '0/0 (0%)';
  686. }
  687. // Get evaluations by student
  688. $cats = Category::load(null, null, $courseCodeItem, null, null, $sId);
  689. $scoretotal = [];
  690. if (isset($cats) && isset($cats[0])) {
  691. if (!empty($sId)) {
  692. $scoretotal = $cats[0]->calc_score($studentId, null, $courseCodeItem, $sId);
  693. } else {
  694. $scoretotal = $cats[0]->calc_score($studentId, null, $courseCodeItem);
  695. }
  696. }
  697. $scoretotal_display = '0/0 (0%)';
  698. if (!empty($scoretotal) && !empty($scoretotal[1])) {
  699. $scoretotal_display =
  700. round($scoretotal[0], 1).'/'.
  701. round($scoretotal[1], 1).
  702. ' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)';
  703. }
  704. $progress = Tracking::get_avg_student_progress(
  705. $user_info['user_id'],
  706. $courseCodeItem,
  707. null,
  708. $sId
  709. );
  710. $score = Tracking:: get_avg_student_score($user_info['user_id'], $courseCodeItem, [], $sId);
  711. $progress = empty($progress) ? '0%' : $progress.'%';
  712. $score = empty($score) ? '0%' : $score.'%';
  713. $csv_content[] = [
  714. $session_name,
  715. $courseInfoItem['title'],
  716. $time_spent_on_course,
  717. $progress,
  718. $score,
  719. $attendances_faults_avg,
  720. $scoretotal_display,
  721. ];
  722. echo '<tr>
  723. <td ><a href="'.$courseInfoItem['course_public_url'].'?id_session='.$sId.'">'.
  724. $courseInfoItem['title'].'</a></td>
  725. <td >'.$time_spent_on_course.'</td>
  726. <td >'.$progress.'</td>
  727. <td >'.$score.'</td>
  728. <td >'.$attendances_faults_avg.'</td>
  729. <td >'.$scoretotal_display.'</td>';
  730. if (!empty($coachId)) {
  731. echo '<td width="10"><a href="'.api_get_self().
  732. '?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&id_coach='.$coachId.
  733. '&origin='.$origin.'&id_session='.$sId.'#infosStudent">
  734. '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
  735. } else {
  736. echo '<td width="10"><a href="'.api_get_self(
  737. ).'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&origin='.$origin.'&id_session='.$sId.'#infosStudent">
  738. '.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
  739. }
  740. echo '</tr>';
  741. }
  742. }
  743. } else {
  744. echo "<tr><td colspan='5'>".get_lang('NoCourse')."</td></tr>";
  745. }
  746. echo '</tbody>';
  747. echo '</table>';
  748. echo '</div>';
  749. }
  750. } else {
  751. if ($user_info['status'] != INVITEE) {
  752. $csv_content[] = [];
  753. $csv_content[] = [str_replace('&nbsp;', '', $table_title)];
  754. $t_lp = Database:: get_course_table(TABLE_LP_MAIN);
  755. // csv export headers
  756. $csv_content[] = [];
  757. $csv_content[] = [
  758. get_lang('Learnpath'),
  759. get_lang('Time'),
  760. get_lang('AverageScore'),
  761. get_lang('LatestAttemptAverageScore'),
  762. get_lang('Progress'),
  763. get_lang('LastConnexion'),
  764. ];
  765. $query = $em
  766. ->createQuery(
  767. '
  768. SELECT lp FROM ChamiloCourseBundle:CLp lp
  769. WHERE lp.sessionId = :session AND lp.cId = :course
  770. ORDER BY lp.displayOrder ASC
  771. '
  772. );
  773. if (empty($sessionId)) {
  774. $query->setParameters(
  775. [
  776. 'session' => 0,
  777. 'course' => $courseInfo['real_id'],
  778. ]
  779. );
  780. } else {
  781. $query->setParameters(
  782. [
  783. 'session' => $sessionId,
  784. 'course' => $courseInfo['real_id'],
  785. ]
  786. );
  787. }
  788. $rs_lp = $query->getResult();
  789. if (count($rs_lp) > 0) {
  790. ?>
  791. <!-- LPs-->
  792. <div class="table-responsive">
  793. <table class="table table-striped table-hover">
  794. <thead>
  795. <tr>
  796. <th><?php echo get_lang('LearningPath'); ?></th>
  797. <th>
  798. <?php
  799. echo get_lang('Time').' ';
  800. Display:: display_icon(
  801. 'info3.gif',
  802. get_lang('TotalTimeByCourse'),
  803. ['align' => 'absmiddle', 'hspace' => '3px']
  804. ); ?>
  805. </th>
  806. <th>
  807. <?php
  808. echo get_lang('AverageScore').' ';
  809. Display:: display_icon(
  810. 'info3.gif',
  811. get_lang('AverageIsCalculatedBasedInAllAttempts'),
  812. ['align' => 'absmiddle', 'hspace' => '3px']
  813. ); ?>
  814. </th>
  815. <th><?php
  816. echo get_lang('LatestAttemptAverageScore').' ';
  817. Display::display_icon(
  818. 'info3.gif',
  819. get_lang('AverageIsCalculatedBasedInTheLatestAttempts'),
  820. ['align' => 'absmiddle', 'hspace' => '3px']
  821. ); ?>
  822. </th>
  823. <th><?php
  824. echo get_lang('Progress').' ';
  825. Display:: display_icon(
  826. 'info3.gif',
  827. get_lang('LPProgressScore'),
  828. ['align' => 'absmiddle', 'hspace' => '3px']
  829. ); ?>
  830. </th>
  831. <th><?php
  832. echo get_lang('LastConnexion').' ';
  833. Display:: display_icon(
  834. 'info3.gif',
  835. get_lang('LastTimeTheCourseWasUsed'),
  836. ['align' => 'absmiddle', 'hspace' => '3px']
  837. ); ?>
  838. </th>
  839. <?php
  840. echo '<th>'.get_lang('Details').'</th>';
  841. if (api_is_allowed_to_edit()) {
  842. echo '<th>'.get_lang('ResetLP').'</th>';
  843. } ?>
  844. </tr>
  845. </thead>
  846. <tbody>
  847. <?php
  848. $i = 0;
  849. foreach ($rs_lp as $learnpath) {
  850. $lp_id = $learnpath->getId();
  851. $lp_name = $learnpath->getName();
  852. $any_result = false;
  853. // Get progress in lp
  854. $progress = Tracking::get_avg_student_progress(
  855. $studentId,
  856. $course_code,
  857. [$lp_id],
  858. $sessionId
  859. );
  860. if ($progress === null) {
  861. $progress = '0%';
  862. } else {
  863. $any_result = true;
  864. }
  865. // Get time in lp
  866. $total_time = Tracking::get_time_spent_in_lp(
  867. $studentId,
  868. $course_code,
  869. [$lp_id],
  870. $sessionId
  871. );
  872. if (!empty($total_time)) {
  873. $any_result = true;
  874. }
  875. // Get last connection time in lp
  876. $start_time = Tracking::get_last_connection_time_in_lp(
  877. $studentId,
  878. $course_code,
  879. $lp_id,
  880. $sessionId
  881. );
  882. if (!empty($start_time)) {
  883. $start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
  884. } else {
  885. $start_time = '-';
  886. }
  887. if (!empty($total_time)) {
  888. $any_result = true;
  889. }
  890. // Quiz in lp
  891. $score = Tracking::get_avg_student_score(
  892. $studentId,
  893. $course_code,
  894. [$lp_id],
  895. $sessionId
  896. );
  897. // Latest exercise results in a LP
  898. $score_latest = Tracking:: get_avg_student_score(
  899. $studentId,
  900. $course_code,
  901. [$lp_id],
  902. $sessionId,
  903. false,
  904. true
  905. );
  906. if ($i % 2 == 0) {
  907. $css_class = "row_even";
  908. } else {
  909. $css_class = "row_odd";
  910. }
  911. $i++;
  912. // csv export content
  913. $csv_content[] = [
  914. api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
  915. api_time_to_hms($total_time),
  916. $score.'%',
  917. $score_latest.'%',
  918. $progress.'%',
  919. $start_time,
  920. ];
  921. echo '<tr class="'.$css_class.'">';
  922. echo Display::tag('td', stripslashes($lp_name));
  923. echo Display::tag('td', api_time_to_hms($total_time));
  924. if (!is_null($score)) {
  925. if (is_numeric($score)) {
  926. $score = $score.'%';
  927. }
  928. }
  929. echo Display::tag('td', $score);
  930. if (!is_null($score_latest)) {
  931. if (is_numeric($score_latest)) {
  932. $score_latest = $score_latest.'%';
  933. }
  934. }
  935. echo Display::tag('td', $score_latest);
  936. if (is_numeric($progress)) {
  937. $progress = $progress.'%';
  938. } else {
  939. $progress = '-';
  940. }
  941. echo Display::tag('td', $progress);
  942. // Do not change with api_convert_and_format_date, because
  943. // this value came from the lp_item_view table
  944. // which implies several other changes not a priority right now
  945. echo Display::tag('td', $start_time);
  946. if ($any_result === true) {
  947. $from = '';
  948. if ($from_myspace) {
  949. $from = '&from=myspace';
  950. }
  951. $link = Display::url(
  952. Display::return_icon('2rightarrow.png', get_lang('Details')),
  953. 'lp_tracking.php?cidReq='.$course_code.'&course='.$course_code.$from.'&origin='.$origin.'&lp_id='.$learnpath->getId(
  954. ).'&student_id='.$user_info['user_id'].'&id_session='.$sessionId
  955. );
  956. echo Display::tag('td', $link);
  957. }
  958. if (api_is_allowed_to_edit()) {
  959. echo '<td>';
  960. if ($any_result === true) {
  961. echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.
  962. '&cidReq='.$course_code.
  963. '&course='.$course_code.
  964. '&details='.Security::remove_XSS($_GET['details']).
  965. '&origin='.$origin.
  966. '&lp_id='.$learnpath->getId().
  967. '&student='.$user_info['user_id'].
  968. '&details=true&id_session='.$sessionId.'">';
  969. echo Display::return_icon(
  970. 'clean.png',
  971. get_lang('Clean'),
  972. '',
  973. ICON_SIZE_SMALL
  974. ).'</a>';
  975. echo '</a>';
  976. }
  977. echo '</td>';
  978. echo '</tr>';
  979. }
  980. $data_learnpath[$i][] = $lp_name;
  981. $data_learnpath[$i][] = $progress.'%';
  982. } ?>
  983. </tbody>
  984. </table>
  985. </div>
  986. <?php
  987. }
  988. } ?>
  989. <!-- line about exercises -->
  990. <?php if ($user_info['status'] != INVITEE) {
  991. ?>
  992. <div class="table-responsive">
  993. <table class="table table-striped table-hover">
  994. <thead>
  995. <tr>
  996. <th><?php echo get_lang('Exercises'); ?></th>
  997. <th><?php echo get_lang('LearningPath'); ?></th>
  998. <th><?php echo get_lang('AvgCourseScore').' '.Display:: return_icon(
  999. 'info3.gif',
  1000. get_lang('AverageScore'),
  1001. ['align' => 'absmiddle', 'hspace' => '3px']
  1002. ); ?></th>
  1003. <th><?php echo get_lang('Attempts'); ?></th>
  1004. <th><?php echo get_lang('LatestAttempt'); ?></th>
  1005. <th><?php echo get_lang('AllAttempts'); ?></th>
  1006. </tr>
  1007. </thead>
  1008. <tbody>
  1009. <?php
  1010. $csv_content[] = [];
  1011. $csv_content[] = [
  1012. get_lang('Exercises'),
  1013. get_lang('LearningPath'),
  1014. get_lang('AvgCourseScore'),
  1015. get_lang('Attempts'),
  1016. ];
  1017. $t_quiz = Database:: get_course_table(TABLE_QUIZ_TEST);
  1018. $sessionCondition = api_get_session_condition(
  1019. $sessionId,
  1020. true,
  1021. true,
  1022. 'quiz.session_id'
  1023. );
  1024. $sql = "SELECT quiz.title, id FROM $t_quiz AS quiz
  1025. WHERE
  1026. quiz.c_id = ".$courseInfo['real_id']." AND
  1027. active IN (0, 1)
  1028. $sessionCondition
  1029. ORDER BY quiz.title ASC ";
  1030. $result_exercices = Database::query($sql);
  1031. $i = 0;
  1032. if (Database:: num_rows($result_exercices) > 0) {
  1033. while ($exercices = Database:: fetch_array($result_exercices)) {
  1034. $exercise_id = intval($exercices['id']);
  1035. $count_attempts = Tracking::count_student_exercise_attempts(
  1036. $studentId,
  1037. $courseInfo['real_id'],
  1038. $exercise_id,
  1039. 0,
  1040. 0,
  1041. $sessionId,
  1042. 2
  1043. );
  1044. $score_percentage = Tracking::get_avg_student_exercise_score(
  1045. $studentId,
  1046. $course_code,
  1047. $exercise_id,
  1048. $sessionId,
  1049. 1,
  1050. 0
  1051. );
  1052. if (!isset($score_percentage) && $count_attempts > 0) {
  1053. $scores_lp = Tracking::get_avg_student_exercise_score(
  1054. $studentId,
  1055. $course_code,
  1056. $exercise_id,
  1057. $sessionId,
  1058. 2,
  1059. 1
  1060. );
  1061. $score_percentage = $scores_lp[0];
  1062. $lp_name = $scores_lp[1];
  1063. } else {
  1064. $lp_name = '-';
  1065. }
  1066. $lp_name = !empty($lp_name) ? $lp_name : get_lang('NoLearnpath');
  1067. if ($i % 2) {
  1068. $css_class = 'row_odd';
  1069. } else {
  1070. $css_class = 'row_even';
  1071. }
  1072. echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
  1073. echo '<td>';
  1074. if (!empty($lp_name)) {
  1075. echo $lp_name;
  1076. } else {
  1077. echo '-';
  1078. }
  1079. echo '</td>';
  1080. echo '<td>';
  1081. if ($count_attempts > 0) {
  1082. echo $score_percentage.'%';
  1083. } else {
  1084. echo '-';
  1085. $score_percentage = 0;
  1086. }
  1087. echo '</td>';
  1088. echo '<td>'.$count_attempts.'</td>';
  1089. echo '<td>';
  1090. $sql = "SELECT exe_id FROM $tbl_stats_exercices
  1091. WHERE
  1092. exe_exo_id = $exercise_id AND
  1093. exe_user_id = $studentId AND
  1094. c_id = ".$courseInfo['real_id']." AND
  1095. session_id = $sessionId AND
  1096. status = ''
  1097. ORDER BY exe_date DESC
  1098. LIMIT 1";
  1099. $result_last_attempt = Database::query($sql);
  1100. if (Database:: num_rows($result_last_attempt) > 0) {
  1101. $id_last_attempt = Database:: result($result_last_attempt, 0, 0);
  1102. if ($count_attempts > 0) {
  1103. echo '<a href="../exercise/exercise_show.php?id='.$id_last_attempt.
  1104. '&cidReq='.$course_code.
  1105. '&session_id='.$sessionId.
  1106. '&student='.$studentId.
  1107. '&origin='.(empty($origin) ? 'tracking' : $origin).
  1108. '">';
  1109. echo Display::return_icon('quiz.gif');
  1110. echo '</a>';
  1111. }
  1112. }
  1113. echo '</td>';
  1114. echo '<td>';
  1115. $all_attempt_url = "../exercise/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$studentId&id_session=$sessionId";
  1116. echo Display::url(
  1117. Display::return_icon(
  1118. 'test_results.png',
  1119. get_lang('AllAttempts'),
  1120. [],
  1121. ICON_SIZE_SMALL
  1122. ),
  1123. $all_attempt_url
  1124. );
  1125. echo '</td></tr>';
  1126. $data_exercices[$i][] = $exercices['title'];
  1127. $data_exercices[$i][] = $score_percentage.'%';
  1128. $data_exercices[$i][] = $count_attempts;
  1129. $csv_content[] = [
  1130. $exercices['title'],
  1131. $lp_name,
  1132. $score_percentage,
  1133. $count_attempts,
  1134. ];
  1135. $i++;
  1136. }
  1137. } else {
  1138. echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
  1139. } ?>
  1140. </tbody>
  1141. </table>
  1142. </div>
  1143. <?php
  1144. }
  1145. // @when using sessions we do not show the survey list
  1146. if (empty($sessionId)) {
  1147. $survey_list = SurveyManager::get_surveys($course_code, $sessionId);
  1148. $survey_data = [];
  1149. foreach ($survey_list as $survey) {
  1150. $user_list = SurveyManager::get_people_who_filled_survey(
  1151. $survey['survey_id'],
  1152. false,
  1153. $courseInfo['real_id']
  1154. );
  1155. $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), [], ICON_SIZE_SMALL);
  1156. if (in_array($studentId, $user_list)) {
  1157. $survey_done = Display::return_icon("accept.png", get_lang('Answered'), [], ICON_SIZE_SMALL);
  1158. }
  1159. $data = ['title' => $survey['title'], 'done' => $survey_done];
  1160. $survey_data[] = $data;
  1161. }
  1162. if (!empty($survey_list)) {
  1163. $table = new HTML_Table(['class' => 'data_table']);
  1164. $header_names = [get_lang('Survey'), get_lang('Answered')];
  1165. $row = 0;
  1166. $column = 0;
  1167. foreach ($header_names as $item) {
  1168. $table->setHeaderContents($row, $column, $item);
  1169. $column++;
  1170. }
  1171. $row = 1;
  1172. if (!empty($survey_data)) {
  1173. foreach ($survey_data as $data) {
  1174. $column = 0;
  1175. $table->setCellContents($row, $column, $data);
  1176. $class = 'class="row_odd"';
  1177. if ($row % 2) {
  1178. $class = 'class="row_even"';
  1179. }
  1180. $table->setRowAttributes($row, $class, true);
  1181. $column++;
  1182. $row++;
  1183. }
  1184. }
  1185. echo $table->toHtml();
  1186. }
  1187. }
  1188. // line about other tools?>
  1189. <div class="table-responsive">
  1190. <table class="table table-striped table-hover">
  1191. <thead>
  1192. <tr>
  1193. <th colspan="2"><?php echo get_lang('OtherTools'); ?></th>
  1194. </tr>
  1195. </thead>
  1196. <tbody>
  1197. <?php
  1198. $csv_content[] = [];
  1199. $nb_assignments = Tracking::count_student_assignments($studentId, $course_code, $sessionId);
  1200. $messages = Tracking::count_student_messages($studentId, $course_code, $sessionId);
  1201. $links = Tracking::count_student_visited_links($studentId, $courseInfo['real_id'], $sessionId);
  1202. $chat_last_connection = Tracking::chat_last_connection($studentId, $courseInfo['real_id'], $sessionId);
  1203. $documents = Tracking::count_student_downloaded_documents(
  1204. $studentId,
  1205. $courseInfo['real_id'],
  1206. $sessionId
  1207. );
  1208. $uploaded_documents = Tracking::count_student_uploaded_documents($studentId, $course_code, $sessionId);
  1209. $csv_content[] = [
  1210. get_lang('OtherTools'),
  1211. ];
  1212. $csv_content[] = [
  1213. get_lang('Student_publication'),
  1214. $nb_assignments,
  1215. ];
  1216. $csv_content[] = [
  1217. get_lang('Messages'),
  1218. $messages,
  1219. ];
  1220. $csv_content[] = [
  1221. get_lang('LinksDetails'),
  1222. $links,
  1223. ];
  1224. $csv_content[] = [
  1225. get_lang('DocumentsDetails'),
  1226. $documents,
  1227. ];
  1228. $csv_content[] = [
  1229. get_lang('UploadedDocuments'),
  1230. $uploaded_documents,
  1231. ];
  1232. $csv_content[] = [
  1233. get_lang('ChatLastConnection'),
  1234. $chat_last_connection,
  1235. ]; ?>
  1236. <tr><!-- assignments -->
  1237. <td width="40%"><?php echo get_lang('Student_publication'); ?></td>
  1238. <td><?php echo $nb_assignments; ?></td>
  1239. </tr>
  1240. <tr><!-- messages -->
  1241. <td><?php echo get_lang('Forum').' - '.get_lang('NumberOfPostsForThisUser'); ?></td>
  1242. <td><?php echo $messages; ?></td>
  1243. </tr>
  1244. <tr><!-- links -->
  1245. <td><?php echo get_lang('LinksDetails'); ?></td>
  1246. <td><?php echo $links; ?></td>
  1247. </tr>
  1248. <tr><!-- downloaded documents -->
  1249. <td><?php echo get_lang('DocumentsDetails'); ?></td>
  1250. <td><?php echo $documents; ?></td>
  1251. </tr>
  1252. <tr><!-- uploaded documents -->
  1253. <td><?php echo get_lang('UploadedDocuments'); ?></td>
  1254. <td><?php echo $uploaded_documents; ?></td>
  1255. </tr>
  1256. <tr><!-- Chats -->
  1257. <td><?php echo get_lang('ChatLastConnection'); ?></td>
  1258. <td><?php echo $chat_last_connection; ?></td>
  1259. </tr>
  1260. </tbody>
  1261. </table>
  1262. </div>
  1263. <?php
  1264. } //end details
  1265. echo Tracking::displayUserSkills(
  1266. $user_info['user_id'],
  1267. $courseInfo ? $courseInfo['real_id'] : 0,
  1268. $sessionId
  1269. );
  1270. }
  1271. if ($export) {
  1272. ob_end_clean();
  1273. switch ($export) {
  1274. case 'csv':
  1275. Export::arrayToCsv($csv_content, 'reporting_student');
  1276. break;
  1277. case 'xls':
  1278. Export::arrayToXls($csv_content, 'reporting_student');
  1279. break;
  1280. }
  1281. exit;
  1282. }
  1283. //Adding AB stuff 2016-12-14 CEMEQ
  1284. $TABLECALHORAIRE = 'c_cal_horaire';
  1285. $coursesList = [];
  1286. //On cherche le calendrier pour ce user dans ce cours, groupe
  1287. $sql = "SELECT * FROM user WHERE user_id = $studentId";
  1288. $result = Database::query($sql);
  1289. $horaire_id = Database::fetch_array($result);
  1290. $nom_hor = $horaire_id['official_code'];
  1291. $course_code_real = $_course['real_id'];
  1292. //avec le nom d'horaire= official code, on trouve le nombre de jour a faire
  1293. $sql = "SELECT * FROM $TABLECALHORAIRE
  1294. where
  1295. name = '$nom_hor' and
  1296. c_id = $course_code_real ";
  1297. $res = Database::query($sql);
  1298. $resulta = Database::fetch_array($res);
  1299. $num_hours = $resulta['num_hours'];
  1300. $num_minute = $resulta['num_minute'];
  1301. if ($num_minute == '0') {
  1302. $num_minute = '1';
  1303. }
  1304. $minute_mod = $num_hours * 60;
  1305. $num_days = 0;
  1306. if (!empty($num_minute)) {
  1307. $num_days = $minute_mod / $num_minute;
  1308. }
  1309. // affichage des jours complétés dans les parcours l'élève
  1310. //on recherche les cours où sont inscrit les user
  1311. $sql2 = "SELECT c_id, user_id FROM course_rel_user WHERE user_id = $studentId";
  1312. $result2 = Database::query($sql2);
  1313. $Total = 0;
  1314. while ($a_courses = Database::fetch_array($result2)) {
  1315. $Courses_code = $a_courses['c_id'];
  1316. //on sort le c_id avec le code du cours
  1317. $sql8 = "SELECT * FROM course WHERE code = '$Courses_code'
  1318. ";
  1319. $result8 = Database::query($sql8);
  1320. $course_code_id = Database::fetch_array($result8);
  1321. $c_id = $Courses_code;
  1322. // pours chaque cours dans lequel il est inscrit, on cherche les jours complétés
  1323. $Req1 = "SELECT * FROM c_lp_view
  1324. WHERE user_id = $studentId AND c_id = $c_id";
  1325. $res = Database::query($Req1);
  1326. while ($result = Database::fetch_array($res)) {
  1327. $lp_id = $result['lp_id'];
  1328. $lp_id_view = $result['id'];
  1329. $c_id_view = $result['c_id'];
  1330. $Req2 = "SELECT id, lp_id ,title ,item_type
  1331. FROM c_lp_item
  1332. WHERE lp_id = $lp_id
  1333. AND title LIKE '(+)%'
  1334. AND c_id = $c_id_view
  1335. AND item_type = 'document'
  1336. ";
  1337. $res2 = Database::query($Req2);
  1338. while ($resulta = Database::fetch_array($res2)) {
  1339. $lp_item_id = $resulta['id'];
  1340. $Req3 = "SELECT MAX(id)
  1341. FROM c_lp_item_view
  1342. WHERE
  1343. lp_item_id = $lp_item_id AND
  1344. lp_view_id = $lp_id_view AND
  1345. c_id = $c_id_view AND
  1346. status = 'completed'
  1347. ";
  1348. $res3 = Database::query($Req3);
  1349. while ($resul = Database::fetch_array($res3)) {
  1350. $max = $resul['0'];
  1351. $Req4 = "SELECT COUNT( id )
  1352. FROM c_lp_item_view
  1353. WHERE
  1354. id = $max AND
  1355. c_id = $c_id_view";
  1356. $res4 = Database::query($Req4);
  1357. while ($resultat = Database::fetch_array($res4)) {
  1358. $Total = $Total + $resultat[0];
  1359. }
  1360. }
  1361. }
  1362. }
  1363. }
  1364. api_display_tool_title($nameTools);
  1365. $tbl_personal_agenda = Database:: get_main_table(TABLE_PERSONAL_AGENDA);
  1366. $now = date('Y-m-d');
  1367. //on compte le nombre de m% dans l'agenda pour chaque module
  1368. $sqljtot = "SELECT COUNT( * ) AS TOT
  1369. FROM $tbl_personal_agenda
  1370. WHERE user = $studentId
  1371. And title like 'm%'";
  1372. $resultjt = Database::query($sqljtot);
  1373. $jour_realise = 0;
  1374. while ($jtot = Database::fetch_array($resultjt)) {
  1375. $jour_realise_tot = ($jour_realise + $jtot['TOT']) / 2;
  1376. }
  1377. //fin des jour de l'agenda
  1378. //recherche du jour inséré dans agenda par le calendrier
  1379. $jour_agenda = '';
  1380. $tour = -1;
  1381. while ($jour_agenda == '') {
  1382. $tour++;
  1383. $date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $tour, date("Y")));
  1384. $sql4 = "SELECT * FROM $tbl_personal_agenda
  1385. WHERE
  1386. user = $studentId AND
  1387. text='Pour le calendrier, ne pas effacer' AND
  1388. date like '".$date." %:%' ";
  1389. $result4 = Database::query($sql4);
  1390. $res4 = Database::fetch_array($result4);
  1391. $jour_agenda = $res4['title'];
  1392. if ($tour > 300) {
  1393. break;
  1394. }
  1395. }
  1396. $diff = $jour_agenda - $Total;
  1397. if ($diff > 0) {
  1398. $sing = get_lang('retard');
  1399. } else {
  1400. $sing = get_lang('avance');
  1401. }
  1402. $diff = abs($diff);
  1403. //pour trouver la date de fin de sa formation, on ajoute les retard (%diff) au nombre de jours total de la formation et
  1404. //on regarde dans son agenda pour cette valeur qui donne ainsi la date
  1405. $diff2 = $jour_agenda - $Total;
  1406. $goto = $num_days + $diff2;
  1407. $goto = number_format($goto);
  1408. $sqlgo = "SELECT * FROM $tbl_personal_agenda
  1409. WHERE user = $studentId
  1410. AND title = '".$goto."'
  1411. ";
  1412. $result7 = Database::query($sqlgo);
  1413. $res7 = Database::fetch_array($result7);
  1414. $end_dates = $res7['date'];
  1415. $end_date = date("Y-m-d", strtotime($end_dates));
  1416. if ($end_date < '2010-01-01') {
  1417. $end_date = get_lang('hors_cal');
  1418. }
  1419. ?>
  1420. <table class="data_table">
  1421. <th rowspan="6">
  1422. <?php
  1423. //on récupere les points de controle de l'élève
  1424. /*$pt[] = '0';
  1425. $pt[] = '0';
  1426. $sqlcontrole = "SELECT diff
  1427. FROM $tbl_stats_exercices
  1428. WHERE exe_user_id = ".$studentId."
  1429. AND diff != ''
  1430. ORDER BY exe_date ASC
  1431. ";
  1432. $result = Database::query($sqlcontrole);
  1433. while ($ptctl = Database::fetch_array($result)) {
  1434. $pt[] = $ptctl ['diff'];
  1435. }
  1436. //graphique de suivi
  1437. include "../inc/teechartphp/sources/TChart.php";
  1438. $chart = new TChart(500, 300);
  1439. $chart->getAspect()->setView3D(false);
  1440. $chart->getHeader()->setText("Graphique de suivi");
  1441. $chart->getAxes()->getLeft()->setMinimumOffset(10);
  1442. $chart->getAxes()->getLeft()->setMaximumOffset(10);
  1443. $chart->getAxes()->getBottom()->setMinimumOffset(10);
  1444. $chart->getAxes()->getBottom()->setMaximumOffset(10);
  1445. $line1 = new Line($chart->getChart());
  1446. $data = $pt;
  1447. $line1->addArray($data);
  1448. foreach ($chart->getSeries() as $serie) {
  1449. $pointer = $serie->getPointer();
  1450. $pointer->setVisible(true);
  1451. $pointer->getPen()->setVisible(false);
  1452. $pointer->setHorizSize(2);
  1453. $pointer->setVertSize(2);
  1454. $marks = $serie->getMarks();
  1455. $marks->setVisible(true);
  1456. $marks->setArrowLength(5);
  1457. $marks->getArrow()->setVisible(false);
  1458. $marks->setTransparent(true);
  1459. }
  1460. $x = $student_id;
  1461. $line1->getPointer()->setStyle(PointerStyle::$CIRCLE);
  1462. $chart->getLegend()->setVisible(false);
  1463. $chart->render("../garbage/$x-image.png");
  1464. $rand = rand();
  1465. print '<img src="../garbage/'.$x.'-image.png?rand='.$rand.'">';
  1466. */
  1467. ?>
  1468. <tr>
  1469. <th align="left" width="412">
  1470. <?php echo get_lang('Cumulatif_agenda'); ?>: <b><font
  1471. color=#CC0000> <?php echo $jour_realise_tot; ?></font></b></p>
  1472. </th>
  1473. </tr>
  1474. <tr>
  1475. <th align="left">
  1476. <?php echo get_lang('Cumulatif'); ?> <b><font color=#CC0000> <?php echo $Total; ?></font></b></p>
  1477. </th>
  1478. </tr>
  1479. <tr>
  1480. <th align="left">
  1481. <?php echo get_lang('jours_selon_horaire'); ?>: <b><font
  1482. color=#CC0000> <?php echo $jour_agenda; ?><?php echo $Days; ?></font></b></p>
  1483. </th>
  1484. </tr>
  1485. <tr>
  1486. <th align="left">
  1487. <?php echo get_lang('dif2'); ?>: <b><font
  1488. color=#CC0000> <?php echo $diff; ?><?php echo $Days, $sing; ?></font></b></p>
  1489. </th>
  1490. </tr>
  1491. <tr>
  1492. <th align="left">
  1493. <?php echo get_lang('date_fin'); ?>: <b><font color=#CC0000> <?php echo $end_date; ?></font></b></p>
  1494. </th>
  1495. </tr>
  1496. </th>
  1497. </table>
  1498. <hr>
  1499. <br>
  1500. <form action="create_intervention.php" method="post" name="create_intervention">
  1501. <table class='data_table'>
  1502. <tr>
  1503. <th colspan="6">
  1504. <?php echo get_lang('create_interventions_commentaires');
  1505. echo $user_info['complete_name']; ?>
  1506. </th>
  1507. <tr>
  1508. <th><?php echo get_lang('level'); ?></th>
  1509. <th><?php echo get_lang('lang_date'); ?></th>
  1510. <th><?php echo get_lang('consignes_interventions'); ?></th>
  1511. <th><?php echo get_lang('Actions'); ?></th>
  1512. </tr>
  1513. <tr>
  1514. <td>
  1515. <select name="level">
  1516. <option value="1">1</option>
  1517. <option value="2">2</option>
  1518. <option value="3">3</option>
  1519. </select>
  1520. </td>
  1521. <td>
  1522. <input type="text" name="date" value="<?php echo date("Y-m-d"); ?>">
  1523. </td>
  1524. <td><textarea name="inter_coment" style="width:90%;" rows="2"> </textarea></td>
  1525. <INPUT type=hidden name=ex_user_id value= <?php echo $studentId; ?>>
  1526. <td><input type="SUBMIT" value="Sauvegarder" name="B1"></td>
  1527. </tr>
  1528. </table>
  1529. </form>
  1530. <?php
  1531. // formulaire d'édition des commentaires
  1532. ?>
  1533. <form>
  1534. <table class='data_table'>
  1535. <tr>
  1536. <th><?php echo get_lang('level'); ?> </th>
  1537. <th>
  1538. <?php echo get_lang('lang_date'); ?>
  1539. </th>
  1540. <th>
  1541. <?php echo get_lang('interventions_commentaires'); ?>
  1542. </th>
  1543. <th>
  1544. <?php echo get_lang('Actions'); ?>
  1545. </th>
  1546. </tr>
  1547. <?php
  1548. $tbl_stats_exercices = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
  1549. $sqlinter = "SELECT *
  1550. FROM $tbl_stats_exercices
  1551. WHERE
  1552. exe_user_id = $studentId AND
  1553. level != 0
  1554. ORDER BY exe_date ASC, level ASC
  1555. ";
  1556. $resultinter = Database::query($sqlinter);
  1557. $mod_no = null;
  1558. while ($a_inter = Database::fetch_array($resultinter)) {
  1559. $level = $a_inter['level'];
  1560. $mod_no = $a_inter['mod_no'];
  1561. $inter_coment = stripslashes($a_inter['inter_coment']);
  1562. $inter_date = substr($a_inter['exe_date'], 0, 11);
  1563. echo "
  1564. <tr><center>
  1565. <td> ".$a_inter['level']."
  1566. </td>
  1567. <td>
  1568. $inter_date
  1569. </td>
  1570. <td>$inter_coment
  1571. </td>
  1572. ";
  1573. $exe_id = $a_inter['exe_id']; ?>
  1574. <td class="highlight">
  1575. <a href="edit_intervention.php?num=<?php echo $exe_id; ?>&student_id=<?php echo $studentId; ?> ">
  1576. <?php echo Display::return_icon('edit.png', get_lang('Edit')); ?></a>
  1577. &nbsp;&nbsp; <a
  1578. href="delete_exam.php?num=<?php echo $exe_id; ?>&student_id=<?php echo $studentId; ?>">
  1579. <img
  1580. src="../img/delete.gif" border="0"
  1581. onClick='return confirmDelete2()'>
  1582. </a>
  1583. <?php
  1584. }
  1585. ?>
  1586. </td>
  1587. </form>
  1588. <?php
  1589. $table_title = '';
  1590. if (!empty($session_id)) {
  1591. $session_name = api_get_session_name($session_id);
  1592. $table_title = ($session_name ? Display::return_icon(
  1593. 'session.png',
  1594. get_lang('Session'),
  1595. [],
  1596. ICON_SIZE_SMALL
  1597. ).' '.$session_name.' ' : '');
  1598. }
  1599. if (!empty($info_course['title'])) {
  1600. $table_title .= ($info_course ? Display::return_icon(
  1601. 'course.png',
  1602. get_lang('Course'),
  1603. [],
  1604. ICON_SIZE_SMALL
  1605. ).' '.$info_course['title'].' ' : '');
  1606. }
  1607. echo Display::page_subheader($table_title);
  1608. if (empty($_GET['details'])) {
  1609. $csv_content[] = [];
  1610. $csv_content[] = [
  1611. get_lang('Session', ''),
  1612. get_lang('Course', ''),
  1613. get_lang('Time', ''),
  1614. get_lang('Progress', ''),
  1615. get_lang('Score', ''),
  1616. get_lang('AttendancesFaults', ''),
  1617. get_lang('Evaluations'),
  1618. ];
  1619. $attendance = new Attendance();
  1620. foreach ($courses_in_session as $key => $courses) {
  1621. $session_id = $key;
  1622. $session_info = api_get_session_info($session_id);
  1623. $session_name = '';
  1624. if (!empty($session_info)) {
  1625. $session_name = $session_info['name'];
  1626. }
  1627. $date_start = '';
  1628. if (!empty($session_info['date_start']) && $session_info['date_start'] != '0000-00-00') {
  1629. $date_start = api_format_date($session_info['date_start'], DATE_FORMAT_SHORT);
  1630. }
  1631. $date_end = '';
  1632. if (!empty($session_info['date_end']) && $session_info['date_end'] != '0000-00-00') {
  1633. $date_end = api_format_date($session_info['date_end'], DATE_FORMAT_SHORT);
  1634. }
  1635. if (!empty($date_start) && !empty($date_end)) {
  1636. $date_session = get_lang('From').' '.$date_start.' '.get_lang('Until').' '.$date_end;
  1637. }
  1638. $title = '';
  1639. if (empty($session_id)) {
  1640. $title = Display::return_icon('course.png', get_lang('Course'), [], ICON_SIZE_SMALL).' '.get_lang(
  1641. 'Course'
  1642. );
  1643. } else {
  1644. $title = Display::return_icon(
  1645. 'session.png',
  1646. get_lang('Session'),
  1647. [],
  1648. ICON_SIZE_SMALL
  1649. ).' '.$session_name.($date_session ? ' ('.$date_session.')' : '');
  1650. }
  1651. // Courses
  1652. echo '<table class="data_table">';
  1653. echo '<h3>'.$title.'</h3>';
  1654. echo '<tr>
  1655. <th>'.get_lang('Course').'</th>
  1656. <th>'.get_lang('Time').'</th>
  1657. <th>'.get_lang('Score').'</th>
  1658. <th>'.get_lang('FirstConnexion').'</th>
  1659. <th>'.get_lang('Progress').'</th>
  1660. <th>'.get_lang('fin_mod_prevue').'</th>
  1661. <th>'.get_lang('Details').'</th>
  1662. </tr>';
  1663. if (!empty($courses)) {
  1664. foreach ($courses as $course_code) {
  1665. if (CourseManager:: is_user_subscribed_in_course($studentId, $course_code, true)) {
  1666. $course_info = CourseManager:: get_course_information($course_code);
  1667. $time_spent_on_course = api_time_to_hms(
  1668. Tracking:: get_time_spent_on_the_course($user_info['user_id'], $course_code, $session_id)
  1669. );
  1670. //on sort le c_id avec le code du cours
  1671. $sql8 = "SELECT *
  1672. FROM course
  1673. WHERE code = ' $course_code'
  1674. ";
  1675. $result8 = Database::query($sql8);
  1676. $course_code_id = Database::fetch_array($result8);
  1677. $c_id = $course_code_id['id'];
  1678. // firts connection date
  1679. $sql2 = 'SELECT STR_TO_DATE(access_date,"%Y-%m-%d")
  1680. FROM '.$tbl_stats_access.'
  1681. WHERE access_user_id = '.$studentId.'
  1682. AND c_id = '.$c_id.'
  1683. ORDER BY access_id ASC LIMIT 0,1
  1684. ';
  1685. $rs2 = Database::query($sql2);
  1686. $first_connection_date_to_module = Database::result($rs2, 0, 0);
  1687. //pour trouver la date de fin prévue du module
  1688. $end_date_module = get_lang('hors_cal');
  1689. //avec le nom d'horaire= official code, on trouve la date de
  1690. // début de chaque module nombre de jour a faire
  1691. $sql = "SELECT * FROM c_cal_dates
  1692. where horaire_name = '$nom_hor'
  1693. and c_id = '$c_id'
  1694. AND date = date_format('$first_connection_date_to_module','%Y-%m-%d')
  1695. ";
  1696. $res = Database::query($sql);
  1697. $resulta = Database::fetch_array($res);
  1698. $date_debut = $resulta['date'];
  1699. //on trouve le nombre de jour pour ce module
  1700. $sql = "SELECT * FROM c_cal_set_module where c_id = '$c_id'";
  1701. $res = Database::query($sql);
  1702. $resulta = Database::fetch_array($res);
  1703. $nombre_heure = $resulta['minutes'];
  1704. // on trouve le nombre de minute par jour
  1705. // Julio
  1706. /*$sql = "SELECT * FROM c_cal_horaire where c_id = '$course_code_real'";
  1707. $res = Database::query($sql);
  1708. $resulta = Database::fetch_array($res);
  1709. $nombre_minutes = $resulta['num_minute'];*/
  1710. $nombre_minutes = 0;
  1711. //on calcule le nombre de jour par module
  1712. $nombre_jours_module = $nombre_heure * '60' / $nombre_minutes;
  1713. //on arrondi
  1714. $nombre_jours_module = number_format($nombre_jours_module, 0);
  1715. //on trouve la date de fin de chaque module AND date = date_format('$first_connection_date_to_module','%Y-%m-%d')
  1716. $sql = "SELECT * FROM `c_cal_dates`
  1717. WHERE
  1718. horaire_name = '$nom_hor' AND
  1719. c_id = '$course_code_real' AND
  1720. STR_TO_DATE(date,'%Y-%m-%d') >= STR_TO_DATE('$first_connection_date_to_module','%Y-%m-%d')
  1721. ORDER BY STR_TO_DATE(date, '%Y-%m-%d') ASC ";
  1722. $res = Database::query($sql);
  1723. mysql_data_seek($res, $nombre_jours_module);
  1724. $row = mysql_fetch_row($res);
  1725. $end_date_module = $row[1];
  1726. //fin de trouver la date de fin prévue du module
  1727. // get average of faults in attendances by student
  1728. $results_faults_avg = $attendance->get_faults_average_by_course(
  1729. $studentId,
  1730. $course_code,
  1731. $session_id
  1732. );
  1733. if (!empty($results_faults_avg['total'])) {
  1734. if (api_is_drh()) {
  1735. $attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(
  1736. WEB_CODE_PATH
  1737. ).'attendance/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$studentId.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
  1738. } else {
  1739. $attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)';
  1740. }
  1741. } else {
  1742. $attendances_faults_avg = '0/0 (0%)';
  1743. }
  1744. // Get evaluations by student
  1745. $cats = Category::load(null, null, $course_code, null, null, $session_id);
  1746. $scoretotal = [];
  1747. if (isset($cats) && isset($cats[0])) {
  1748. if (!empty($session_id)) {
  1749. $scoretotal = $cats[0]->calc_score($studentId, $course_code, $session_id);
  1750. } else {
  1751. $scoretotal = $cats[0]->calc_score($studentId, $course_code);
  1752. }
  1753. }
  1754. $scoretotal_display = '0/0 (0%)';
  1755. if (!empty($scoretotal)) {
  1756. $scoretotal_display = round($scoretotal[0], 1).'/'.round($scoretotal[1], 1).' ('.round(
  1757. ($scoretotal[0] / $scoretotal[1]) * 100,
  1758. 2
  1759. ).' %)';
  1760. }
  1761. $progress = Tracking::get_avg_student_progress(
  1762. $user_info['user_id'],
  1763. $course_code,
  1764. null,
  1765. $session_id
  1766. );
  1767. $score = Tracking:: get_avg_student_score($user_info['user_id'], $course_code, null, $session_id);
  1768. $progress = empty($progress) ? '0%' : $progress.'%';
  1769. $score = empty($score) ? '0%' : $score.'%';
  1770. $csv_content[] = [
  1771. $session_name,
  1772. $course_info['title'],
  1773. $time_spent_on_course,
  1774. $progress,
  1775. $score,
  1776. $attendances_faults_avg,
  1777. $scoretotal_display,
  1778. ];
  1779. $warming = '';
  1780. $today = date('Y-m-d');
  1781. if ($end_date_module <= $today and $progress != '100%') {
  1782. $warming = '<b><font color=#CC0000> '.get_lang('limite_atteinte').'</font></b>';
  1783. }
  1784. $end_date_module = $end_date_module.$warming;
  1785. echo '<tr>
  1786. <td >'.$course_info['title'].'</td>
  1787. <td >'.$time_spent_on_course.'</td>
  1788. <td >'.$score.'</td>
  1789. <td >'.$first_connection_date_to_module.'</td>
  1790. <td >'.$progress.'</td>
  1791. <td >'.$end_date_module.'</td>';
  1792. if (!empty($coachId)) {
  1793. echo '<td width="10">
  1794. <a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$course_info['code'].'&id_coach='.$coachId.
  1795. '&origin='.Security::remove_XSS($_GET['origin']).'&id_session='.$session_id.'#infosStudent">'.
  1796. Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
  1797. } else {
  1798. echo '<td width="10"><a href="'.api_get_self(
  1799. ).'?student='.$user_info['user_id'].'&details=true&course='.$course_info['code'].'&origin='.Security::remove_XSS(
  1800. $_GET['origin']
  1801. ).'&id_session='.$session_id.'#infosStudent">'.
  1802. Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
  1803. }
  1804. echo '</tr>';
  1805. }
  1806. }
  1807. } else {
  1808. echo "<tr><td colspan='5'>".get_lang('NoCourse')."</td></tr>";
  1809. }
  1810. echo '</table>';
  1811. }
  1812. } else {
  1813. $csv_content[] = [];
  1814. $csv_content[] = [str_replace('&nbsp;', '', $table_title)];
  1815. $t_lp = Database:: get_course_table(TABLE_LP_MAIN);
  1816. // csv export headers
  1817. $csv_content[] = [];
  1818. $csv_content[] = [
  1819. get_lang('Learnpath'),
  1820. get_lang('Time'),
  1821. get_lang('AverageScore'),
  1822. get_lang('LatestAttemptAverageScore'),
  1823. get_lang('Progress'),
  1824. get_lang('LastConnexion'),
  1825. ];
  1826. $sql8 = "SELECT * FROM course WHERE code = '$course_code'";
  1827. $result8 = Database::query($sql8);
  1828. $course_code_id = Database::fetch_array($result8);
  1829. $c_id = $course_code_id['id'];
  1830. if (empty($session_id)) {
  1831. $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp
  1832. WHERE session_id = 0 AND c_id = $c_id
  1833. ORDER BY lp.display_order";
  1834. } else {
  1835. $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp
  1836. WHERE c_id = $c_id
  1837. ORDER BY lp.display_order";
  1838. }
  1839. $rs_lp = Database::query($sql_lp);
  1840. if (Database:: num_rows($rs_lp) > 0) {
  1841. ?>
  1842. <!-- LPs-->
  1843. <table class="data_table">
  1844. <tr>
  1845. <th><?php echo get_lang('Learnpaths'); ?></th>
  1846. <th><?php echo get_lang('FirstConnexion'); ?></th>
  1847. <th><?php echo get_lang('Time').' ';
  1848. Display:: display_icon(
  1849. 'info3.gif',
  1850. get_lang('TotalTimeByCourse'),
  1851. ['align' => 'absmiddle', 'hspace' => '3px']
  1852. ); ?></th>
  1853. <th><?php echo get_lang('AverageScore').' ';
  1854. Display:: display_icon(
  1855. 'info3.gif',
  1856. get_lang('AverageIsCalculatedBasedInAllAttempts'),
  1857. ['align' => 'absmiddle', 'hspace' => '3px']
  1858. ); ?></th>
  1859. <th><?php echo get_lang('LatestAttemptAverageScore').' ';
  1860. Display:: display_icon(
  1861. 'info3.gif',
  1862. get_lang('AverageIsCalculatedBasedInTheLatestAttempts'),
  1863. ['align' => 'absmiddle', 'hspace' => '3px']
  1864. ); ?></th>
  1865. <th><?php echo get_lang('Progress').' ';
  1866. Display:: display_icon(
  1867. 'info3.gif',
  1868. get_lang('LPProgressScore'),
  1869. ['align' => 'absmiddle', 'hspace' => '3px']
  1870. ); ?></th>
  1871. <th><?php echo get_lang('LastConnexion').' ';
  1872. Display:: display_icon(
  1873. 'info3.gif',
  1874. get_lang('LastTimeTheCourseWasUsed'),
  1875. ['align' => 'absmiddle', 'hspace' => '3px']
  1876. ); ?></th>
  1877. <?php
  1878. echo '<th>'.get_lang('Details').'</th>';
  1879. if (api_is_allowed_to_edit()) {
  1880. echo '<th>'.get_lang('ResetLP').'</th>';
  1881. } ?>
  1882. </tr>
  1883. <?php
  1884. // firts connection date
  1885. $sql2 = 'SELECT access_date
  1886. FROM '.$tbl_stats_access.'
  1887. WHERE access_user_id = '.$studentId.'
  1888. AND c_id = '.$c_id.'
  1889. ORDER BY access_id ASC LIMIT 0,1
  1890. ';
  1891. $rs2 = Database::query($sql2);
  1892. $first_connection_date_to_module = Database::result($rs2, 0, 0);
  1893. $i = 0;
  1894. while ($learnpath = Database:: fetch_array($rs_lp)) {
  1895. $lp_id = intval($learnpath['id']);
  1896. $lp_name = $learnpath['name'];
  1897. $any_result = false;
  1898. // Get progress in lp
  1899. $progress = Tracking::get_avg_student_progress(
  1900. $studentId,
  1901. $course_code,
  1902. [$lp_id],
  1903. $session_id
  1904. );
  1905. if ($progress === null) {
  1906. $progress = '0%';
  1907. } else {
  1908. $any_result = true;
  1909. }
  1910. // Get time in lp
  1911. $total_time = Tracking::get_time_spent_in_lp(
  1912. $studentId,
  1913. $course_code,
  1914. [$lp_id],
  1915. $session_id
  1916. );
  1917. if (!empty($total_time)) {
  1918. $any_result = true;
  1919. }
  1920. // Get last connection time in lp
  1921. $start_time = Tracking::get_last_connection_time_in_lp(
  1922. $studentId,
  1923. $course_code,
  1924. $lp_id,
  1925. $session_id
  1926. );
  1927. if (!empty($start_time)) {
  1928. $start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
  1929. } else {
  1930. $start_time = '-';
  1931. }
  1932. if (!empty($total_time)) {
  1933. $any_result = true;
  1934. }
  1935. // Quiz in lp
  1936. $score = Tracking::get_avg_student_score(
  1937. $studentId,
  1938. $course_code,
  1939. [$lp_id],
  1940. $session_id
  1941. );
  1942. // Latest exercise results in a LP
  1943. $score_latest = Tracking:: get_avg_student_score(
  1944. $studentId,
  1945. $course_code,
  1946. [$lp_id],
  1947. $session_id,
  1948. false,
  1949. true
  1950. );
  1951. if ($i % 2 == 0) {
  1952. $css_class = "row_even";
  1953. } else {
  1954. $css_class = "row_odd";
  1955. }
  1956. $i++;
  1957. // csv export content
  1958. $csv_content[] = [
  1959. api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
  1960. api_time_to_hms($total_time),
  1961. $score.'%',
  1962. $score_latest.'%',
  1963. $progress.'%',
  1964. $start_time,
  1965. ];
  1966. echo '<tr class="'.$css_class.'">';
  1967. echo Display::tag('td', stripslashes($lp_name));
  1968. echo Display::tag('td', stripslashes($first_connection_date_to_module));
  1969. echo Display::tag('td', api_time_to_hms($total_time));
  1970. if (!is_null($score)) {
  1971. if (is_numeric($score)) {
  1972. $score = $score.'%';
  1973. }
  1974. }
  1975. echo Display::tag('td', $score);
  1976. if (!is_null($score_latest)) {
  1977. if (is_numeric($score_latest)) {
  1978. $score_latest = $score_latest.'%';
  1979. }
  1980. }
  1981. echo Display::tag('td', $score_latest);
  1982. if (is_numeric($progress)) {
  1983. $progress = $progress.'%';
  1984. } else {
  1985. $progress = '-';
  1986. }
  1987. echo Display::tag('td', $progress);
  1988. //Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
  1989. //which implies several other changes not a priority right now
  1990. echo Display::tag('td', $start_time);
  1991. if ($any_result === true) {
  1992. $from = '';
  1993. if ($from_myspace) {
  1994. $from = '&from=myspace';
  1995. }
  1996. $link = Display::url(
  1997. Display::return_icon('2rightarrow.png', get_lang('Details')),
  1998. 'lp_tracking.php?cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS(
  1999. $_GET['course']
  2000. ).$from.'&origin='.Security::remove_XSS(
  2001. $_GET['origin']
  2002. ).'&lp_id='.$learnpath['id'].'&student_id='.$user_info['user_id'].'&id_session='.$session_id
  2003. );
  2004. echo Display::tag('td', $link);
  2005. }
  2006. if (api_is_allowed_to_edit()) {
  2007. echo '<td>';
  2008. if ($any_result === true) {
  2009. echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&cidReq='.Security::remove_XSS(
  2010. $_GET['course']
  2011. ).'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS(
  2012. $_GET['details']
  2013. ).'&origin='.Security::remove_XSS(
  2014. $_GET['origin']
  2015. ).'&lp_id='.$learnpath['id'].'&student='.$user_info['user_id'].'&details=true&id_session='.Security::remove_XSS(
  2016. $_GET['id_session']
  2017. ).'">';
  2018. echo Display::return_icon('clean.png', get_lang('Clean'), '', ICON_SIZE_SMALL).'</a>';
  2019. echo '</a>';
  2020. }
  2021. echo '</td>';
  2022. echo '</tr>';
  2023. }
  2024. $data_learnpath[$i][] = $lp_name;
  2025. $data_learnpath[$i][] = $progress.'%';
  2026. }
  2027. } else {
  2028. //echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
  2029. } ?>
  2030. </table>
  2031. <!-- line about exercises -->
  2032. <table class="data_table">
  2033. <tr>
  2034. <th><?php echo get_lang('Exercises'); ?></th>
  2035. <th><?php echo get_lang('LearningPath'); ?></th>
  2036. <th><?php echo get_lang('AvgCourseScore').' '.Display:: return_icon(
  2037. 'info3.gif',
  2038. get_lang('AverageScore'),
  2039. ['align' => 'absmiddle', 'hspace' => '3px']
  2040. ); ?></th>
  2041. <th><?php echo get_lang('Attempts'); ?></th>
  2042. <th><?php echo get_lang('LatestAttempt'); ?></th>
  2043. <th><?php echo get_lang('AllAttempts'); ?></th>
  2044. </tr>
  2045. <?php
  2046. $csv_content[] = [];
  2047. $csv_content[] = [
  2048. get_lang('Exercises'),
  2049. get_lang('LearningPath'),
  2050. get_lang('AvgCourseScore'),
  2051. get_lang('Attempts'),
  2052. ];
  2053. $t_quiz = Database:: get_course_table(TABLE_QUIZ_TEST);
  2054. $sql = "SELECT quiz.title, id FROM ".$t_quiz." AS quiz
  2055. WHERE
  2056. quiz.c_id = $c_id AND
  2057. (quiz.session_id = $session_id OR quiz.session_id = 0) AND
  2058. active IN (0, 1)
  2059. ORDER BY quiz.title ASC ";
  2060. $result_exercices = Database::query($sql);
  2061. $i = 0;
  2062. if (Database:: num_rows($result_exercices) > 0) {
  2063. while ($exercices = Database:: fetch_array($result_exercices)) {
  2064. $exercise_id = intval($exercices['id']);
  2065. $count_attempts = Tracking::count_student_exercise_attempts(
  2066. $studentId,
  2067. $course_code,
  2068. $exercise_id,
  2069. 0,
  2070. 0,
  2071. $session_id,
  2072. 2
  2073. );
  2074. $score_percentage = Tracking::get_avg_student_exercise_score(
  2075. $studentId,
  2076. $course_code,
  2077. $exercise_id,
  2078. $session_id,
  2079. 1,
  2080. 0
  2081. );
  2082. if (!isset($score_percentage) && $count_attempts > 0) {
  2083. $scores_lp = Tracking::get_avg_student_exercise_score(
  2084. $studentId,
  2085. $course_code,
  2086. $exercise_id,
  2087. $session_id,
  2088. 2,
  2089. 1
  2090. );
  2091. $score_percentage = $scores_lp[0];
  2092. $lp_name = $scores_lp[1];
  2093. } else {
  2094. $lp_name = '-';
  2095. }
  2096. $lp_name = !empty($lp_name) ? $lp_name : get_lang('NoLearnpath');
  2097. if ($i % 2) {
  2098. $css_class = 'row_odd';
  2099. } else {
  2100. $css_class = 'row_even';
  2101. }
  2102. echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
  2103. echo '<td>';
  2104. if (!empty($lp_name)) {
  2105. echo $lp_name;
  2106. } else {
  2107. echo '-';
  2108. }
  2109. echo '</td>';
  2110. echo '<td>';
  2111. if ($count_attempts > 0) {
  2112. echo $score_percentage.'%';
  2113. } else {
  2114. echo '-';
  2115. $score_percentage = 0;
  2116. }
  2117. echo '</td>';
  2118. echo '<td>'.$count_attempts.'</td>';
  2119. echo '<td>';
  2120. $sql_last_attempt = 'SELECT exe_id FROM '.$tbl_stats_exercices.'
  2121. WHERE exe_exo_id ="'.$exercise_id.'" AND
  2122. exe_user_id ="'.$studentId.'" AND
  2123. c_id ="'.$course_code.'" AND
  2124. session_id ="'.$session_id.'" AND
  2125. status = ""
  2126. ORDER BY exe_date DESC LIMIT 1';
  2127. $result_last_attempt = Database::query($sql_last_attempt);
  2128. if (Database:: num_rows($result_last_attempt) > 0) {
  2129. $id_last_attempt = Database:: result($result_last_attempt, 0, 0);
  2130. if ($count_attempts > 0) {
  2131. echo '<a href="../exercice/exercise_show.php?id='.$id_last_attempt.'&cidReq='.$course_code.'&session_id='.$session_id.'&student='.$studentId.'&origin='.(empty($_GET['origin']) ? 'tracking' : Security::remove_XSS(
  2132. $_GET['origin']
  2133. )).'"> <img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif" border="0" /> </a>';
  2134. }
  2135. }
  2136. echo '</td>';
  2137. echo '<td>';
  2138. $all_attempt_url = "../exercice/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$studentId&id_session=$session_id";
  2139. echo Display::url(
  2140. Display::return_icon('test_results.png', get_lang('AllAttempts'), [], ICON_SIZE_SMALL),
  2141. $all_attempt_url
  2142. );
  2143. echo '</td></tr>';
  2144. $data_exercices[$i][] = $exercices['title'];
  2145. $data_exercices[$i][] = $score_percentage.'%';
  2146. $data_exercices[$i][] = $count_attempts;
  2147. $csv_content[] = [
  2148. $exercices['title'],
  2149. $lp_name,
  2150. $score_percentage,
  2151. $count_attempts,
  2152. ];
  2153. $i++;
  2154. }
  2155. } else {
  2156. echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
  2157. }
  2158. echo '</table>';
  2159. //@when using sessions we do not show the survey list
  2160. if (empty($session_id)) {
  2161. $survey_list = SurveyManager::get_surveys($course_code, $session_id);
  2162. $survey_data = [];
  2163. foreach ($survey_list as $survey) {
  2164. $user_list = SurveyManager::get_people_who_filled_survey(
  2165. $survey['survey_id'],
  2166. false,
  2167. $info_course['real_id']
  2168. );
  2169. $survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), [], ICON_SIZE_SMALL);
  2170. if (in_array($studentId, $user_list)) {
  2171. $survey_done = Display::return_icon("accept.png", get_lang('Answered'), [], ICON_SIZE_SMALL);
  2172. }
  2173. $data = ['title' => $survey['title'], 'done' => $survey_done];
  2174. $survey_data[] = $data;
  2175. }
  2176. if (!empty($survey_list)) {
  2177. $table = new HTML_Table(['class' => 'data_table']);
  2178. $header_names = [get_lang('Survey'), get_lang('Answered')];
  2179. $row = 0;
  2180. $column = 0;
  2181. foreach ($header_names as $item) {
  2182. $table->setHeaderContents($row, $column, $item);
  2183. $column++;
  2184. }
  2185. $row = 1;
  2186. if (!empty($survey_data)) {
  2187. foreach ($survey_data as $data) {
  2188. $column = 0;
  2189. $table->setCellContents($row, $column, $data);
  2190. $class = 'class="row_odd"';
  2191. if ($row % 2) {
  2192. $class = 'class="row_even"';
  2193. }
  2194. $table->setRowAttributes($row, $class, true);
  2195. $column++;
  2196. $row++;
  2197. }
  2198. }
  2199. echo $table->toHtml();
  2200. }
  2201. }
  2202. // line about other tools
  2203. echo '<table class="data_table">';
  2204. $csv_content[] = [];
  2205. $nb_assignments = Tracking::count_student_assignments($studentId, $course_code, $session_id);
  2206. $messages = Tracking::count_student_messages($studentId, $course_code, $session_id);
  2207. $links = Tracking::count_student_visited_links($studentId, $course_code, $session_id);
  2208. $chat_last_connection = Tracking::chat_last_connection($studentId, $course_code, $session_id);
  2209. $documents = Tracking::count_student_downloaded_documents($studentId, $course_code, $session_id);
  2210. $uploaded_documents = Tracking::count_student_uploaded_documents($studentId, $course_code, $session_id);
  2211. $csv_content[] = [
  2212. get_lang('OtherTools'),
  2213. ];
  2214. $csv_content[] = [
  2215. get_lang('StudentPublications'),
  2216. $nb_assignments,
  2217. ];
  2218. $csv_content[] = [
  2219. get_lang('Messages'),
  2220. $messages,
  2221. ];
  2222. $csv_content[] = [
  2223. get_lang('LinksDetails'),
  2224. $links,
  2225. ];
  2226. $csv_content[] = [
  2227. get_lang('DocumentsDetails'),
  2228. $documents,
  2229. ];
  2230. $csv_content[] = [
  2231. get_lang('UploadedDocuments'),
  2232. $uploaded_documents,
  2233. ];
  2234. $csv_content[] = [
  2235. get_lang('ChatLastConnection'),
  2236. $chat_last_connection,
  2237. ]; ?>
  2238. <tr>
  2239. <th colspan="2"><?php echo get_lang('OtherTools'); ?></th>
  2240. </tr>
  2241. <tr><!-- assignments -->
  2242. <td width="40%"><?php echo get_lang('StudentPublications'); ?></td>
  2243. <td><?php echo $nb_assignments; ?></td>
  2244. </tr>
  2245. <tr><!-- messages -->
  2246. <td><?php echo get_lang('Forum').' - '.get_lang('NumberOfPostsForThisUser'); ?></td>
  2247. <td><?php echo $messages; ?></td>
  2248. </tr>
  2249. <tr><!-- links -->
  2250. <td><?php echo get_lang('LinksDetails'); ?></td>
  2251. <td><?php echo $links; ?></td>
  2252. </tr>
  2253. <tr><!-- downloaded documents -->
  2254. <td><?php echo get_lang('DocumentsDetails'); ?></td>
  2255. <td><?php echo $documents; ?></td>
  2256. </tr>
  2257. <tr><!-- uploaded documents -->
  2258. <td><?php echo get_lang('UploadedDocuments'); ?></td>
  2259. <td><?php echo $uploaded_documents; ?></td>
  2260. </tr>
  2261. <tr><!-- Chats -->
  2262. <td><?php echo get_lang('ChatLastConnection'); ?></td>
  2263. <td><?php echo $chat_last_connection; ?></td>
  2264. </tr>
  2265. </table>
  2266. </td>
  2267. </tr>
  2268. </table>
  2269. <?php
  2270. } //end details
  2271. if ($export_csv) {
  2272. ob_end_clean();
  2273. Export:: export_table_csv($csv_content, 'reporting_student');
  2274. exit;
  2275. }
  2276. ?>
  2277. <br>
  2278. <form action="create_exam.php" method="post" name="create_exam">
  2279. <table class='data_table'>
  2280. <tr>
  2281. <th colspan="6">
  2282. <?php echo get_lang('Title');
  2283. echo $user_info['complete_name']; ?>
  2284. </th>
  2285. <tr>
  2286. <th style="width: 60px">
  2287. <?php echo get_lang('Module'); ?>
  2288. </th>
  2289. <th style="width: 120px">
  2290. <?php echo get_lang('Results'); ?>
  2291. </th>
  2292. <th style="width: 100px">
  2293. <?php echo get_lang('result_rep_1'); ?>
  2294. </th>
  2295. <th style="width: 100px">
  2296. <?php echo get_lang('result_rep_2'); ?>
  2297. </th>
  2298. <th style="width: 720px">
  2299. <?php echo get_lang('Comment'); ?>
  2300. </th>
  2301. <th style="width: 60px">
  2302. <?php echo get_lang('Actions'); ?>
  2303. </th>
  2304. </tr>
  2305. <tr>
  2306. <td><input type="text" style="width:90%;" NAME="mod_no" size="1" <?php echo "$mod_no "; ?></textarea></td>
  2307. <td>
  2308. <select name="score_ex">
  2309. <option value="-">-</option>
  2310. <option value="SU">SU</option>
  2311. <option value="EC">EC</option>
  2312. </select>
  2313. </td>
  2314. <td>
  2315. <select name="score_rep1">
  2316. <option value="-">-</option>
  2317. <option value="SU">SU</option>
  2318. <option value="EC">EC</option>
  2319. </select>
  2320. </td>
  2321. <td>
  2322. <select name="score_rep2">
  2323. <option value="-">-</option>
  2324. <option value="SU">SU</option>
  2325. <option value="EC">EC</option>
  2326. </select>
  2327. </td>
  2328. <td><textarea name="coment" style="width:70%; rows=" 2"><?php echo "$coment"; ?></textarea></td>
  2329. <INPUT type=hidden name=ex_user_id value= <?php echo $studentId; ?>>
  2330. <td><input type="SUBMIT" value="<?php echo get_lang('Save'); ?>" name="create_exam"></td>
  2331. </tr>
  2332. </table>
  2333. </form>
  2334. <form name="save_exam">
  2335. <table class='data_table'>
  2336. <tr>
  2337. <th colspan="6">
  2338. <?php echo get_lang('result_exam_title');
  2339. echo $user_info['complete_name']; ?>
  2340. </th>
  2341. <tr>
  2342. <th><?php echo get_lang('Module'); ?> </th>
  2343. <th>
  2344. <?php echo get_lang('Results'); ?>
  2345. </th>
  2346. <th>
  2347. <?php echo get_lang('result_rep_1'); ?>
  2348. </th>
  2349. <th>
  2350. <?php echo get_lang('result_rep_2'); ?>
  2351. </th>
  2352. <th>
  2353. <?php echo get_lang('Comment'); ?>
  2354. </th>
  2355. <th>
  2356. <?php echo get_lang('Actions'); ?>
  2357. </th>
  2358. </tr>
  2359. <?php
  2360. $sqlexam = "SELECT *
  2361. FROM $tbl_stats_exercices
  2362. WHERE exe_user_id = $studentId
  2363. AND c_id = 0 AND mod_no != '0'
  2364. ORDER BY mod_no ASC";
  2365. $resultexam = Database::query($sqlexam);
  2366. $coment = '';
  2367. while ($a_exam = Database::fetch_array($resultexam)) {
  2368. //$ex_id = $a_exam['ex_id'];
  2369. $mod_no = $a_exam['mod_no'];
  2370. $score_ex = $a_exam['score_ex'];
  2371. $score_rep1 = $a_exam['score_rep1'];
  2372. $score_rep2 = $a_exam['score_rep2'];
  2373. $coment = stripslashes($a_exam['coment']);
  2374. echo "
  2375. <tr><center>
  2376. <td> ".$a_exam['mod_no']."
  2377. </td>
  2378. <td><center>
  2379. ".$a_exam['score_ex']."
  2380. </td>
  2381. <td><center>
  2382. ".$a_exam['score_rep1']."
  2383. </td>
  2384. <td><center>
  2385. ".$a_exam['score_rep2']."
  2386. </td>
  2387. <td>$coment
  2388. ";
  2389. $exe_idd = $a_exam['exe_id']; ?>
  2390. <INPUT type=hidden name=ex_idd value= <?php echo "$exe_idd"; ?>>
  2391. <td class="highlight">&nbsp;
  2392. <a href="edit_exam.php?num=<?php echo $exe_idd; ?>&student_id=<?php echo $studentId; ?>">
  2393. <?php echo Display::return_icon('edit.png', get_lang('Edit')); ?>
  2394. </a>
  2395. &nbsp;&nbsp;<a href="delete_exam.php?num=<?php echo $exe_idd; ?>&student_id=<?php echo $studentId; ?>">
  2396. <img
  2397. src="../img/delete.gif" border="0"
  2398. onClick='return confirmDelete2()'></a>
  2399. </td>
  2400. </tr>
  2401. <?php
  2402. }
  2403. ?>
  2404. </table>
  2405. </form>
  2406. <strong><?php echo get_lang('imprime_sommaire'); ?> </strong>
  2407. <?php
  2408. echo '<a target="_blank"
  2409. href="print_myStudents.php?student='.$studentId.'&details=true&course='.$course_code.'&origin=tracking_course">
  2410. <img src="'.api_get_path(WEB_IMG_PATH).'printmgr.gif" border="0" /></a>';
  2411. // tableau pour date de fin prévue pour chaque module
  2412. ?>
  2413. <table class='data_table'>
  2414. <tr>
  2415. <th colspan="6">
  2416. <?php echo get_lang('fin_mod_prevue');
  2417. echo $user_info['complete_name']; ?>
  2418. </th>
  2419. <tr>
  2420. <th style="width: 17%">
  2421. <?php echo get_lang('Module'); ?>
  2422. </th>
  2423. <th style="width: 17%">
  2424. <?php echo get_lang('FirstLogin'); ?>
  2425. </th>
  2426. <th style="width: 16%">
  2427. <?php echo get_lang('ToDo'); ?>
  2428. </th>
  2429. <th style="width: 16%">
  2430. <?php echo get_lang('realise'); ?>
  2431. </th>
  2432. <th style="width: 16%">
  2433. <?php echo get_lang('pour_realise'); ?>
  2434. </th>
  2435. <th style="width: 16%">
  2436. <?php echo get_lang('fin_mod_prevue'); ?>
  2437. </th>
  2438. </tr>
  2439. </table>
  2440. <?php Display:: display_footer();