Merge pull request #5210 from christianbeeznest/displayorder-tools4

Learnpath: Fix lp creation and editing in sessions
pull/5213/head
christianbeeznest 9 months ago committed by GitHub
commit e474f67354
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      public/main/inc/lib/document.lib.php
  2. 13
      public/main/lp/learnpath.class.php
  3. 3
      public/main/lp/learnpathList.class.php
  4. 5
      public/main/lp/lp_add_item.php
  5. 2
      src/CourseBundle/Entity/CQuiz.php

@ -513,8 +513,6 @@ class DocumentManager
if ('/chat_files' == $path) {
$condition .= " AND (docs.session_id = '$sessionId') ";
}
// share_folder filter
$condition .= " AND docs.path != '/shared_folder' ";
}
return $condition;
@ -567,10 +565,6 @@ class DocumentManager
}
$show_users_condition = '';
if ('false' === api_get_setting('show_users_folders')) {
$show_users_condition = " AND docs.path NOT LIKE '%shared_folder%'";
}
if ($can_see_invisible) {
$sessionId = $sessionId ?: api_get_session_id();
$condition_session = " AND (l.session_id = '$sessionId' OR (l.session_id = '0' OR l.session_id IS NULL) )";
@ -638,7 +632,7 @@ class DocumentManager
}
//get visible folders
$sql = "SELECT DISTINCT docs.id, docs.path
$sql = "SELECT DISTINCT docs.id
FROM resource_node AS n
INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.resource_node_id = n.id)
@ -685,7 +679,6 @@ class DocumentManager
INNER JOIN resource_link l
ON (l.resource_node_id = n.id)
WHERE
docs.path LIKE '".Database::escape_string($row['path'].'/%')."' AND
docs.filetype = 'folder' AND
$groupCondition AND
l.visibility NOT IN ('".ResourceLink::VISIBILITY_DELETED."')

@ -2143,8 +2143,17 @@ class learnpath
*/
public function get_lp_session_id()
{
if (!empty($this->lp_session_id)) {
return (int) $this->lp_session_id;
$lp = Container::getLpRepository()->find($this->lp_id);
if ($lp) {
/* @var ResourceNode $resourceNode */
$resourceNode = $lp->getResourceNode();
if ($resourceNode) {
$link = $resourceNode->getResourceLinks()->first();
if ($link && $link->getSession()) {
return (int) $link->getSession()->getId();
}
}
}
return 0;

@ -137,9 +137,10 @@ class LearnpathList
}
}
$link = $lp->getFirstResourceLink();
$this->list[$lp->getIid()] = [
'lp_type' => $lp->getLpType(),
'lp_session' => 0,
'lp_session' => $link && $link->getSession() ? (int) $link->getSession()->getId() : 0,
'lp_name' => stripslashes($lp->getTitle()),
'lp_desc' => stripslashes($lp->getDescription()),
'lp_path' => $lp->getPath(),

@ -20,11 +20,12 @@ $lpId = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0;
$submit = $_POST['submit_button'] ?? null;
$type = $_GET['type'] ?? null;
$action = $_GET['action'] ?? null;
$is_allowed_to_edit = api_is_allowed_to_edit(null, false);
$checkStudentView = 'true' === $isStudentView;
$is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, $checkStudentView);
$listUrl = api_get_path(WEB_CODE_PATH).
'lp/lp_controller.php?action=view&lp_id='.$lpId.'&'.api_get_cidreq().'&isStudentView=true';
if (!$is_allowed_to_edit) {
if ((!$is_allowed_to_edit) || $checkStudentView) {
header("Location: $listUrl");
exit;
}

@ -454,7 +454,7 @@ class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowC
/**
* Set text to display to user when they fail to the test (when pass percentage has been set).
*/
public function setTextWhenFinishedFailure(string $textWhenFinished): self
public function setTextWhenFinishedFailure(?string $textWhenFinished): self
{
$this->textWhenFinishedFailure = $textWhenFinished;

Loading…
Cancel
Save