Report, progress of exercise REFS BT#7017

1.9.x
César Perales 11 years ago
parent 13b2328926
commit 4052f7e562
  1. 39
      main/inc/ajax/model.ajax.php
  2. 57
      main/inc/lib/sessionmanager.lib.php
  3. 17
      main/mySpace/index.php
  4. 55
      main/mySpace/myspace.lib.php

@ -239,14 +239,16 @@ switch ($action) {
break;
case 'get_session_lp_progress':
case 'get_session_progress':
#$count = SessionManager::get_count_session_lp_progress(intval($_GET['session_id']));
#break;
$courses = SessionManager::get_course_list_by_session_id(intval($_GET['session_id']));
//TODO let select course
$course = current($courses);
$users = CourseManager::get_student_list_from_course_code($course['code'], true, intval($_GET['session_id']));
$count = count($users);
break;
case 'get_exercise_progress':
$records = SessionManager::get_exercise_progress(intval($_GET['session_id']));
$count = count($records);
break;
/*case 'get_extra_fields':
$type = $_REQUEST['type'];
$obj = new ExtraField($type);
@ -563,6 +565,38 @@ switch ($action) {
)
);
break;
case 'get_exercise_progress':
$sessionId = 0;
if (isset($_GET['session_id']) && !empty($_GET['session_id']))
{
$sessionId = intval($_GET['session_id']);
$courses = SessionManager::get_course_list_by_session_id($sessionId);
//TODO let select course
$course = current($courses);
}
$columns = array(
'session',
'exercise_id',
'quiz_title',
'username',
'lastname',
'firstname',
'time',
'question_id',
'question',
'answer',
'correct'
);
$result = SessionManager::get_exercise_progress($sessionId,
array(
'where' => $where_condition,
'order' => "$sidx $sord",
'limit'=> "$start , $limit"
)
);
break;
case 'get_session_lp_progress':
$sessionId = 0;
if (isset($_GET['session_id']) && !empty($_GET['session_id']))
@ -861,6 +895,7 @@ $allowed_actions = array(
'get_sessions_tracking',
'get_session_lp_progress',
'get_session_progress',
'get_exercise_progress',
'get_exercise_results',
'get_hotpotatoes_exercise_results',
'get_work_teacher',

@ -501,6 +501,58 @@ class SessionManager
$num = $row['total_rows'];
return $num;
}
/**
* Get the progress of a exercise
* @param int session id
* @return array
*/
public static function get_exercise_progress($sessionId = 0, $options = array())
{
$session = Database::get_main_table(TABLE_MAIN_SESSION);
$user = Database::get_main_table(TABLE_MAIN_USER);
$quiz = Database::get_course_table(TABLE_QUIZ_TEST);
$quiz_answer = Database::get_course_table(TABLE_QUIZ_ANSWER);
$quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$table_stats_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$table_stats_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$courses = SessionManager::get_course_list_by_session_id($sessionId);
//TODO let select course
$course = current($courses);
//TODO fix this
$course_info = array('real_id' => $course['id']);
$sql = "SELECT
s.name as session,
CONCAT (q.c_id, q.id) as exercise_id,
q.title as quiz_title,
u.username,
u.lastname,
u.firstname,
a.tms as time,
qa.question_id,
qq.question,
qa.answer,
qa.correct
FROM $table_stats_attempt a
LEFT JOIN $quiz_answer qa ON a.answer = qa.id_auto
LEFT JOIN $quiz_question qq ON qq.id = qa.question_id
INNER JOIN $table_stats_exercises e ON e.exe_id = a.exe_id
INNER JOIN $session s ON s.id = a.session_id
INNER JOIN $quiz q ON q.id = e.exe_exo_id
INNER JOIN $user u ON u.user_id = a.user_id
WHERE a.session_id = %d
AND a.course_code = '%s'";
$sql_query = sprintf($sql, $sessionId, $course['code']);
$rs = Database::query($sql_query);
while ($row = Database::fetch_array($rs))
{
$data[] = $row;
}
return $data;
}
/**
* Gets the progress of learning paths in the given session
* @param int session id
@ -520,6 +572,7 @@ class SessionManager
//TODO fix this
$course_info = array('real_id' => $course['id']);
//getting all the students of the course
//we are not using this because it only returns user ids
/*if (empty($sessionId)
@ -607,8 +660,8 @@ class SessionManager
$forum_post = Database::get_course_table(TABLE_FORUM_POST);
$tbl_course_lp = Database::get_course_table(TABLE_LP_MAIN);
$wiki = Database::get_course_table(TABLE_WIKI);
$table_stats_default = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_stats_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$table_stats_default = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$table_stats_access = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$courses = SessionManager::get_course_list_by_session_id($sessionId);
//TODO let select course

@ -160,7 +160,7 @@ echo '<a href="javascript: void(0);" onclick="javascript: window.print()">'.
Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</span>';
if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview','progressoverview'))) {
if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogressoverview','progressoverview','exerciseprogress'))) {
echo '<a href="index.php">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
if (!api_is_platform_admin()) {
if (api_get_setting('add_users_by_coach') == 'true') {
@ -183,7 +183,7 @@ if (!empty($session_id) && !in_array($display, array('accessoverview','lpprogres
// Actions menu
$nb_menu_items = count($menu_items);
if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview'))) {
if (empty($session_id) || in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview', 'exerciseprogress'))) {
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
@ -204,7 +204,7 @@ $sessionFilter->addElement('select_ajax', 'session_name', get_lang('SearchCourse
$courseListUrl = api_get_self();
#show filter by session
if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview'))) {
if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','lpprogressoverview', 'progressoverview', 'exerciseprogress'))) {
echo '<div class="pull-right">';
echo $sessionFilter->return_form();
echo '</div>';
@ -608,6 +608,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
echo ' | <a href="'.api_get_self().'?view=admin&amp;display=accessoverview">'.get_lang('DisplayAccessOverview').'</a>';
echo ' | <a href="'.api_get_self().'?view=admin&amp;display=lpprogressoverview">'.get_lang('DisplayLpProgressOverview').'</a>';
echo ' | <a href="'.api_get_self().'?view=admin&amp;display=progressoverview">'.get_lang('DisplayProgressOverview').'</a>';
echo ' | <a href="'.api_get_self().'?view=admin&amp;display=exerciseprogress">'.get_lang('DisplayExerciseProgress').'</a>';
echo ' | <a href="'.api_get_self().'?view=admin&amp;display=courseoverview">'.get_lang('DisplayCourseOverview').'</a>';
echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/question_course_report.php?view=admin">'.get_lang('LPQuestionListResults').'</a>';
echo ' | <a href="'.api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin">'.get_lang('LPExerciseResultsBySession').'</a>';
@ -625,13 +626,19 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
}
} else if($display == 'lpprogressoverview') {
if (!empty($_GET['session_id'])) {
echo MySpace::display_tracking_lp_progress_overview($_GET['session_id']);
echo MySpace::display_tracking_lp_progress_overview(intval($_GET['session_id']));
} else {
Display::display_warning_message(get_lang('ChooseSession'));
}
} else if($display == 'progressoverview') {
if (!empty($_GET['session_id'])) {
echo MySpace::display_tracking_progress_overview($_GET['session_id']);
echo MySpace::display_tracking_progress_overview(intval($_GET['session_id']));
} else {
Display::display_warning_message(get_lang('ChooseSession'));
}
} else if($display == 'exerciseprogress') {
if (!empty($_GET['session_id'])) {
echo MySpace::display_tracking_exercise_progress_overview(intval($_GET['session_id']));
} else {
Display::display_warning_message(get_lang('ChooseSession'));
}

@ -320,6 +320,61 @@ class MySpace {
$table = Display::grid_js('lps', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$return = '<script>$(function() {'. $table . '});</script>';
$return .= Display::grid_html('lps');
return $return;
}
/**
* Display a sortable table that contains an overview off all the progress of the user in a session
* @author César Perales <cesar.perales@beeznest.com>, Beeznest Team
*/
function display_tracking_exercise_progress_overview($sessionId = 0) {
$courses = SessionManager::get_course_list_by_session_id($sessionId);
//TODO let select course
$course = current($courses);
/**
* Column name
* The order is important you need to check the $column variable in the model.ajax.php file
*/
$columns = array(
get_lang('Session'),
get_lang('ExerciseId'),
get_lang('QuizTitle'),
get_lang('Username'),
get_lang('Lastname'),
get_lang('Firstname'),
get_lang('Time'),
get_lang('Question_id'),
get_lang('Question'),
get_lang('Answer'),
get_lang('Correct'),
);
/**
* Column config
*/
$column_model = array(
array('name'=>'session', 'index'=>'session', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
array('name'=>'exercise_id', 'index'=>'exercise_id', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'quiz_title', 'index'=>'quiz_title', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'username', 'index'=>'username', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'lastname', 'index'=>'lastname', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'firstname', 'index'=>'firstname', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'time', 'index'=>'time', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'question_id', 'index'=>'question_id', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'question', 'index'=>'question', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'answer', 'index'=>'answer', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'correct', 'index'=>'correct', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
);
//get dinamic column names
$action_links = '';
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id=' . intval($sessionId);
$table = Display::grid_js('lps', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$return = '<script>$(function() {'. $table . '});</script>';
$return .= Display::grid_html('lps');
return $return;

Loading…
Cancel
Save