Fixing session exericse reports see #5589

skala
Julio Montoya 12 years ago
parent a535d80408
commit 8f683893ad
  1. 1
      main/mySpace/lp_tracking.php
  2. 9
      main/newscorm/learnpath.class.php
  3. 84
      main/newscorm/lp_stats.php

@ -6,7 +6,6 @@ require_once '../inc/global.inc.php';
// resetting the course id
$cidReset = true;
$from_myspace = false;
$from_link = '';
if (isset($_GET['from']) && $_GET['from'] == 'myspace') {

@ -354,10 +354,9 @@ class learnpath {
$res_ins = Database::query($sql_ins);
}
}
}
}
$this->ordered_items = $this->get_flat_ordered_items_list($this->get_id(), 0, $course_id);
$this->ordered_items = self::get_flat_ordered_items_list($this->get_id(), 0, $course_id);
$this->max_ordered_items = 0;
foreach ($this->ordered_items as $index => $dummy) {
if ($index > $this->max_ordered_items && !empty($dummy)) {
@ -2682,7 +2681,7 @@ class learnpath {
* @param integer Parent ID of the items to look for
* @return mixed Ordered list of item IDs or false on error
*/
public function get_flat_ordered_items_list($lp, $parent = 0, $course_id = null) {
public static function get_flat_ordered_items_list($lp, $parent = 0, $course_id = null) {
if (empty($course_id)) {
$course_id = api_get_course_int_id();
} else {
@ -9075,7 +9074,7 @@ EOD;
if (!empty($course_data)) {
$scorm_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/scorm/'.$this->path;
$list = $this->get_flat_ordered_items_list($lp_id);
$list = self::get_flat_ordered_items_list($lp_id);
if (!empty($list)) {
foreach ($list as $item_id) {
$item = $this->items[$item_id];

@ -16,7 +16,10 @@ require_once 'resourcelinker.inc.php';
require_once '../exercice/exercise.lib.php';
$course_code = api_get_course_id();
$user_id = api_get_user_id();
if (empty($user_id)) {
$user_id = api_get_user_id();
}
// Declare variables to be used in lp_stats.php
@ -26,12 +29,10 @@ if (isset($_GET['lp_id']) && isset($lp_id) && !empty($lp_id)) {
} else {
if (isset($_SESSION['oLP'])) {
$lp_id = $_SESSION['oLP']->get_id();
$list = $_SESSION['oLP']->get_flat_ordered_items_list($lp_id);
$list = learnpath::get_flat_ordered_items_list($lp_id);
}
}
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
if (isset($_GET['course'])) {
@ -149,7 +150,6 @@ if (isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) {
}
//Show lp items
if (is_array($list) && count($list) > 0) {
foreach ($list as $my_item_id) {
$extend_this = 0;
@ -161,47 +161,63 @@ if (is_array($list) && count($list) > 0) {
// Prepare statement to go through each attempt.
if (!empty($view)) {
$sql = "SELECT iv.status as mystatus, v.view_count as mycount, iv.score as myscore, iv.total_time as mytime, i.id as myid,
i.lp_id as mylpid, iv.lp_view_id as mylpviewid, i.title as mytitle, i.max_score as mymaxscore,
iv.max_score as myviewmaxscore, i.item_type as item_type, iv.view_count as iv_view_count, iv.id as iv_id, path as path
FROM $TBL_LP_ITEM as i INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id )
INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id)
$sql = "SELECT
iv.status as mystatus,
v.view_count as mycount,
iv.score as myscore,
iv.total_time as mytime,
i.id as myid,
i.lp_id as mylpid,
iv.lp_view_id as mylpviewid,
i.title as mytitle,
i.max_score as mymaxscore,
iv.max_score as myviewmaxscore,
i.item_type as item_type,
iv.view_count as iv_view_count,
iv.id as iv_id,
path
FROM $TBL_LP_ITEM as i
INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id)
INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id AND v.c_id = $course_id)
WHERE
i.c_id = $course_id AND
iv.c_id = $course_id AND
v.c_id = $course_id AND i.id = $my_item_id AND
i.id = $my_item_id AND
i.lp_id = $lp_id AND
v.user_id = " . $user_id . " AND
v.user_id = $user_id AND
v.view_count = $view AND v.session_id = $session_id
ORDER BY iv.view_count $qry_order ";
//var_dump($sql);
} else {
$sql = "SELECT iv.status as mystatus, v.view_count as mycount, " .
" iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " .
" i.title as mytitle, i.max_score as mymaxscore, " .
" iv.max_score as myviewmaxscore, " .
" i.item_type as item_type, iv.view_count as iv_view_count, " .
" iv.id as iv_id, path as path " .
" FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v " .
" WHERE i.id = iv.lp_item_id AND
i.c_id = $course_id AND
iv.c_id = $course_id AND
v.c_id = $course_id AND
i.id = $my_item_id " .
" AND iv.lp_view_id = v.id " .
" AND i.lp_id = $lp_id " .
" AND v.user_id = " . $user_id . " " .
" AND v.session_id = $session_id " .
" ORDER BY iv.view_count $qry_order ";
$sql = "SELECT
iv.status as mystatus,
v.view_count as mycount,
iv.score as myscore,
iv.total_time as mytime,
i.id as myid,
i.lp_id as mylpid,
iv.lp_view_id as mylpviewid,
i.title as mytitle,
i.max_score as mymaxscore,
iv.max_score as myviewmaxscore,
i.item_type as item_type,
iv.view_count as iv_view_count,
iv.id as iv_id,
path
FROM $TBL_LP_ITEM as i
INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id)
INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id AND v.c_id = $course_id)
WHERE
i.id = $my_item_id AND
i.lp_id = $lp_id AND
v.user_id = $user_id AND
v.session_id = $session_id
ORDER BY iv.view_count $qry_order ";
}
$result = Database::query($sql);
$num = Database :: num_rows($result);
$time_for_total = 'NaN';
//Extend all + extend scorm?
if (($extend_this || $extend_all) && $num > 0) {
//var_dump('go');
if (($extend_this || $extend_all) && $num > 0) {
$row = Database :: fetch_array($result);
$result_disabled_ext_all = false;
if ($row['item_type'] == 'quiz') {

Loading…
Cancel
Save