Merge 1.9.x

1.10.x
Julio Montoya 10 years ago
commit 3da23bd745
  1. 4
      main/document/document.php
  2. 162
      main/exercice/exercise.lib.php
  3. 158
      main/exercice/stats.php

@ -1292,8 +1292,7 @@ if ($is_allowed_to_edit ||
/* VISIBILITY COMMANDS */
if ($is_allowed_to_edit) {
if ((isset($_GET['set_invisible']) && !empty($_GET['set_invisible'])) ||
(isset($_GET['set_visible']) && !empty($_GET['set_visible'])) &&
$_GET['set_visible'] != '*' && $_GET['set_invisible'] != '*'
(isset($_GET['set_visible']) && !empty($_GET['set_visible']))
) {
// Make visible or invisible?
if (isset($_GET['set_visible'])) {
@ -1328,7 +1327,6 @@ if ($is_allowed_to_edit) {
null,
$sessionId)
) {
//don't use ViMod because firt is load ViMdod (Gradebook). VisibilityChanged (trad4all)
$message = Display::return_message(get_lang('VisibilityChanged'), 'confirmation');
} else {
$message = Display::return_message(get_lang('ViModProb'), 'error');

@ -2207,25 +2207,33 @@ function get_exercises_to_be_taken($course_code, $session_id)
**/
function get_student_stats_by_question($question_id, $exercise_id, $course_code, $session_id)
{
$track_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$question_id = intval($question_id);
$exercise_id = intval($exercise_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$sql = "SELECT MAX(marks) as max , MIN(marks) as min, AVG(marks) as average
FROM $track_exercises e INNER JOIN $track_attempt a ON (a.exe_id = e.exe_id)
WHERE exe_exo_id = $exercise_id AND
course_code = '$course_code' AND
e.session_id = $session_id AND
question_id = $question_id AND status = '' LIMIT 1";
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$question_id = intval($question_id);
$exercise_id = intval($exercise_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$sql = "SELECT MAX(marks) as max, MIN(marks) as min, AVG(marks) as average
FROM $track_exercises e
INNER JOIN $track_attempt a
ON (
a.exe_id = e.exe_id AND
e.exe_cours_id = a.course_code AND
e.session_id = a.session_id
)
WHERE
exe_exo_id = $exercise_id AND
course_code = '$course_code' AND
e.session_id = $session_id AND
question_id = $question_id AND
status = ''
LIMIT 1";
$result = Database::query($sql);
$return = array();
if ($result) {
$return = Database::fetch_array($result, 'ASSOC');
}
return $return;
@ -2240,30 +2248,46 @@ function get_student_stats_by_question($question_id, $exercise_id, $course_code
*/
function get_number_students_question_with_answer_count($question_id, $exercise_id, $course_code, $session_id)
{
$track_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$courseUserSession = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$question_id = intval($question_id);
$exercise_id = intval($exercise_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
if (empty($session_id)) {
$courseCondition = "
INNER JOIN $courseUser cu
ON cu.course_code = a.course_code AND cu.user_id = exe_user_id";
$courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT;
} else {
$courseCondition = "
INNER JOIN $courseUserSession cu
ON cu.course_code = a.course_code AND cu.id_user = exe_user_id";
$courseConditionWhere = " AND cu.status = 0 ";
}
$sql = "SELECT DISTINCT exe_user_id
FROM $track_exercises e
INNER JOIN $track_attempt a
ON (a.exe_id = e.exe_id)
INNER JOIN $course_user cu
ON cu.course_code = a.course_code AND cu.user_id = exe_user_id
ON (
a.exe_id = e.exe_id AND
e.exe_cours_id = a.course_code AND
e.session_id = a.session_id
)
$courseCondition
WHERE
exe_exo_id = $exercise_id AND
a.course_code = '$course_code' AND
e.session_id = $session_id AND
question_id = $question_id AND
answer <> '0' AND
cu.status = ".STUDENT." AND
relation_type <> 2 AND
e.status = ''";
exe_exo_id = $exercise_id AND
a.course_code = '$course_code' AND
e.session_id = $session_id AND
question_id = $question_id AND
answer <> '0' AND
e.status = ''
$courseConditionWhere
";
$result = Database::query($sql);
$return = 0;
if ($result) {
@ -2283,32 +2307,44 @@ function get_number_students_question_with_answer_count($question_id, $exercise_
*/
function get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, $course_code, $session_id)
{
$track_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$courseUserSession = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$question_id = intval($question_id);
$answer_id = intval($answer_id);
$exercise_id = intval($exercise_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$question_id = intval($question_id);
$answer_id = intval($answer_id);
$exercise_id = intval($exercise_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
if (empty($session_id)) {
$courseCondition = "
INNER JOIN $courseUser cu
ON cu.course_code = a.hotspot_course_code AND cu.user_id = exe_user_id";
$courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT;
} else {
$courseCondition = "
INNER JOIN $courseUserSession cu
ON cu.course_code = a.hotspot_course_code AND cu.id_user = exe_user_id";
$courseConditionWhere = " AND cu.status = 0 ";
}
$sql = "SELECT DISTINCT exe_user_id
FROM $track_exercises e
INNER JOIN $track_hotspot a
ON (a.hotspot_exe_id = e.exe_id)
INNER JOIN $course_user cu
ON cu.course_code = a.hotspot_course_code AND cu.user_id = exe_user_id
$courseCondition
WHERE
exe_exo_id = $exercise_id AND
a.hotspot_course_code = '$course_code' AND
e.session_id = $session_id AND
hotspot_answer_id = $answer_id AND
hotspot_question_id = $question_id AND
cu.status = ".STUDENT." AND
hotspot_correct = 1 AND
relation_type <> 2 AND
e.status = ''";
e.status = ''
$courseConditionWhere
";
$result = Database::query($sql);
$return = 0;
@ -2341,7 +2377,8 @@ function get_number_students_answer_count(
) {
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$courseUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$courseUserSession = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$question_id = intval($question_id);
$answer_id = intval($answer_id);
@ -2360,21 +2397,36 @@ function get_number_students_answer_count(
$select_condition = " DISTINCT exe_user_id ";
}
if (empty($session_id)) {
$courseCondition = "
INNER JOIN $courseUser cu
ON cu.course_code = a.course_code AND cu.user_id = exe_user_id";
$courseConditionWhere = " AND relation_type <> 2 AND cu.status = ".STUDENT;
} else {
$courseCondition = "
INNER JOIN $courseUserSession cu
ON cu.course_code = a.course_code AND cu.id_user = exe_user_id";
$courseConditionWhere = " AND cu.status = 0 ";
}
$sql = "SELECT $select_condition
FROM $track_exercises e
INNER JOIN $track_attempt a
ON (a.exe_id = e.exe_id)
INNER JOIN $course_user cu
ON cu.course_code = a.course_code AND cu.user_id = exe_user_id
ON (
a.exe_id = e.exe_id AND
e.exe_cours_id = a.course_code AND
e.session_id = a.session_id
)
$courseCondition
WHERE
exe_exo_id = $exercise_id AND
a.course_code = '$course_code' AND
e.session_id = $session_id AND
exe_exo_id = $exercise_id AND
a.course_code = '$course_code' AND
e.session_id = $session_id AND
$answer_condition
question_id = $question_id AND
cu.status = ".STUDENT." AND
relation_type <> 2 AND
e.status = ''";
question_id = $question_id AND
e.status = ''
$courseConditionWhere
";
$result = Database::query($sql);
$return = 0;
if ($result) {
@ -2526,8 +2578,8 @@ function check_fill_in_blanks($answer, $user_answer)
*/
function get_number_students_finish_exercise($exercise_id, $course_code, $session_id)
{
$track_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$exercise_id = intval($exercise_id);
$course_code = Database::escape_string($course_code);

@ -5,7 +5,7 @@ $language_file = array('exercice', 'tracking');
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
$exercise_id = (isset($_GET['exerciseId']) && !empty($_GET['exerciseId'])) ? intval($_GET['exerciseId']) : 0;
$exercise_id = isset($_GET['exerciseId']) && !empty($_GET['exerciseId']) ? intval($_GET['exerciseId']) : 0;
$gradebook = isset($gradebook) ? $gradebook : null;
$objExercise = new Exercise();
@ -15,23 +15,22 @@ if (!$result) {
api_not_allowed(true);
}
$session_id = api_get_session_id();
$sessionId = api_get_session_id();
$courseCode = api_get_course_id();
if (empty($session_id)) {
$students = CourseManager :: get_student_list_from_course_code(api_get_course_id(), false);
if (empty($sessionId)) {
$students = CourseManager :: get_student_list_from_course_code($courseCode, false);
} else {
$students = CourseManager :: get_student_list_from_course_code(api_get_course_id(), true, $session_id);
$students = CourseManager :: get_student_list_from_course_code($courseCode, true, $sessionId);
}
$count_students = count($students);
$question_list = $objExercise->get_validated_question_list();
$data = array();
//Question title # of students who tool it Lowest score Average Highest score Maximum score
// Question title # of students who tool it Lowest score Average Highest score Maximum score
$headers = array(
get_lang('Question'),
get_lang('QuestionType'),
//get_lang('NumberOfStudentsWhoTryTheExercise'),
get_lang('NumberStudentWhoSelectedIt'),
get_lang('LowestScore'),
get_lang('AverageScore'),
@ -41,28 +40,42 @@ $headers = array(
if (!empty($question_list)) {
foreach ($question_list as $question_id) {
$question_obj = Question::read($question_id);
$exercise_stats = get_student_stats_by_question($question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$count_users = get_number_students_question_with_answer_count($question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$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'];
$question_obj = Question::read($question_id);
$exercise_stats = get_student_stats_by_question(
$question_id,
$exercise_id,
$courseCode,
$sessionId
);
$count_users = get_number_students_question_with_answer_count(
$question_id,
$exercise_id,
$courseCode,
$sessionId
);
$data[$question_id]['name'] = cut($question_obj->question, 100);
$data[$question_id]['type'] = $question_obj->get_question_type_name();
$percentange = 0;
if ($count_students) {
$percentange = $count_users/$count_students*100;
$percentange = $count_users / $count_students*100;
}
$data[$question_id]['students_who_try_exercise'] = Display::bar_progress($percentange, false, $count_users .' / '.$count_students);
$data[$question_id]['lowest_score'] = round($exercise_stats['min'], 2);
$data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
$data[$question_id]['highest_score'] = round($exercise_stats['max'], 2);
$data[$question_id]['max_score'] = round($question_obj->weighting, 2);
$data[$question_id]['students_who_try_exercise'] = Display::bar_progress(
$percentange,
false,
$count_users .' / '.$count_students
);
$data[$question_id]['lowest_score'] = round($exercise_stats['min'], 2);
$data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
$data[$question_id]['highest_score'] = round($exercise_stats['max'], 2);
$data[$question_id]['max_score'] = round($question_obj->weighting, 2);
}
}
//Format A table
// Format A table
$table = new HTML_Table(array('class' => 'data_table'));
$row = 0;
$column = 0;
@ -83,7 +96,7 @@ foreach ($data as $row_table) {
}
$content = $table->toHtml();
//Format B
// Format B
$headers = array(
get_lang('Question'),
@ -98,19 +111,23 @@ if (!empty($question_list)) {
$id = 0;
foreach ($question_list as $question_id) {
$question_obj = Question::read($question_id);
$exercise_stats = get_student_stats_by_question($question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$exercise_stats = get_student_stats_by_question(
$question_id,
$exercise_id,
$courseCode,
$sessionId
);
$answer = new Answer($question_id);
$answer_count = $answer->selectNbrAnswers();
for ($answer_id = 1; $answer_id <= $answer_count; $answer_id++) {
$answer_info = $answer->selectAnswer($answer_id);
$is_correct = $answer->isCorrect($answer_id);
$answer_info = $answer->selectAnswer($answer_id);
$is_correct = $answer->isCorrect($answer_id);
$correct_answer = $is_correct == 1 ? get_lang('Yes') : get_lang('No');
$real_answer_id = $answer->selectAutoId($answer_id);
//$data[$id]['name'] .=$answer_count;
//Overwriting values depending of the question
// Overwriting values depending of the question
switch ($question_obj->type) {
case FILL_IN_BLANKS :
$answer_info_db = $answer_info;
@ -120,9 +137,9 @@ if (!empty($question_list)) {
$counter = 0;
foreach ($answers as $answer_item) {
if ($counter == 0) {
$data[$id]['name'] = cut($question_obj->question, 100);
$data[$id]['name'] = cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
$data[$id]['name'] = '-';
}
$data[$id]['answer'] = $answer_item;
@ -131,13 +148,22 @@ if (!empty($question_list)) {
$data[$id]['correct'] = '-';
$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);
$count = get_number_students_answer_count(
$real_answer_id,
$question_id,
$exercise_id,
$courseCode,
$sessionId,
FILL_IN_BLANKS,
$answer_info_db,
$answer_item
);
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;
}
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
$id++;
$counter++;
@ -146,9 +172,9 @@ if (!empty($question_list)) {
case MATCHING:
if ($is_correct == 0) {
if ($answer_id == 1) {
$data[$id]['name'] = cut($question_obj->question, 100);
$data[$id]['name'] = cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
$data[$id]['name'] = '-';
}
$correct = '';
@ -159,48 +185,67 @@ if (!empty($question_list)) {
break;
}
}
$data[$id]['answer'] = $correct;
$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);
$data[$id]['answer'] = $correct;
$data[$id]['correct'] = $answer_info;
$count = get_number_students_answer_count(
$answer_id,
$question_id,
$exercise_id,
$courseCode,
$sessionId,
MATCHING
);
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;
}
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
}
break;
case HOT_SPOT:
if ($answer_id == 1) {
$data[$id]['name'] = cut($question_obj->question, 100);
$data[$id]['name'] = cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
$data[$id]['name'] = '-';
}
$data[$id]['answer'] = $answer_info;
$data[$id]['correct'] = '-';
$count = get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$data[$id]['answer'] = $answer_info;
$data[$id]['correct'] = '-';
$count = get_number_students_answer_hotspot_count(
$answer_id,
$question_id,
$exercise_id,
$courseCode,
$sessionId
);
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;
}
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
break;
default:
if ($answer_id == 1) {
$data[$id]['name'] = cut($question_obj->question, 100);
$data[$id]['name'] = cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
$data[$id]['name'] = '-';
}
$data[$id]['answer'] = $answer_info;
$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());
$data[$id]['answer'] = $answer_info;
$data[$id]['correct'] = $correct_answer;
$count = get_number_students_answer_count(
$real_answer_id,
$question_id,
$exercise_id,
$courseCode,
$sessionId
);
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;
}
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
}
$id++;
}
@ -208,7 +253,7 @@ if (!empty($question_list)) {
}
}
//Format A table
// Format A table
$table = new HTML_Table(array('class' => 'data_table'));
$row = 0;
$column = 0;
@ -239,7 +284,8 @@ $tpl = new Template(get_lang('ReportByQuestion'));
//$actions[]= array(get_lang('Back'), Display::return_icon('back.png', get_lang('Back'), 'exercise_report.php?'.$exercise_id));
//$tpl->set_actions($actions);
$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'">' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
$actions = '<a href="exercise_report.php?exerciseId='.intval($_GET['exerciseId']).'">' .
Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'',ICON_SIZE_MEDIUM).'</a>';
$actions = Display::div($actions, array('class'=> 'actions'));
$content = $actions.$content;
$tpl->assign('content', $content);

Loading…
Cancel
Save