User Learning Path progress by session refs BT#7015

1.9.x
César Perales 12 years ago
parent fc9bf1a84c
commit c8e3425aec
  1. 21
      main/inc/ajax/model.ajax.php
  2. 75
      main/inc/lib/sessionmanager.lib.php
  3. 21
      main/mySpace/index.php
  4. 27
      main/mySpace/myspace.lib.php

@ -203,6 +203,9 @@ switch ($action) {
}
$count = SessionManager::get_count_admin($where_condition);
break;
case 'get_session_lp_progress':
$count = SessionManager::get_count_session_lp_progress($_GET['session_id']);
break;
/*case 'get_extra_fields':
$type = $_REQUEST['type'];
$obj = new ExtraField($type);
@ -431,6 +434,23 @@ switch ($action) {
)
);
break;
case 'get_session_lp_progress':
$columns = array(
'username', 'firstname', 'lastname', 'name', 'progress'
);
$sessionId = 0;
if (isset($_GET['session_id']) && !empty($_GET['session_id']))
{
$sessionId = intval($_GET['session_id']);
}
$result = SessionManager::get_session_lp_progress($sessionId,
array(
'where' => $where_condition,
'order' => "$sidx $sord",
'limit'=> "$start , $limit"
)
);
break;
case 'get_timelines':
$columns = array('headline', 'actions');
@ -630,6 +650,7 @@ $allowed_actions = array(
'get_usergroups_teacher',
'get_gradebooks',
'get_sessions',
'get_session_lp_progress',
'get_exercise_results',
'get_hotpotatoes_exercise_results',
'get_work_teacher',

@ -475,10 +475,83 @@ class SessionManager
$formatted_sessions[] = $session;
}
}
return $formatted_sessions;
}
/**
* Get total of records for progress of learning paths in the given session
* @param int session id
* @return int
*/
public static function get_count_session_lp_progress($sessionId = 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "select count(*) as total_rows
FROM $tbl_lp_view v
INNER JOIN $tbl_lp l ON l.id = v.lp_id
INNER JOIN $tbl_user u ON u.user_id = v.user_id
INNER JOIN $tbl_course c";
$sql .= ' WHERE v.session_id = ' . $sessionId;
$result_rows = Database::query($sql);
$row = Database::fetch_array($result_rows);
$num = $row['total_rows'];
return $num;
}
/**
* Gets the progress of learning paths in the given session
* @param int session id
* @param array options order and limit keys
* @return array table with user name, lp name, progress
*/
public static function get_session_lp_progress($sessionId = 0, $options)
{
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$select = "select u.username, u.firstname, u.lastname, l.name, v.progress
FROM $tbl_lp_view v
INNER JOIN $tbl_lp l ON l.id = v.lp_id
INNER JOIN $tbl_user u ON u.user_id = v.user_id
INNER JOIN $tbl_course c
";
$where = ' WHERE 1=1 ';
if (!empty($options['where'])) {
$where .= ' AND '.$options['where'];
}
$where .= ' AND v.session_id = ' . $sessionId;
$order = null;
if (!empty($options['order'])) {
$order = " ORDER BY ".$options['order'];
}
$limit = null;
if (!empty($options['limit'])) {
$limit = " LIMIT ".$options['limit'];
}
$select .= $where.$order.$limit;
error_log($select);
$result = Database::query($select);
$formatted_sessions = array();
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_assoc($result)) {
error_log(print_r($row,1));
$formatted_sessions[] = $row;
}
/*foreach ($lps as $lp) {
error_log(print_r($lp,1));
}*/
}
return $formatted_sessions;
}
/**
* Creates a new course code based in given code
*

@ -18,6 +18,7 @@ require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once 'myspace.lib.php';
$htmlHeadXtra[] = api_get_jqgrid_js();
// the section (for the tabs)
$this_section = SECTION_TRACKING;
//for HTML editor repository
@ -158,7 +159,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) && $display != 'accessoverview') {
if (!empty($session_id) && !in_array($display, array('accessoverview','progressoverview'))) {
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') {
@ -182,7 +183,7 @@ if (!empty($session_id) && $display != 'accessoverview') {
// Actions menu
$nb_menu_items = count($menu_items);
if (empty($session_id) || $display == 'accessoverview') {
if (empty($session_id) || in_array($display, array('accessoverview','progressoverview'))) {
if ($nb_menu_items > 1) {
foreach ($menu_items as $key => $item) {
echo $item;
@ -201,17 +202,20 @@ if (empty($session_id) || $display == 'accessoverview') {
}
$sessionFilter->addElement('select_ajax', 'session_name', get_lang('SearchCourseBySession'), null, array('url' => $url, 'defaults' => $sessionList));
$courseListUrl = api_get_self();
if ($is_platform_admin && $view == 'admin' && $display == 'accessoverview') {
#show filter by session
if ($is_platform_admin && $view == 'admin' && in_array($display, array('accessoverview','progressoverview'))) {
echo '<div class="pull-right">';
echo $sessionFilter->return_form();
echo '</div>';
echo '<script>$(function() {
$("#session_name").on("change", function() {
var sessionId = $(this).val();
window.location = "'.$courseListUrl.'?view=admin&display=accessoverview&session_id="+sessionId;
window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId;
});
});</script>';
}
echo '</div>';
if (empty($session_id)) {
@ -627,6 +631,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
}
echo ' | <a href="'.api_get_self().'?view=admin&amp;display=sessionoverview">'.get_lang('DisplaySessionOverview').'</a>';
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=progressoverview">'.get_lang('DisplayProgressOverview').'</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>';
@ -638,11 +643,17 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
} else if($display == 'sessionoverview') {
MySpace::display_tracking_session_overview();
} else if($display == 'accessoverview') {
if (!empty(isset($_GET['session_id']))) {
if (!empty($_GET['session_id'])) {
MySpace::display_tracking_access_overview();
} 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']);
} else {
Display::display_warning_message(get_lang('ChooseSession'));
}
} else if($display == 'courseoverview') {
MySpace::display_tracking_course_overview();
} else {

@ -270,6 +270,33 @@ class MySpace {
$table->set_column_filter(4, array('MySpace','course_info_tracking_filter'));
$table->display();
}
/**
* 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_progress_overview($sessionId = 0) {
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('Username'), get_lang('FirstName'), get_lang('LastName'), get_lang('Name'), get_lang('Progress'));
//Column config
$column_model = array(
array('name'=>'username', 'index'=>'username', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
array('name'=>'firstname', 'index'=>'firstname', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'lastname', 'index'=>'lastname', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'name', 'index'=>'name', 'width'=>'100', 'align'=>'left', 'search' => 'true'),
array('name'=>'progress', 'index'=>'progress', 'width'=>'70', 'align'=>'left', 'search' => 'true'),
);
$action_links = '';
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_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;
}
/**
* Display a sortable table that contains an overview off all the access to a session
* @author César Perales <cesar.perales@beeznest.com>, Beeznest Team

Loading…
Cancel
Save