Lps: Fix add items

pull/3741/head
Julio Montoya 4 years ago
parent b5492b2169
commit 9863485893
  1. 2
      public/main/forum/forumfunction.inc.php
  2. 10
      public/main/inc/ajax/lp.ajax.php
  3. 6
      public/main/inc/lib/document.lib.php
  4. 31
      public/main/inc/lib/tracking.lib.php
  5. 139
      public/main/lp/learnpath.class.php
  6. 103
      public/main/lp/lp_controller.php

@ -3233,7 +3233,7 @@ function showQualify($option, $user_id, $thread_id)
break;
case 2:
$sql = "SELECT thread_qualify_max FROM $table_threads
WHERE c_id = $course_id AND thread_id=".$thread_id;
WHERE c_id = $course_id AND iid=".$thread_id;
break;
}

@ -80,8 +80,8 @@ switch ($action) {
break;
}
$parentId = isset($_REQUEST['parent_id']) ? $_REQUEST['parent_id'] : '';
$previousId = isset($_REQUEST['previous_id']) ? $_REQUEST['previous_id'] : '';
$parentId = $_REQUEST['parent_id'] ?? '';
$previousId = $_REQUEST['previous_id'] ?? '';
$itemId = $learningPath->add_item(
$parentId,
@ -92,11 +92,7 @@ switch ($action) {
null
);
/** @var learnpath $learningPath */
$learningPath = Session::read('oLP');
if ($learningPath) {
echo $learningPath->returnLpItemList(null);
}
echo $learningPath->returnLpItemList(null);
}
break;
case 'update_lp_item_order':

@ -2930,7 +2930,11 @@ class DocumentManager
$folder = '';
}
$link .= '<a data_id="'.$node['id'].'" data_type="document" class="moved ui-sortable-handle link_with_id">';
$link .= '<a
data_id="'.$node['id'].'"
data_type="document"
class="moved ui-sortable-handle link_with_id"
>';
$link .= $folder.'&nbsp;'.addslashes($node['title']);
$link .= '</a>';

