diff --git a/admin/tool/lp/editcompetencyframework.php b/admin/tool/lp/editcompetencyframework.php index fea950e75d2b1..d76d1dd707d5d 100644 --- a/admin/tool/lp/editcompetencyframework.php +++ b/admin/tool/lp/editcompetencyframework.php @@ -65,28 +65,25 @@ if ($form->is_cancelled()) { redirect($frameworksurl); -} - -echo $output->header(); -echo $output->heading($pagetitle); - -$data = $form->get_data(); -if ($data) { - require_sesskey(); +} else if ($data = $form->get_data()) { if (empty($data->id)) { // Create new framework. $data->contextid = $context->id; - \tool_lp\api::create_framework($data); - echo $output->notification(get_string('competencyframeworkcreated', 'tool_lp'), 'notifysuccess'); - echo $output->continue_button($frameworksurl); + $framework = \tool_lp\api::create_framework($data); + $frameworkmanageurl = new moodle_url('/admin/tool/lp/competencies.php', array( + 'pagecontextid' => $pagecontextid, + 'competencyframeworkid' => $framework->get_id() + )); + $messagesuccess = get_string('competencyframeworkcreated', 'tool_lp'); + redirect($frameworkmanageurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS); } else { \tool_lp\api::update_framework($data); - echo $output->notification(get_string('competencyframeworkupdated', 'tool_lp'), 'notifysuccess'); - echo $output->continue_button($frameworksurl); + $messagesuccess = get_string('competencyframeworkupdated', 'tool_lp'); + redirect($frameworksurl, $messagesuccess, 0, \core\output\notification::NOTIFY_SUCCESS); } -} else { - $form->display(); } - +echo $output->header(); +echo $output->heading($pagetitle); +$form->display(); echo $output->footer(); diff --git a/admin/tool/lp/tests/behat/framework_crud.feature b/admin/tool/lp/tests/behat/framework_crud.feature index 17d993ca72af7..8c313a5773c37 100644 --- a/admin/tool/lp/tests/behat/framework_crud.feature +++ b/admin/tool/lp/tests/behat/framework_crud.feature @@ -23,12 +23,11 @@ Feature: Manage competency frameworks And I should see "You must configure the scale by selecting default and proficient values" And "Configure scales" "button" should be visible And I press "Configure scales" - And I click on "#tool_lp_scale_default_1" "css_element" - And I click on "#tool_lp_scale_proficient_1" "css_element" + And I click on "//input[@data-field='tool_lp_scale_default_1']" "xpath_element" + And I click on "//input[@data-field='tool_lp_scale_proficient_1']" "xpath_element" And I click on "//input[@value='Close']" "xpath_element" When I press "Save changes" Then I should see "Competency framework created" - And I click on "Continue" "button" And I should see "Science Year-1" Scenario: Read a framework @@ -51,7 +50,6 @@ Feature: Manage competency frameworks And I set the field "Name" to "Science Year-3 Edited" When I press "Save changes" Then I should see "Competency framework updated" - And I click on "Continue" "button" And I should see "Science Year-3 Edited" And I should see "sc-y-3"