Skip to content

Commit

Permalink
MDL-53376 tool_lp: Redirect after creating a new framework
Browse files Browse the repository at this point in the history
  • Loading branch information
taboubi authored and Frederic Massart committed Apr 18, 2016
1 parent c579c7b commit 49792e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
29 changes: 13 additions & 16 deletions admin/tool/lp/editcompetencyframework.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
6 changes: 2 additions & 4 deletions admin/tool/lp/tests/behat/framework_crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"

Expand Down

0 comments on commit 49792e9

Please sign in to comment.