Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
506cdabb
Commit
506cdabb
authored
Mar 30, 2020
by
Robert Lyon
Committed by
Gerrit Code Review
Mar 30, 2020
Browse files
Merge "Behat Bug:1829080 SmartEvidence framework matrix editor functionality"
parents
154c2894
ccbd4232
Changes
6
Hide whitespace changes
Inline
Side-by-side
htdocs/module/framework/frameworks.php
View file @
506cdabb
...
...
@@ -174,6 +174,7 @@ $frameworks = Framework::get_frameworks('any');
if
(
$frameworks
)
{
foreach
(
$frameworks
as
$framework
)
{
$fk
=
new
Framework
(
$framework
->
id
);
$framework
->
institution_name
=
(
$fk
->
get
(
'institution_name'
))
?
$fk
->
get
(
'institution_name'
)
:
''
;
if
(
$fk
->
get
(
'active'
))
{
$framework
->
active
=
array
(
'title'
=>
'Enabled'
,
...
...
htdocs/module/framework/js/editor.js
View file @
506cdabb
...
...
@@ -33,7 +33,7 @@
* check copy save
* add inst default in the php. It's already there?
*/
var
editor
;
jQuery
(
function
(
$
)
{
// Use bootstrap
JSONEditor
.
defaults
.
options
.
theme
=
'
bootstrap4
'
;
...
...
@@ -57,7 +57,6 @@ jQuery(function($) {
// Enable select2
JSONEditor
.
plugins
.
select2
.
enable
=
true
;
var
editor
;
var
parent_array
=
[
''
];
var
standard_array
=
[];
var
standard_names
=
[];
...
...
htdocs/module/framework/lib.php
View file @
506cdabb
...
...
@@ -177,6 +177,7 @@ class Framework {
private
$id
;
private
$name
;
private
$institution
;
private
$institution_name
;
private
$description
;
private
$selfassess
;
private
$active
=
1
;
// active by default
...
...
@@ -215,6 +216,9 @@ class Framework {
if
(
$field
==
'selfassess'
||
$field
==
'active'
)
{
$value
=
(
int
)
$value
;
}
if
(
$field
===
'institution'
&&
$value
!=
'all'
)
{
$this
->
institution_name
=
get_field
(
'institution'
,
'displayname'
,
'name'
,
$value
);
}
$this
->
{
$field
}
=
$value
;
}
}
...
...
htdocs/testing/frameworks/behat/classes/BehatGeneral.php
View file @
506cdabb
...
...
@@ -1524,6 +1524,107 @@ EOF;
}
}
private
function
i_get_se_field
(
$dv
)
{
// If we are not running javascript we can't test the form
if
(
!
$this
->
running_javascript
())
{
throw
new
DriverException
(
'SE editor tests are disabled in scenarios without Javascript support'
);
}
// If we are looking at a "standards" or "standardelements" node we need to check that it is active
$checkactive
=
(
preg_match
(
'/\.standards\./'
,
$dv
)
||
preg_match
(
'/\.standardelements\./'
,
$dv
))
?
"//div[contains(concat(' ', normalize-space(@class), ' '), ' active ')]"
:
''
;
$exception
=
new
Exception
(
'The field at schemapath "'
.
$dv
.
'" '
.
(
$checkactive
?
'in active tab '
:
''
)
.
'not found'
);
$xpath
=
$checkactive
.
"//div[contains(concat(' ', normalize-space(@data-schemapath), ' '), ' "
.
$dv
.
" ')]"
.
"//input"
.
" | "
.
$checkactive
.
"//div[contains(concat(' ', normalize-space(@data-schemapath), ' '), ' "
.
$dv
.
" ')]"
.
"//select"
.
" | "
.
$checkactive
.
"//div[contains(concat(' ', normalize-space(@data-schemapath), ' '), ' "
.
$dv
.
" ')]"
.
"//textarea"
;
// First check the node exists
$node
=
$this
->
find
(
'xpath'
,
$xpath
,
$exception
);
return
$xpath
;
}
/**
* Investigate a Smart Evidence editor field via data schemepath attribute
*
* @Given the SE field :datavalue should contain :value
*/
public
function
i_check_the_se_field
(
$dv
,
$value
)
{
$xpath
=
$this
->
i_get_se_field
(
$dv
);
$textliteral
=
$this
->
escaper
->
escapeLiteral
(
$value
);
// Then check that is set to value
// We need to do this via JS
$js
=
"(function() {
var fxpath = document.evaluate (
\"
"
.
$xpath
.
"
\"
,
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
var hasValue = jQuery(fxpath.snapshotItem(0)).val();
var hasMatch = hasValue.indexOf("
.
$textliteral
.
");
// If not found in value check if a select field and if option text matches
if (hasMatch == -1 && jQuery(fxpath.snapshotItem(0)).prop('tagName') == 'SELECT') {
hasValue = jQuery(fxpath.snapshotItem(0)).find(':selected').text();
hasMatch = hasValue.indexOf("
.
$textliteral
.
");
}
return (hasMatch != -1);
})()"
;
$result
=
$this
->
getSession
()
->
evaluateScript
(
"
$js
"
);
if
(
$result
==
false
)
{
throw
new
Exception
(
'The field at schemapath "'
.
$dv
.
'" does not contain text "'
.
$textliteral
.
'"'
);
}
}
/**
* Investigate a Smart Evidence editor field via data schemepath attribute
*
* @Given the SE field :datavalue should not contain :value
*/
public
function
i_check_the_se_field2
(
$dv
,
$value
)
{
$xpath
=
$this
->
i_get_se_field
(
$dv
);
$textliteral
=
$this
->
escaper
->
escapeLiteral
(
$value
);
// Then check that is set to value
// We need to do this via JS
$js
=
"(function() {
var fxpath = document.evaluate (
\"
"
.
$xpath
.
"
\"
,
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
var hasValue = jQuery(fxpath.snapshotItem(0)).val();
var hasMatch = hasValue.indexOf("
.
$textliteral
.
");
// If not found in value check if a select field and if option text matches
if (hasMatch == -1 && jQuery(fxpath.snapshotItem(0)).prop('tagName') == 'SELECT') {
hasValue = jQuery(fxpath.snapshotItem(0)).find(':selected').text();
hasMatch = hasValue.indexOf("
.
$textliteral
.
");
}
return (hasMatch == -1);
})()"
;
$result
=
$this
->
getSession
()
->
evaluateScript
(
"
$js
"
);
if
(
$result
==
false
)
{
throw
new
Exception
(
'The field at schemapath "'
.
$dv
.
'" does contain text "'
.
$textliteral
.
'"'
);
}
}
/**
* Update a Smart Evidence editor field via data schemepath attribute
*
* @Given I set the SE field :datavalue to :value
*/
public
function
i_set_the_se_field
(
$dv
,
$value
)
{
$xpath
=
$this
->
i_get_se_field
(
$dv
);
$textliteral
=
$this
->
escaper
->
escapeLiteral
(
$value
);
// Then check that is set to value
// We need to do this via JS
$js
=
'editor.getEditor("'
.
$dv
.
'").setValue('
.
$textliteral
.
');'
;
$result
=
$this
->
getSession
()
->
evaluateScript
(
"
$js
"
);
}
/**
* Display the editting page
*
...
...
htdocs/theme/raw/plugintype/module/framework/templates/frameworks.tpl
View file @
506cdabb
...
...
@@ -7,6 +7,7 @@
<thead>
<tr>
<th>
{
str
tag
=
"name"
}
</th>
<th>
{
str
tag
=
"institution"
section
=
"mahara"
}
</th>
<th>
{
str
tag
=
"usedincollections"
section
=
"module.framework"
}
</th>
<th>
{
str
tag
=
"selfassess"
section
=
"module.framework"
}
</th>
<th>
{
str
tag
=
"active"
}
</th>
...
...
@@ -17,6 +18,7 @@
{
foreach
from
=
$frameworks
key
=
k
item
=
item
}
<tr>
<td>
{
$item
->
name
}
</td>
<td>
{
$item
->
institution_name
}
</td>
<td>
{
$item
->
collections
}
</td>
<td>
{
$item
->
selfassess
}
</td>
<td>
...
...
test/behat/features/site_features/smart_evidence_editor.feature
0 → 100644
View file @
506cdabb
@javascript
@core
@smartevidence
Feature
:
SmartEvidence editor
As a site administrator
I want to edit or copy a framework matrix
Background
:
Given the following "institutions" exist
:
|
name
|
displayname
|
registerallowed
|
registerconfirm
|
|
instone
|
Institution
One
|
ON
|
OFF
|
Scenario
:
Site administrator uploads and edits a SmartEvidence framework matrix
Given
I log in as
"admin"
with password
"Kupuh1pa!"
And
I choose
"SmartEvidence"
in
"Extensions"
from administration menu
And
I follow
"Import"
in the
"Arrow-bar nav"
property
And
I attach the file
"example.matrix"
to
"Matrix file"
And
I press
"Upload matrix"
# Check that we have new framework
Then
I should see
"Title of your framework"
When
I click on
"Edit"
in
"Title of your framework"
row
And
I disable the switch
"Active framework"
And
I press
"Save"
Then
I should see
"Settings saved"
When
I follow
"Editor"
in the
"Arrow-bar nav"
property
Then
I should see
"The current form contents are valid and ok to submit"
When
I select
"Title of your framework"
from
"Edit saved framework"
And
I wait
"1"
seconds
And
the SE field
"root.name"
should contain
"Title of your framework"
And
I set the SE field
"root.name"
to
"Fish"
And
the SE field
"root.name"
should not contain
"Title of your framework"
And
the SE field
"root.institution"
should contain
"all"
And
I set the SE field
"root.institution"
to
"Institution One"
And
the SE field
"root.evidencestatuses.begun"
should contain
"Ready for assessment"
And
the SE field
"root.standards.0.name"
should contain
"Title of the standard"
And
I set the SE field
"root.standards.0.name"
to
"Standard One"
And
the SE field
"root.description"
should contain
"You can write more in the description"
And
I set the SE field
"root.description"
to
"This is my new description"
And
the SE field
"root.selfassess"
should contain
"No"
And
I press
"add_standard"
And
the SE field
"root.standards.4.shortname"
should contain
"Short name"
And
I set the SE field
"root.standards.4.shortname"
to
"New standard"
# Not working yet
# And I click on "Delete last standard" delete button
And
I follow
"1.2"
And
the SE field
"root.standardelements.1.name"
should contain
"1.2 - Sub level of the standard"
And
I scroll to the top
And
I press
"Save"
And
I follow
"Management"
in the
"Arrow-bar nav"
property
Then
I should see
"Fish"
Then
I should see
"Institution One"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment