Skip to content

Commit

Permalink
Add learnpath_item_view_id in url see BT#11905
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Oct 27, 2016
1 parent 5a145fe commit 0aa20ed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
1 change: 0 additions & 1 deletion main/exercise/exercise_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

/** @var Exercise $objExercise */
if (empty($objExercise)) {

$objExercise = Session::read('objExercise');
}
if (empty($remind_list)) {
Expand Down
3 changes: 2 additions & 1 deletion main/exercise/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
$gradebook = isset($_GET['gradebook']) ? Security :: remove_XSS($_GET['gradebook']) : null;
$learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : null;
$learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : null;
$learnpathItemViewId = isset($_REQUEST['learnpath_item_view_id']) ? intval($_REQUEST['learnpath_item_view_id']) : null;
$origin = api_get_origin();

$interbreadcrumb[] = array("url" => "exercise.php?gradebook=$gradebook", "name" => get_lang('Exercises'));
Expand Down Expand Up @@ -115,7 +116,7 @@

// 2. Exercise button
// Notice we not add there the lp_item_view_id because is not already generated
$exercise_url = api_get_path(WEB_CODE_PATH) . 'exercise/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.$extra_params;
$exercise_url = api_get_path(WEB_CODE_PATH) . 'exercise/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&learnpath_item_view_id='.$learnpathItemViewId.$extra_params;
$exercise_url_button = Display::url(
$label,
$exercise_url,
Expand Down
21 changes: 18 additions & 3 deletions main/lp/learnpath.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3409,7 +3409,6 @@ public function get_link($type = 'http', $item_id = null, $provided_toc = false)
$item_id,
$this->get_view_id()
);

if ($this->debug > 0) {
error_log('rl_get_resource_link_for_learnpath - file: ' . $file, 0);
}
Expand Down Expand Up @@ -11295,12 +11294,28 @@ public static function rl_get_resource_link_for_learnpath($course_id, $learningP
}
$row_item = Database::fetch_array($res_item, 'ASSOC');

$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
// Get the lp_item_view with the highest view_count.
$sql = "SELECT * FROM $item_view_table
WHERE
c_id = $course_id AND
lp_item_id = " . $row_item['id'] . " AND
lp_view_id = " . $lpViewId . "
ORDER BY view_count DESC";
$learnpathItemViewResult = Database::query($sql);
$learnpathItemViewData = Database::fetch_array($learnpathItemViewResult, 'ASSOC');
$learnpathItemViewId = 0;
if (isset($learnpathItemViewData)) {
$learnpathItemViewId = $learnpathItemViewData['id'];
}

$type = strtolower($row_item['item_type']);
$id = (strcmp($row_item['path'], '') == 0) ? '0' : $row_item['path'];
$origin = 'learnpath';
$main_dir_path = api_get_path(WEB_CODE_PATH);
$main_course_path = api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/';
$link = '';

switch ($type) {
case 'dir':
$link .= $main_dir_path . 'lp/blank.php';
Expand All @@ -11322,11 +11337,11 @@ public static function rl_get_resource_link_for_learnpath($course_id, $learningP
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$sql = "SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id";
$result= Database::query($sql);
$myrow=Database::fetch_array($result);
$myrow = Database::fetch_array($result);
if ($row_item['title'] != '') {
$myrow['title'] = $row_item['title'];
}
$link .= $main_dir_path . 'exercise/overview.php?cidReq='.$course_code.'&session_id='.$session_id.'&lp_init=1&origin='.$origin.'&learnpath_id='.$learningPathId.'&learnpath_item_id='.$id_in_path.'&exerciseId='.$id;
$link .= $main_dir_path . 'exercise/overview.php?cidReq='.$course_code.'&session_id='.$session_id.'&lp_init=1&origin='.$origin.'&learnpath_item_view_id='.$learnpathItemViewId.'&learnpath_id='.$learningPathId.'&learnpath_item_id='.$id_in_path.'&exerciseId='.$id;
}
break;
case 'hotpotatoes': //lowercase because of strtolower above
Expand Down

0 comments on commit 0aa20ed

Please sign in to comment.