@ -840,7 +840,7 @@ class Tracking
question_id, marks, ponderation
FROM $tbl_stats_attempts as at
INNER JOIN $tbl_quiz_questions as q
ON (q.id = at.question_id AND q.c_id = $course_id)
ON (q.iid = at.question_id AND q.c_id = $course_id)
WHERE exe_id ='$id_last_attempt'
) as t";
@ -2878,7 +2878,7 @@ class Tracking
// Getting the most recent attempt
$sql = "SELECT
lp_iv.id as lp_item_view_id,
lp_iv.iid as lp_item_view_id,
lp_iv.score as score,
lp_i.max_score,
lp_iv.max_score as max_score_item_view,
@ -2909,13 +2909,13 @@ class Tracking
// For the currently analysed view, get the score and
// max_score of each item if it is a sco or a TOOL_QUIZ
$sql = "SELECT
lp_iv.id as lp_item_view_id,
lp_iv.iid as lp_item_view_id,
lp_iv.score as score,
lp_i.max_score,
lp_iv.max_score as max_score_item_view,
lp_i.path,
lp_i.item_type,
lp_i.id as iid
lp_i.iid
FROM $lp_item_view_table as lp_iv
INNER JOIN $lp_item_table as lp_i
ON lp_i.iid = lp_iv.lp_item_id AND
@ -3025,7 +3025,7 @@ class Tracking
ponderation
FROM $tbl_stats_attempts AS at
INNER JOIN $tbl_quiz_questions AS q
ON (q.id = at.question_id AND q.c_id = q.c_id)
ON (q.iid = at.question_id AND q.c_id = q.c_id)
WHERE
exe_id ='$id_last_attempt' AND
q.c_id = $course_id
@ -4760,7 +4760,8 @@ class Tracking
} else {
$sql = "SELECT c.id, c.code, title
FROM $tbl_course_user u
INNER JOIN $tbl_course c ON (c_id = c.id)
INNER JOIN $tbl_course c
ON (c_id = c.id)
WHERE
u.user_id= $user_id AND
relation_type <> ".COURSE_RELATION_TYPE_RRHH."
@ -6451,7 +6452,7 @@ class Tracking
if (!empty($exerciseId)) {
$exerciseId = intval($exerciseId);
$where .= ' AND q.id = %d ';
$where .= ' AND q.iid = %d ';
$whereParams[] = $exerciseId;
}
@ -6493,19 +6494,19 @@ class Tracking
ta.answer as answer_id,
ta.tms as time,
te.exe_exo_id as quiz_id,
CONCAT ('c', q.c_id, '_e', q.id) as exercise_id,
CONCAT ('c', q.c_id, '_e', q.iid) as exercise_id,
q.title as quiz_title,
qq.description as description
FROM $ttrack_exercises te
INNER JOIN $ttrack_attempt ta
ON ta.exe_id = te.exe_id
INNER JOIN $tquiz q
ON q.id = te.exe_exo_id
ON q.iid = te.exe_exo_id
INNER JOIN $tquiz_rel_question rq
ON rq.exercice_id = q.id AND rq.c_id = q.c_id
ON rq.exercice_id = q.iid AND rq.c_id = q.c_id
INNER JOIN $tquiz_question qq
ON
qq.id = rq.question_id AND
qq.iid = rq.question_id AND
qq.c_id = rq.c_id AND
qq.position = rq.question_order AND
ta.question_id = rq.question_id
@ -6531,14 +6532,14 @@ class Tracking
}
}
// Now fill questions data. Query all questions and answers for this test to avoid
$sqlQuestions = "SELECT tq.c_id, tq.id as question_id, tq.question, tqa.id_auto,
tqa.answer, tqa.correct, tq.position, tqa.id_auto as answer_id
$sqlQuestions = "SELECT tq.c_id, tq.iid as question_id, tq.question, tqa.iid,
tqa.answer, tqa.correct, tq.position, tqa.iid as answer_id
FROM $tquiz_question tq, $tquiz_answer tqa
WHERE
tqa.question_id = tq.id AND
tqa.question_id = tq.iid AND
tqa.c_id = tq.c_id AND
tq.c_id = $courseIdx AND
tq.id IN (".implode(',', $questionIds).")";
tq.iid IN (".implode(',', $questionIds).")";
$resQuestions = Database::query($sqlQuestions);
$answer = [];

