From bc919eaabd29c00d5c9bdf4184aae20dd6fde281 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 23 Nov 2012 19:49:05 +0100 Subject: [PATCH] Minor - fixing warnings --- main/exercice/stats.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/main/exercice/stats.php b/main/exercice/stats.php index cb2966d4fe..2c094b0d2f 100644 --- a/main/exercice/stats.php +++ b/main/exercice/stats.php @@ -51,7 +51,10 @@ if (!empty($question_list)) { $data[$question_id]['name'] = cut($question_obj->question, 100); $data[$question_id]['type'] = $question_obj->get_question_type_name(); //$data[$question_id]['students_who_try_exercise'] = $exercise_stats['users']; - $percentange = $count_users/$count_students*100; + $percentange = 0; + if ($count_students) { + $percentange = $count_users/$count_students*100; + } $data[$question_id]['students_who_try_exercise'] = Display::bar_progress($percentange, false, $count_users .' / '.$count_students); @@ -133,7 +136,10 @@ if (!empty($question_list)) { $count = get_number_students_answer_count($real_answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id(), FILL_IN_BLANKS, $answer_info_db, $answer_item); - $percentange = $count/$count_students*100; + $percentange = 0; + if (!empty($count_students)) { + $percentange = $count/$count_students*100; + } $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students); $id++; @@ -160,8 +166,10 @@ if (!empty($question_list)) { $data[$id]['correct'] = $answer_info; $count = get_number_students_answer_count($answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id(), MATCHING); - - $percentange = $count/$count_students*100; + $percentange = 0; + if (!empty($count_students)) { + $percentange = $count/$count_students*100; + } $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students); } break; @@ -175,7 +183,10 @@ if (!empty($question_list)) { $data[$id]['correct'] = '-'; $count = get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id()); - $percentange = $count/$count_students*100; + $percentange = 0; + if (!empty($count_students)) { + $percentange = $count/$count_students*100; + } $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students); break; default: @@ -188,7 +199,10 @@ if (!empty($question_list)) { $data[$id]['correct'] = $correct_answer; $count = get_number_students_answer_count($real_answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id()); - $percentange = $count/$count_students*100; + $percentange = 0; + if (!empty($count_students)) { + $percentange = $count/$count_students*100; + } $data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students); } $id++;