Minor - format code

pull/2487/head
jmontoyaa 8 years ago
parent 2cbd401579
commit 4654570b23
  1. 12
      main/tracking/exams.php
  2. 5
      main/tracking/lp_results_by_user.php
  3. 224
      main/tracking/question_course_report.php

@ -246,11 +246,9 @@ if (!empty($courseList) && is_array($courseList)) {
if (Database::num_rows($resultExercises) > 0) { if (Database::num_rows($resultExercises) > 0) {
while ($exercise = Database::fetch_array($resultExercises, 'ASSOC')) { while ($exercise = Database::fetch_array($resultExercises, 'ASSOC')) {
$exerciseSessionId = $exercise['session_id']; $exerciseSessionId = $exercise['session_id'];
if (empty($exerciseSessionId)) { if (empty($exerciseSessionId)) {
if ($global) { if ($global) {
// If the exercise was created in the base course. // If the exercise was created in the base course.
// Load all sessions. // Load all sessions.
@ -280,7 +278,6 @@ if (!empty($courseList) && is_array($courseList)) {
$html .= $result['html']; $html .= $result['html'];
$export_array_global = array_merge($export_array_global, $result['export_array_global']); $export_array_global = array_merge($export_array_global, $result['export_array_global']);
} else { } else {
if (empty($sessionId)) { if (empty($sessionId)) {
// Load base course. // Load base course.
$result = processStudentList( $result = processStudentList(
@ -298,7 +295,6 @@ if (!empty($courseList) && is_array($courseList)) {
$result['export_array_global'] $result['export_array_global']
); );
} else { } else {
$result = processStudentList( $result = processStudentList(
$filter_score, $filter_score,
$global, $global,
@ -317,7 +313,6 @@ if (!empty($courseList) && is_array($courseList)) {
} }
} else { } else {
// If the exercise only exists in this session. // If the exercise only exists in this session.
$result = processStudentList( $result = processStudentList(
$filter_score, $filter_score,
$global, $global,
@ -370,7 +365,8 @@ if ($exportToXLS) {
* @param $b * @param $b
* @return int * @return int
*/ */
function sort_user($a, $b) { function sort_user($a, $b)
{
if (is_numeric($a['score']) && is_numeric($b['score'])) { if (is_numeric($a['score']) && is_numeric($b['score'])) {
if ($a['score'] < $b['score']) { if ($a['score'] < $b['score']) {
return 1; return 1;
@ -484,8 +480,7 @@ function export_complete_report_xls($filename, $array)
*/ */
function processStudentList($filter_score, $global, $exercise, $courseInfo, $sessionId, $newSessionList) function processStudentList($filter_score, $global, $exercise, $courseInfo, $sessionId, $newSessionList)
{ {
if ( if ((isset($exercise['id']) && empty($exercise['id'])) ||
(isset($exercise['id']) && empty($exercise['id'])) ||
!isset($exercise['id']) !isset($exercise['id'])
) { ) {
return array( return array(
@ -519,7 +514,6 @@ function processStudentList($filter_score, $global, $exercise, $courseInfo, $ses
} }
$html = null; $html = null;
$totalStudents = count($students); $totalStudents = count($students);
if (!$global) { if (!$global) {

@ -2,7 +2,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
*
* Exercise results from Learning paths * Exercise results from Learning paths
* *
* @todo implement pagination * @todo implement pagination
@ -34,7 +33,7 @@ if (api_is_platform_admin()) {
if ($global) { if ($global) {
$temp_course_list = CourseManager :: get_courses_list(); $temp_course_list = CourseManager :: get_courses_list();
foreach ($temp_course_list as $temp_course_item) { foreach ($temp_course_list as $temp_course_item) {
$course_item = api_get_course_info($temp_course_item['code']); $course_item = api_get_course_info($temp_course_item['code']);
$course_list[] = array( $course_list[] = array(
'code' => $course_item['code'], 'code' => $course_item['code'],
@ -254,6 +253,6 @@ function export_complete_report_csv($filename, $array)
Export :: arrayToCsv($array, $filename); Export :: arrayToCsv($array, $filename);
} }
exit; exit;
} }
Display :: display_footer(); Display :: display_footer();

@ -14,20 +14,20 @@ $this_section = "session_my_space";
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_session_general_coach || $is_sessionAdmin; $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_session_general_coach || $is_sessionAdmin;
if (!$is_allowedToTrack) { if (!$is_allowedToTrack) {
Display::display_header(null); Display::display_header(null);
api_not_allowed(); api_not_allowed();
Display::display_footer(); Display::display_footer();
} }
$export_to_xls = false; $export_to_xls = false;
if (isset($_GET['export'])) { if (isset($_GET['export'])) {
$export_to_xls = true; $export_to_xls = true;
} }
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
$global = true; $global = true;
} else { } else {
$global = false; $global = false;
} }
$global = true; $global = true;
@ -38,21 +38,21 @@ $course_select_list[0] = get_lang('None');
$htmlHeadXtra[] = ' $htmlHeadXtra[] = '
<script type="text/javascript"> <script type="text/javascript">
function load_courses() { function load_courses() {
document.search_simple.submit(); document.search_simple.submit();
} }
</script>'; </script>';
$session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : null; $session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : null;
if (empty($session_id)) { if (empty($session_id)) {
$temp_course_list = CourseManager::get_courses_list(); $temp_course_list = CourseManager::get_courses_list();
} else { } else {
$temp_course_list = SessionManager::get_course_list_by_session_id($session_id); $temp_course_list = SessionManager::get_course_list_by_session_id($session_id);
} }
foreach ($temp_course_list as $temp_course_item) { foreach ($temp_course_list as $temp_course_item) {
$course_item = api_get_course_info($temp_course_item['code']); $course_item = api_get_course_info($temp_course_item['code']);
$course_select_list[$temp_course_item['code']] = $course_item['title']; $course_select_list[$temp_course_item['code']] = $course_item['title'];
} }
//Get session list //Get session list
@ -95,132 +95,132 @@ $form->setDefaults(array('course_code'=>(string) $course_code));
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
if (!empty($course_info)) { if (!empty($course_info)) {
$list = new LearnpathList('', $course_code); $list = new LearnpathList('', $course_code);
$lp_list = $list->get_flat_list(); $lp_list = $list->get_flat_list();
$main_question_list = array(); $main_question_list = array();
foreach ($lp_list as $lp_id => $lp) { foreach ($lp_list as $lp_id => $lp) {
$exercise_list = Event::get_all_exercises_from_lp( $exercise_list = Event::get_all_exercises_from_lp(
$lp_id, $lp_id,
$course_info['real_id'] $course_info['real_id']
); );
foreach ($exercise_list as $exercise) { foreach ($exercise_list as $exercise) {
$my_exercise = new Exercise($course_info['real_id']); $my_exercise = new Exercise($course_info['real_id']);
$my_exercise->read($exercise['path']); $my_exercise->read($exercise['path']);
$question_list = $my_exercise->selectQuestionList(); $question_list = $my_exercise->selectQuestionList();
$exercise_stats = Event::get_all_exercise_event_from_lp( $exercise_stats = Event::get_all_exercise_event_from_lp(
$exercise['path'], $exercise['path'],
$course_info['real_id'], $course_info['real_id'],
$session_id $session_id
); );
foreach ($question_list as $question_id) { foreach ($question_list as $question_id) {
$question_data = Question::read($question_id); $question_data = Question::read($question_id);
$main_question_list[$question_id] = $question_data; $main_question_list[$question_id] = $question_data;
$quantity_exercises = 0; $quantity_exercises = 0;
$question_result = 0; $question_result = 0;
foreach ($exercise_stats as $stats) { foreach ($exercise_stats as $stats) {
if (!empty($stats['question_list'])) { if (!empty($stats['question_list'])) {
foreach ($stats['question_list'] as $my_question_stat) { foreach ($stats['question_list'] as $my_question_stat) {
if ($question_id == $my_question_stat['question_id']) { if ($question_id == $my_question_stat['question_id']) {
$question_result = $question_result + $my_question_stat['marks']; $question_result = $question_result + $my_question_stat['marks'];
$quantity_exercises++; $quantity_exercises++;
} }
} }
} }
} }
if (!empty($quantity_exercises)) { if (!empty($quantity_exercises)) {
// Score % average // Score % average
$main_question_list[$question_id]->results = ($question_result / ($quantity_exercises)); $main_question_list[$question_id]->results = ($question_result / ($quantity_exercises));
} else { } else {
$main_question_list[$question_id]->results = 0; $main_question_list[$question_id]->results = 0;
} }
$main_question_list[$question_id]->quantity = $quantity_exercises; $main_question_list[$question_id]->quantity = $quantity_exercises;
} }
} }
} }
} }
if (!$export_to_xls) { if (!$export_to_xls) {
Display::display_header(get_lang("MySpace")); Display::display_header(get_lang("MySpace"));
echo '<div class="actions">'; echo '<div class="actions">';
if ($global) { if ($global) {
echo MySpace::getTopMenu(); echo MySpace::getTopMenu();
} else { } else {
echo '<div style="float:left; clear:left"> echo '<div style="float:left; clear:left">
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'. <a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.
get_lang('StudentsTracking').'</a>&nbsp;| get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'. <a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.
get_lang('CourseTracking').'</a>&nbsp;'; get_lang('CourseTracking').'</a>&nbsp;';
echo '</div>'; echo '</div>';
} }
echo '</div>'; echo '</div>';
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
echo MySpace::getAdminActions(); echo MySpace::getAdminActions();
} }
echo '<br />'; echo '<br />';
echo '<h2>'.get_lang('LPQuestionListResults').'</h2>'; echo '<h2>'.get_lang('LPQuestionListResults').'</h2>';
$form->display(); $form->display();
if (empty($course_code)) { if (empty($course_code)) {
echo Display::return_message(get_lang('PleaseSelectACourse'), 'warning'); echo Display::return_message(get_lang('PleaseSelectACourse'), 'warning');
} }
} }
$course_average = array(); $course_average = array();
$counter = 0; $counter = 0;
if (!empty($main_question_list) && is_array($main_question_list)) { if (!empty($main_question_list) && is_array($main_question_list)) {
$html_result .= '<table class="data_table">'; $html_result .= '<table class="data_table">';
$html_result .= '<tr><th>'.get_lang('Question'). $html_result .= '<tr><th>'.get_lang('Question').
Display::return_icon('info3.gif', get_lang('QuestionsAreTakenFromLPExercises'), array('align' => 'absmiddle', 'hspace' => '3px')).'</th>'; Display::return_icon('info3.gif', get_lang('QuestionsAreTakenFromLPExercises'), array('align' => 'absmiddle', 'hspace' => '3px')).'</th>';
$html_result .= '<th>'.$course_info['visual_code'].' '.get_lang('AverageScore').Display::return_icon('info3.gif', get_lang('AllStudentsAttemptsAreConsidered'), array('align' => 'absmiddle', 'hspace' => '3px')).' </th>'; $html_result .= '<th>'.$course_info['visual_code'].' '.get_lang('AverageScore').Display::return_icon('info3.gif', get_lang('AllStudentsAttemptsAreConsidered'), array('align' => 'absmiddle', 'hspace' => '3px')).' </th>';
$html_result .= '<th>'.get_lang('Quantity').'</th>'; $html_result .= '<th>'.get_lang('Quantity').'</th>';
foreach ($main_question_list as $question) { foreach ($main_question_list as $question) {
$total_student = 0; $total_student = 0;
$counter++; $counter++;
$s_css_class = 'row_even'; $s_css_class = 'row_even';
if ($counter % 2 == 0) { if ($counter % 2 == 0) {
$s_css_class = 'row_odd'; $s_css_class = 'row_odd';
} }
$html_result .= "<tr class='$s_css_class'> $html_result .= "<tr class='$s_css_class'>
<td >"; <td >";
$question_title = trim($question->question); $question_title = trim($question->question);
if (empty($question_title)) { if (empty($question_title)) {
$html_result .= get_lang('Untitled').' '.get_lang('Question').' #'.$question->id; $html_result .= get_lang('Untitled').' '.get_lang('Question').' #'.$question->id;
} else { } else {
$html_result .= $question->question; $html_result .= $question->question;
} }
$html_result .= "</td>"; $html_result .= "</td>";
$html_result .= "<td>"; $html_result .= "<td>";
$html_result .= round($question->results, 2).' / '.$question->weighting; $html_result .= round($question->results, 2).' / '.$question->weighting;
$html_result .= "</td>"; $html_result .= "</td>";
$html_result .= "<td>"; $html_result .= "<td>";
$html_result .= $question->quantity; $html_result .= $question->quantity;
$html_result .= "</td>"; $html_result .= "</td>";
} }
$html_result .= "</tr>"; $html_result .= "</tr>";
$html_result .= '</table>'; $html_result .= '</table>';
} else { } else {
if (!empty($course_code)) { if (!empty($course_code)) {
echo Display::return_message(get_lang('NoResults'), 'warning'); echo Display::return_message(get_lang('NoResults'), 'warning');
} }
} }
if (!$export_to_xls) { if (!$export_to_xls) {
echo $html_result; echo $html_result;
} }
Display::display_footer(); Display::display_footer();

Loading…
Cancel
Save