@ -423,7 +423,7 @@ class learnpath
public function add_item(
$parent,
$previous,
$type = 'dir',
$type,
$id,
$title,
$description,
@ -431,6 +431,7 @@ class learnpath
$max_time_allowed = 0,
$userId = 0
) {
$type = empty($type) ? 'dir' : $type;
$course_id = $this->course_info['real_id'];
if (empty($course_id)) {
// Sometimes Oogie doesn't catch the course info but sets $this->cc
@ -448,11 +449,12 @@ class learnpath
if (empty($max_time_allowed)) {
$max_time_allowed = 0;
}
$lpId = $this->get_id();
$sql = "SELECT COUNT(iid) AS num
FROM $tbl_lp_item
WHERE
c_id = $course_id AND
lp_id = ".$this->get_id()." AND
lp_id = $lpId AND
parent_item_id = $parent ";
$res_count = Database::query($sql);
@ -468,7 +470,7 @@ class learnpath
FROM $tbl_lp_item
WHERE
c_id = $course_id AND
lp_id = ".$this->get_id()." AND
lp_id = $lpId AND
parent_item_id = $parent AND
previous_item_id = 0 OR
previous_item_id = $parent ";
@ -483,7 +485,7 @@ class learnpath
FROM $tbl_lp_item
WHERE
c_id = $course_id AND
lp_id = ".$this->get_id()." AND
lp_id = $lpId AND
iid = $previous";
$result = Database::query($sql);
$row = Database::fetch_array($result);
@ -496,18 +498,17 @@ class learnpath
}
$id = (int) $id;
$typeCleaned = Database::escape_string($type);
$max_score = 100;
if ('quiz' === $type && $id) {
$sql = 'SELECT SUM(ponderation)
FROM '.Database::get_course_table(TABLE_QUIZ_QUESTION).' as quiz_question
FROM '.Database::get_course_table(TABLE_QUIZ_QUESTION).' as q
INNER JOIN '.Database::get_course_table(TABLE_QUIZ_TEST_QUESTION).' as quiz_rel_question
ON
quiz_question.id = quiz_rel_question.question_id AND
quiz_question.c_id = quiz_rel_question.c_id
q.iid = quiz_rel_question.question_id AND
q.c_id = quiz_rel_question.c_id
WHERE
quiz_rel_question.exercice_id = '.$id." AND
quiz_question.c_id = $course_id AND
q.c_id = $course_id AND
quiz_rel_question.c_id = $course_id ";
$rsQuiz = Database::query($sql);
$max_score = Database::result($rsQuiz, 0, 0);
@ -517,12 +518,13 @@ class learnpath
$exercise->read($id);
$exercise->disable();
$exercise->save();
$title = $exercise->get_formated_title();
}
$params = [
'c_id' => $course_id,
'lp_id' => $this->get_id(),
'item_type' => $typeCleaned,
'lp_id' => $lpId,
'item_type' => $type,
'ref' => '',
'title' => $title,
'description' => $description,
@ -564,7 +566,7 @@ class learnpath
SET display_order = display_order + 1
WHERE
c_id = $course_id AND
lp_id = ".$this->get_id()." AND
lp_id = $lpId AND
iid <> $new_item_id AND
parent_item_id = $parent AND
display_order > $display_order";
@ -578,7 +580,7 @@ class learnpath
$sql = "UPDATE $tbl_lp_item
SET previous_item_id = ".$this->getLastInFirstLevel()."
WHERE c_id = $course_id AND lp_id = {$this->lp_id} AND item_type = '".TOOL_LP_FINAL_ITEM."'";
WHERE c_id = $course_id AND lp_id = $lpId AND item_type = '".TOOL_LP_FINAL_ITEM."'";
Database::query($sql);
// Upload audio.
@ -8056,7 +8058,8 @@ class learnpath
$return .= '<ul class="lp_resource">';
$return .= '<li class="lp_resource_element">';
$return .= Display::return_icon('new_exercice.png');
$return .= '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise_admin.php?'.api_get_cidreq().'&lp_id='.$this->lp_id.'">'.
$return .= '<a
href="'.api_get_path(WEB_CODE_PATH).'exercise/exercise_admin.php?'.api_get_cidreq().'&lp_id='.$this->lp_id.'">'.
get_lang('New test').'</a>';
$return .= '</li>';
@ -8078,19 +8081,12 @@ class learnpath
$title = strip_tags(api_html_entity_decode($row_quiz['title']));
$visibility = $exercise->isVisible($courseEntity, $sessionEntity);
/*$visibility = api_get_item_visibility(
['real_id' => $course_id],
TOOL_QUIZ,
$row_quiz['iid'],
$session_id
);*/
$link = Display::url(
$previewIcon,
$exerciseUrl.'&exerciseId='.$exerciseId,
['target' => '_blank']
);
$return .= '<li class="lp_resource_element" data_id="'.$exerciseId.'" data_type="quiz" title="'.$title.'" >';
$return .= '<li class="lp_resource_element" title="'.$title.'">';
$return .= Display::url($moveIcon, '#', ['class' => 'moved']);
$return .= $quizIcon;
$sessionStar = api_get_session_image(
@ -8099,9 +8095,12 @@ class learnpath
);
$return .= Display::url(
Security::remove_XSS(cut($title, 80)).$link.$sessionStar,
api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_QUIZ.'&file='.$exerciseId.'&lp_id='.$this->lp_id,
api_get_self().'?'.
api_get_cidreq().'&action=add_item&type='.TOOL_QUIZ.'&file='.$exerciseId.'&lp_id='.$this->lp_id,
[
'class' => false === $visibility ? 'moved text-muted' : 'moved',
'class' => false === $visibility ? 'moved text-muted ' : 'moved link_with_id',
'data_type' => 'quiz',
'data_id' => $exerciseId
]
);
$return .= '</li>';
@ -8189,11 +8188,13 @@ class learnpath
<ul class="lp_resource">
<li class="lp_resource_element">
'.Display::return_icon('linksnew.gif').'
<a href="'.api_get_path(WEB_CODE_PATH).'link/link.php?'.$courseIdReq.'&action=addlink&lp_id='.$this->lp_id.'" title="'.get_lang('Add a link').'">'.
<a
href="'.api_get_path(WEB_CODE_PATH).'link/link.php?'.$courseIdReq.'&action=addlink&lp_id='.$this->lp_id.'"
title="'.get_lang('Add a link').'">'.
get_lang('Add a link').'
</a>
</li>';
$linkIcon = Display::return_icon('links.png', '', [], ICON_SIZE_TINY);
foreach ($categorizedLinks as $categoryId => $links) {
$linkNodes = null;
/** @var CLink $link */
@ -8209,17 +8210,24 @@ class learnpath
if ($link->isVisible($course, $session)) {
//$sessionStar = api_get_session_image($linkSessionId, $userInfo['status']);
$sessionStar = '';
$url = $selfUrl.'?'.$courseIdReq.'&action=add_item&type='.TOOL_LINK.'&file='.$key.'&lp_id='.$this->lp_id;
$link = Display::url(
Security::remove_XSS($title).$sessionStar.$linkUrl,
$url,
[
'class' => 'moved link_with_id',
'data_id' => $key,
'data_type' => TOOL_LINK,
'title' => $title,
]
);
$linkNodes .=
'<li class="lp_resource_element" data_id="'.$key.'" data_type="'.TOOL_LINK.'" title="'.$title.'" >
<a class="moved" href="#">'.
'<li class="lp_resource_element">
<a class="moved" href="#">'.
$moveEverywhereIcon.
'</a>
'.Display::return_icon('links.png', '', [], ICON_SIZE_TINY).'
<a class="moved" href="'.$selfUrl.'?'.$courseIdReq.'&action=add_item&type='.
TOOL_LINK.'&file='.$key.'&lp_id='.$this->lp_id.'">'.
Security::remove_XSS($title).$sessionStar.$linkUrl.
'</a>
</li>';
'.$linkIcon.$link.'
</li>';
}
}
$linksHtmlCode .=
@ -8255,6 +8263,7 @@ class learnpath
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
$works = getWorkListTeacher(0, 100, null, null, null);
if (!empty($works)) {
$icon = Display::return_icon('works.png', '', [], ICON_SIZE_TINY);
foreach ($works as $work) {
$link = Display::url(
Display::return_icon('preview_view.png', get_lang('Preview')),
@ -8262,7 +8271,7 @@ class learnpath
['target' => '_blank']
);
$return .= '<li class="lp_resource_element" data_id="'.$work['iid'].'" data_type="'.TOOL_STUDENTPUBLICATION.'" title="'.Security::remove_XSS(cut(strip_tags($work['title']), 80)).'">';
$return .= '<li class="lp_resource_element">';
$return .= '<a class="moved" href="#">';
$return .= Display::return_icon(
'move_everywhere.png',
@ -8272,10 +8281,17 @@ class learnpath
);
$return .= '</a> ';
$return .= Display::return_icon('works.png', '', [], ICON_SIZE_TINY);
$return .= ' <a class="moved" href="'.api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_STUDENTPUBLICATION.'&file='.$work['iid'].'&lp_id='.$this->lp_id.'">'.
Security::remove_XSS(cut(strip_tags($work['title']), 80)).' '.$link.'
</a>';
$return .= $icon;
$return .= Display::url(
Security::remove_XSS(cut(strip_tags($work['title']), 80)).' '.$link,
api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_STUDENTPUBLICATION.'&file='.$work['iid'].'&lp_id='.$this->lp_id,
[
'class' => 'moved link_with_id',
'data_id' => $work['iid'],
'data_type' => TOOL_STUDENTPUBLICATION,
'title' => Security::remove_XSS(cut(strip_tags($work['title']), 80)),
]
);
$return .= '</li>';
}
@ -8354,7 +8370,7 @@ class learnpath
}
}
</script>';
$moveIcon = Display::return_icon('move_everywhere.png', get_lang('Move'), [], ICON_SIZE_TINY);
foreach ($a_forums as $forum) {
$forumId = $forum->getIid();
$title = Security::remove_XSS($forum->getForumTitle());
@ -8364,17 +8380,31 @@ class learnpath
['target' => '_blank']
);
$return .= '<li class="lp_resource_element" data_id="'.$forumId.'" data_type="'.TOOL_FORUM.'" title="'.$title.'" >';
$return .= '<li class="lp_resource_element">';
$return .= '<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), [], ICON_SIZE_TINY);
$return .= $moveIcon;
$return .= ' </a>';
$return .= Display::return_icon('forum.png', '', [], ICON_SIZE_TINY);
$moveLink = Display::url(
$title.' '.$link,
api_get_self().'?'.
api_get_cidreq().'&action=add_item&type='.TOOL_FORUM.'&forum_id='.$forumId.'&lp_id='.$this->lp_id,
[
'class' => 'moved link_with_id',
'data_id' => $forumId,
'data_type' => TOOL_FORUM,
'title' => $title,
'style' => 'vertical-align:middle',
]
);
$return .= '<a onclick="javascript:toggle_forum('.$forumId.');" style="cursor:hand; vertical-align:middle">
<img src="'.Display::returnIconPath('add.png').'" id="forum_'.$forumId.'_opener" align="absbottom" />
<img
src="'.Display::returnIconPath('add.png').'"
id="forum_'.$forumId.'_opener" align="absbottom"
/>
</a>
<a class="moved" href="'.api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_FORUM.'&forum_id='.$forumId.'&lp_id='.$this->lp_id.'" style="vertical-align:middle">'.
$title.' '.$link.'</a>';
'.$moveLink;
$return .= '</li>';
$return .= '<div style="display:none" id="forum_'.$forumId.'_content">';
@ -8384,16 +8414,23 @@ class learnpath
$threadId = $thread->getIid();
$link = Display::url(
Display::return_icon('preview_view.png', get_lang('Preview')),
api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId,
api_get_path(WEB_CODE_PATH).
'forum/viewthread.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId,
['target' => '_blank']
);
$return .= '<li class="lp_resource_element" data_id="'.$thread->getIid().'" data_type="'.TOOL_THREAD.'" title="'.$thread->getThreadTitle().'" >';
$return .= '<li class="lp_resource_element">';
$return .= '&nbsp;<a class="moved" href="#">';
$return .= Display::return_icon('move_everywhere.png', get_lang('Move'), [], ICON_SIZE_TINY);
$return .= $moveIcon;
$return .= ' </a>';
$return .= Display::return_icon('forumthread.png', get_lang('Thread'), [], ICON_SIZE_TINY);
$return .= '<a class="moved" href="'.api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_THREAD.'&thread_id='.$threadId.'&lp_id='.$this->lp_id.'">'.
$return .= '<a
class="moved link_with_id"
data_id="'.$thread->getIid().'"
data_type="'.TOOL_THREAD.'"
title="'.$thread->getThreadTitle().'"
href="'.api_get_self().'?'.api_get_cidreq().'&action=add_item&type='.TOOL_THREAD.'&thread_id='.$threadId.'&lp_id='.$this->lp_id.'"
>'.
Security::remove_XSS($thread->getThreadTitle()).' '.$link.'</a>';
$return .= '</li>';
}
@ -10615,7 +10652,7 @@ EOD;
if (empty($id)) {
return '';
}
$sql = "SELECT * FROM $tbl_topics WHERE c_id = $course_id AND thread_id=$id";
$sql = "SELECT * FROM $tbl_topics WHERE c_id = $course_id AND iid=$id";
$result = Database::query($sql);
$myrow = Database::fetch_array($result);

