Minor - Fix LP category delete test

pull/3173/head
Julio Montoya 7 years ago
parent d8fdd1f410
commit 34640d210f
  1. 11
      main/lp/lp_controller.php
  2. 20
      main/lp/lp_list.php
  3. 9
      tests/behat/features/toolLp.feature

@ -18,11 +18,10 @@ use ChamiloSession as Session;
$use_anonymous = true;
$debug = 0;
if ($debug) {
error_log('Entering lp_controller.php. Checking if LP exist in current session');
}
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
$current_course_tool = TOOL_LEARNPATH;
$_course = api_get_course_info();
@ -185,7 +184,6 @@ $htmlHeadXtra[] = '
</script>';
$session_id = api_get_session_id();
api_protect_course_script(true);
$lpfound = false;
$myrefresh = 0;
@ -1199,7 +1197,8 @@ switch ($action) {
exit;
}
break;
case 'add_sub_item': // Add an item inside a dir/chapter.
case 'add_sub_item':
// Add an item inside a dir/chapter.
// @todo check if this is @deprecated
if (!$is_allowed_to_edit) {
api_not_allowed(true);

@ -16,11 +16,14 @@ use ChamiloSession as Session;
$this_section = SECTION_COURSES;
//@todo who turns on $lp_controller_touched?
if (empty($lp_controller_touched) || $lp_controller_touched != 1) {
header('location: lp_controller.php?action=list');
header('Location: lp_controller.php?action=list&'.api_get_cidreq());
exit;
}
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
$courseDir = api_get_course_path().'/scorm';
$baseWordDir = $courseDir;
@ -28,8 +31,7 @@ $baseWordDir = $courseDir;
* Display initialisation and security checks.
*/
// Extra javascript functions for in html head:
$htmlHeadXtra[]
= "<script>
$htmlHeadXtra[] = "<script>
function confirmation(name) {
if (confirm(\" ".trim(get_lang('AreYouSureToDeleteJS'))." \"+name+\"?\")) {
return true;
@ -40,7 +42,6 @@ function confirmation(name) {
</script>";
$nameTools = get_lang('LearningPaths');
Event::event_access_tool(TOOL_LEARNPATH);
api_protect_course_script();
/**
* Display.
@ -51,6 +52,8 @@ if (api_get_setting('search_enabled') === 'true') {
search_widget_prepare($htmlHeadXtra);
}
$sessionId = api_get_session_id();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$courseInfo = api_get_course_info();
$subscriptionSettings = learnpath::getSubscriptionSettings();
@ -67,11 +70,8 @@ $introduction = Display::return_introduction_section(
]
);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$courseInfo = api_get_course_info();
$message = '';
$actions = '';
if ($is_allowed_to_edit) {
$actionLeft = '';
$actionLeft .= Display::url(
@ -806,11 +806,9 @@ foreach ($categories as $item) {
'delete.png',
get_lang('LearnpathDeleteLearnpath')
),
'lp_controller.php?'.api_get_cidreq()
."&action=delete&lp_id=$id",
'lp_controller.php?'.api_get_cidreq()."&action=delete&lp_id=$id",
[
'onclick' => "javascript: return confirmation('"
.addslashes($name)."');",
'onclick' => "javascript: return confirmation('".addslashes($name)."');",
]
);
} else {

@ -63,16 +63,19 @@ Feature: LP tool
# And I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list&isStudentView=true"
# Then I should not see an icon with title "Export to PDF"
Scenario: LP exists and LP category exists
Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list&isStudentView=false"
Then I should see "LP 1"
And I should see "LP category 1"
Scenario: Delete a LP
Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list"
And wait for the page to be loaded
Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list&isStudentView=false"
And I follow "Delete"
And I confirm the popup
Then I should not see "LP 1"
Scenario: Delete a LP category
Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list&isStudentView=false"
And wait for the page to be loaded
Then I should see "LP category 1"
And I follow "Delete"
Then I should see "Deleted"
Loading…
Cancel
Save