function load_courses() { document.search_simple.submit(); } '; $session_id = intval($_REQUEST['session_id']); if (empty($session_id)) { $temp_course_list = CourseManager :: get_courses_list(); } else { $temp_course_list = SessionManager::get_course_list_by_session_id($session_id); } foreach($temp_course_list as $temp_course_item) { $course_item = CourseManager ::get_course_information($temp_course_item['code']); $course_list[]= array('db_name' =>$course_item['db_name'],'code'=>$course_item['code'], 'title'=>$course_item['title'], 'visual_code'=>$course_item['visual_code']); $course_select_list[$temp_course_item['code']] = $course_item['title']; } //Get session list $session_list = SessionManager::get_sessions_list(array(), array('name')); $my_session_list = array(); $my_session_list[0] = get_lang('None'); foreach($session_list as $sesion_item) { $my_session_list[$sesion_item['id']] = $sesion_item['name']; } $form = new FormValidator('search_simple','POST','','',null,false); $form->addElement('select', 'session_id', get_lang('Sessions'), $my_session_list, array('id'=>'session_id', 'onchange'=>'load_courses();')); $form->addElement('select', 'course_code',get_lang('Courses'), $course_select_list); $form->addElement('style_submit_button','submit_form', get_lang('Filter')); if (!empty($_REQUEST['course_code'])) $course_code = $_REQUEST['course_code']; else $course_code = ''; if (empty($course_code)) { $course_code = 0; } $form->setDefaults(array('course_code'=>(string)$course_code)); $course_info = api_get_course_info($course_code); if (!empty($course_info)) { $list = new LearnpathList('', $course_code); $lp_list = $list->get_flat_list(); $_course = $course_info; $main_question_list = array(); foreach ($lp_list as $lp_id =>$lp) { $exercise_list = ExerciseLib::get_all_exercises_from_lp($lp_id, $course_info['real_id']); foreach ($exercise_list as $exercise) { $my_exercise = new Exercise(); $my_exercise->read($exercise['path']); $question_list = $my_exercise->selectQuestionList(); $exercise_stats = get_all_exercise_event_from_lp($exercise['path'],$course_info['real_id'], $session_id); foreach ($question_list as $question_id) { $question_data = Question::read($question_id); $main_question_list[$question_id] = $question_data; $quantity_exercises = 0; $question_result = 0; foreach($exercise_stats as $stats) { if (!empty($stats['question_list'])) { foreach($stats['question_list'] as $my_question_stat) { if ($question_id == $my_question_stat['question_id']) { $question_result = $question_result + $my_question_stat['marks']; $quantity_exercises++; } } } } if(!empty($quantity_exercises)) { $main_question_list[$question_id]->results =(($question_result / ($quantity_exercises)) ) ; // Score % average } else { $main_question_list[$question_id]->results = 0; } $main_question_list[$question_id]->quantity = $quantity_exercises; } } } } if (!$export_to_xls) { Display :: display_header(get_lang("MySpace")); echo '
'; if ($global) { $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ); $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher'); $menu_items[] = Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32); $menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php'); $nb_menu_items = count($menu_items); if($nb_menu_items>1) { foreach($menu_items as $key=> $item) { echo $item; } } } else { echo '
'.get_lang('StudentsTracking').' | '.get_lang('CourseTracking').' '; echo '
'; } echo '
'; if (api_is_platform_admin()) { echo ''.get_lang('DisplayCoaches').' | '; echo ''.get_lang('DisplayUserOverview').''; echo ' | '.get_lang('DisplaySessionOverview').''; echo ' | '.get_lang('DisplayCourseOverview').''; echo ' | '.get_lang('LPQuestionListResults'); echo ' | '.get_lang('LPExerciseResultsBySession').''; } echo '
'; echo '

'.get_lang('LPQuestionListResults').'

'; $form->display(); //Display::display_normal_message(get_lang('QuestionsAreTakenFromLPExercises')); if (empty($course_code)) { Display::display_warning_message(get_lang('PleaseSelectACourse')); } } $course_average = array(); $counter = 0; if (!empty($main_question_list) && is_array($main_question_list)) { $html_result .= ''; $html_result .= ''; $html_result .= ''; $html_result .= ''; foreach($main_question_list as $question) { $total_student = 0; $counter ++; $s_css_class = 'row_even'; if ($counter % 2 ==0 ) { $s_css_class = 'row_odd'; } $html_result .= ""; $html_result .= ""; $html_result .= ""; } $html_result .=""; $html_result .= '
'.get_lang('Question').Display :: return_icon('info3.gif', get_lang('QuestionsAreTakenFromLPExercises'), array('align' => 'absmiddle', 'hspace' => '3px')).''.$course_info['visual_code'].' '.get_lang('AverageScore').Display :: return_icon('info3.gif', get_lang('AllStudentsAttemptsAreConsidered'), array('align' => 'absmiddle', 'hspace' => '3px')).' '.get_lang('Quantity').'
"; $question_title = trim($question->question); if (empty($question_title)) { $html_result .= get_lang('Untitled').' '.get_lang('Question').' #'.$question->id; } else { $html_result .= $question->question; } $html_result .= ""; $html_result .= round($question->results, 2).' / '.$question->weighting; $html_result .= ""; $html_result .= $question->quantity; $html_result .= "
'; } else { if (!empty($course_code)) { Display::display_warning_message(get_lang('NoResults')); } } if (!$export_to_xls) { echo $html_result; } $filename = 'exam-reporting-'.date('Y-m-d-h:i:s').'.xls'; if ($export_to_xls) { echo $html_result; export_complete_report_xls($filename, $export_array); exit; } function sort_user($a, $b) { if (is_numeric($a['score']) && is_numeric($b['score'])) { echo $a['score'].' : '.$b['score']; echo '
'; if ($a['score'] < $b['score']) { return 1; } return 0; } return 1; } function export_complete_report_xls($filename, $array) { global $charset; $workbook = new Spreadsheet_Excel_Writer(); $workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH)); $workbook->send($filename); $workbook->setVersion(8); // BIFF8 $worksheet =& $workbook->addWorksheet('Report'); //$worksheet->setInputEncoding(api_get_system_encoding()); $worksheet->setInputEncoding($charset); /* $line = 0; $column = 1; // Skip the first column (row titles) foreach ($array as $elem) { $worksheet->write($line, $column, $elem); $column++; } $workbook->close();*/ exit; } Display :: display_footer();