@ -236,9 +236,7 @@ $htmlHeadXtra[] = '
var id = item.attr("data_id");
var type = item.attr("data_type");
var title = item.attr("title");
processReceive = true;
if (ui.item.parent()[0]) {
var parent_id = $(ui.item.parent()[0]).attr("id");
var previous_id = $(ui.item.prev()).attr("id");
@ -253,6 +251,7 @@ $htmlHeadXtra[] = '
"type": type,
"title" : title
};
console.log(params);
$.ajax({
type: "GET",
@ -631,7 +630,7 @@ switch ($action) {
Display::addFlash(Display::return_message(get_lang('FileDeleted')));
$url = api_get_self().
'?action=add_audio&lp_id='.intval($_SESSION['oLP']->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq();
'?action=add_audio&lp_id='.intval($oLP->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq();
header('Location: '.$url);
exit;
}
@ -719,7 +718,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']);
$oLP->set_autolaunch($_GET['lp_id'], $_GET['status']);
require 'lp_list.php';
exit;
}
@ -733,7 +732,7 @@ switch ($action) {
require 'lp_list.php';
} else {
Session::write('refresh', 1);
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($oLP->lp_id).'&'.api_get_cidreq();
header('Location: '.$url);
exit;
}
@ -775,7 +774,7 @@ switch ($action) {
$extraFieldValues->saveFieldValues($_POST);
Display::addFlash(Display::return_message(get_lang('Updated')));
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($oLP->lp_id).'&'.api_get_cidreq();
header('Location: '.$url);
exit;
}
@ -794,12 +793,12 @@ switch ($action) {
} else {
if (isset($_POST['submit_button'])) {
// Updating the lp.modified_on
$_SESSION['oLP']->set_modified_on();
$oLP->set_modified_on();
Session::write('refresh', 1);
$min = isset($_POST['min_'.$_POST['prerequisites']]) ? $_POST['min_'.$_POST['prerequisites']] : '';
$max = isset($_POST['max_'.$_POST['prerequisites']]) ? $_POST['max_'.$_POST['prerequisites']] : '';
$editPrerequisite = $_SESSION['oLP']->edit_item_prereq(
$editPrerequisite = $oLP->edit_item_prereq(
$_GET['id'],
$_POST['prerequisites'],
$min,
@ -807,7 +806,7 @@ switch ($action) {
);
Display::addFlash(Display::return_message(get_lang('Update successful')));
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($oLP->lp_id).'&'.api_get_cidreq();
header('Location: '.$url);
exit;
} else {
@ -826,15 +825,15 @@ switch ($action) {
Session::write('refresh', 1);
if (isset($_POST['submit_button'])) {
//Updating the lp.modified_on
$_SESSION['oLP']->set_modified_on();
$_SESSION['oLP']->edit_item(
$oLP->set_modified_on();
$oLP->edit_item(
$_GET['id'],
$_POST['parent'],
$_POST['previous'],
$post_title,
$_POST['description']
);
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($oLP->lp_id).'&'.api_get_cidreq();
header('Location: '.$url);
exit;
}
@ -844,7 +843,7 @@ switch ($action) {
// Avoids weird behaviours see CT#967.
$check = Security::check_token('get');
if ($check) {
$_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']);
$oLP->move_item($_GET['id'], $_GET['direction']);
}
Security::clear_token();
require 'lp_admin_view.php';
@ -885,7 +884,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->copy();
$oLP->copy();
}
require 'lp_list.php';
break;
@ -900,7 +899,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->scormExport();
$oLP->scormExport();
exit();
}
break;
@ -912,7 +911,7 @@ switch ($action) {
// Teachers can export to PDF
if (!$is_allowed_to_edit) {
if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->getEntity(), api_get_user_id(), $courseInfo)) {
if (!learnpath::is_lp_visible_for_student($oLP->getEntity(), api_get_user_id(), $courseInfo)) {
api_not_allowed();
}
}
@ -920,7 +919,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']);
$result = $oLP->scorm_export_to_pdf($_GET['lp_id']);
if (!$result) {
require 'lp_list.php';
}
@ -933,7 +932,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$result = $_SESSION['oLP']->exportToCourseBuildFormat($_GET['lp_id']);
$result = $oLP->exportToCourseBuildFormat($_GET['lp_id']);
if (!$result) {
require 'lp_list.php';
}
@ -950,7 +949,7 @@ switch ($action) {
require 'lp_list.php';
} else {
Session::write('refresh', 1);
$_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove');
$oLP->delete(null, $_GET['lp_id'], 'remove');
Skill::deleteSkillsFromItem($_GET['lp_id'], ITEM_TYPE_LEARNPATH);
Display::addFlash(Display::return_message(get_lang('Deleted')));
Session::erase('oLP');
@ -1071,7 +1070,7 @@ switch ($action) {
require 'lp_list.php';
} else {
if (!empty($_REQUEST['id'])) {
$_SESSION['oLP']->delete_item($_REQUEST['id']);
$oLP->delete_item($_REQUEST['id']);
}
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_REQUEST['lp_id']).'&'.api_get_cidreq();
header('Location: '.$url);
@ -1082,7 +1081,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->restart();
$oLP->restart();
require 'lp_view.php';
}
break;
@ -1090,7 +1089,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->last();
$oLP->last();
require 'lp_view.php';
}
break;
@ -1098,7 +1097,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->first();
$oLP->first();
require 'lp_view.php';
}
break;
@ -1106,7 +1105,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->next();
$oLP->next();
require 'lp_view.php';
}
break;
@ -1114,7 +1113,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->previous();
$oLP->previous();
require 'lp_view.php';
}
break;
@ -1122,9 +1121,9 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->save_last();
$_SESSION['oLP']->set_current_item($_GET['item_id']);
$_SESSION['oLP']->start_current_item();
$oLP->save_last();
$oLP->set_current_item($_GET['item_id']);
$oLP->start_current_item();
require 'lp_content.php';
}
break;
@ -1133,7 +1132,7 @@ switch ($action) {
require 'lp_list.php';
} else {
if (!empty($_REQUEST['item_id'])) {
$_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
$oLP->set_current_item($_REQUEST['item_id']);
}
require 'lp_view.php';
}
@ -1142,7 +1141,7 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->save_item();
$oLP->save_item();
require 'lp_save.php';
}
break;
@ -1150,8 +1149,8 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->save_current();
$_SESSION['oLP']->save_last();
$oLP->save_current();
$oLP->save_last();
Display::display_reduced_header();
$output = require 'lp_stats.php';
@ -1162,7 +1161,7 @@ switch ($action) {
case 'list':
if ($lp_found) {
Session::write('refresh', 1);
$_SESSION['oLP']->save_last();
$oLP->save_last();
}
require 'lp_list.php';
break;
@ -1170,13 +1169,13 @@ switch ($action) {
// Switch between fullscreen and embedded mode.
$mode = $_REQUEST['mode'];
if ('fullscreen' === $mode) {
$_SESSION['oLP']->mode = 'fullscreen';
$oLP->mode = 'fullscreen';
} elseif ('embedded' === $mode) {
$_SESSION['oLP']->mode = 'embedded';
$oLP->mode = 'embedded';
} elseif ('embedframe' === $mode) {
$_SESSION['oLP']->mode = 'embedframe';
$oLP->mode = 'embedframe';
} elseif ('impress' === $mode) {
$_SESSION['oLP']->mode = 'impress';
$oLP->mode = 'impress';
}
require 'lp_view.php';
break;
@ -1184,7 +1183,7 @@ switch ($action) {
if ($lp_found) {
if (Security::check_token('get')) {
Session::write('refresh', 1);
$_SESSION['oLP']->update_default_view_mode();
$oLP->update_default_view_mode();
}
}
@ -1195,7 +1194,7 @@ switch ($action) {
case 'switch_force_commit':
if ($lp_found) {
Session::write('refresh', 1);
$_SESSION['oLP']->update_default_scorm_commit();
$oLP->update_default_scorm_commit();
Display::addFlash(Display::return_message(get_lang('Updated')));
}
header('Location: '.$listUrl);
@ -1205,7 +1204,7 @@ switch ($action) {
case 'switch_attempt_mode':
if ($lp_found) {
Session::write('refresh', 1);
$_SESSION['oLP']->switch_attempt_mode();
$oLP->switch_attempt_mode();
Display::addFlash(Display::return_message(get_lang('Updated')));
}
header('Location: '.$listUrl);
@ -1215,7 +1214,7 @@ switch ($action) {
case 'switch_scorm_debug':
if ($lp_found) {
Session::write('refresh', 1);
$_SESSION['oLP']->update_scorm_debug();
$oLP->update_scorm_debug();
Display::addFlash(Display::return_message(get_lang('Updated')));
}
header('Location: '.$listUrl);
@ -1226,8 +1225,8 @@ switch ($action) {
if (!$lp_found) {
require 'lp_list.php';
} else {
$_SESSION['oLP']->save_current();
$_SESSION['oLP']->save_last();
$oLP->save_current();
$oLP->save_last();
$url = $courseInfo['course_public_url'].'?sid='.api_get_session_id();
$redirectTo = isset($_GET['redirectTo']) ? $_GET['redirectTo'] : '';
switch ($redirectTo) {
@ -1256,21 +1255,21 @@ switch ($action) {
require 'lp_list.php';
} else {
if (!empty($_REQUEST['item_id'])) {
$_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
$oLP->set_current_item($_REQUEST['item_id']);
}
require 'lp_impress.php';
}
break;
case 'set_previous_step_as_prerequisite':
$_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&".api_get_cidreq();
$oLP->set_previous_step_as_prerequisite_for_all_items();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($oLP->lp_id)."&".api_get_cidreq();
Display::addFlash(Display::return_message(get_lang('ItemUpdate successful')));
header('Location: '.$url);
exit;
break;
case 'clear_prerequisites':
$_SESSION['oLP']->clear_prerequisites();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&".api_get_cidreq();
$oLP->clear_prerequisites();
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($oLP->lp_id)."&".api_get_cidreq();
Display::addFlash(Display::return_message(get_lang('ItemUpdate successful')));
header('Location: '.$url);
exit;
@ -1286,7 +1285,7 @@ switch ($action) {
}
Session::write('refresh', 1);
$_SESSION['oLP']->set_seriousgame_mode();
$oLP->set_seriousgame_mode();
require 'lp_list.php';
break;
case 'create_forum':
@ -1381,7 +1380,7 @@ switch ($action) {
header('Location:'.api_get_self().'?'.http_build_query([
'action' => 'add_item',
'type' => 'step',
'lp_id' => $_SESSION['oLP']->lp_id,
'lp_id' => $oLP->lp_id,
]));
exit;
break;
@ -1398,7 +1397,7 @@ switch ($action) {
break;
}
$_SESSION['oLP']->getFinalItemForm();
$oLP->getFinalItemForm();
$redirectTo = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
'action' => 'add_item',
'type' => 'step',
@ -1410,7 +1409,7 @@ switch ($action) {
break;
}
if (!empty($_SESSION['oLP'])) {
if (!empty($oLP)) {
Session::write('lpobject', serialize($oLP));
if ($debug > 0) {
error_log('lpobject is serialized in session', 0);

Loading…
Cancel
Save