Commit 833b23db authored by Rebecca Blundell's avatar Rebecca Blundell Committed by Kristina Hoeppner

Bug 1635503: Small fixes to SmartEvidence editor

behatnotneeded

Change-Id: Ide3c89454be8a8a7e70be5c6aae27b7181277124
parent e5cef702
......@@ -17,25 +17,19 @@
* 2 @TODO - Turn edit overall form option into an export json button and have it create a file.matrix
* for sharing. (Note that in the custom code patch 5accb2c9d1259005249248d5cb4f2fa8acba97b5,
* there is code that re-names the button, which is there for this function.)
*
* * - do we want this:
* Clicking the "Save" button keeps you on the form and you have to click "Cancel" to return to the overview -> Implement the Moodle "Save" -
* "Save and return to overview" - "Cancel"?
* - Maybe: Add third-level nav to management screen of a framework? But then what to call the nav item? Overview wouldn't work,
* would be better to then call it "Management".
*/
/*
* Functionality still to be implemented by 19.04:
* @TODO - review:
* - descriptions for the parent and element ids
* - make sub-sub elements work
* - fix 3rd level nav - should have 4 tabs
* - eid increments correctly - make update_eid function work
* - check textarea auto-expand functioning correctly (not regressed)
* - check name textarea not producing errors
* - Standard "Stay or Leave" functionality needs to be implemented - should this include the back button?
* - do we want this:
* Clicking the "Save" button keeps you on the form and you have to click "Cancel" to return to the overview -> Implement the Moodle "Save" -
* "Save and return to overview" - "Cancel"?
* - Maybe: Add third-level nav to management screen of a framework? But then what to call the nav item? Overview wouldn't work,
* would be better to then call it "Management".
- Check error message code makes sense.
*
* check copy save
* add inst default in the php.
*/
jQuery(function($) {
......@@ -59,7 +53,7 @@ jQuery(function($) {
JSONEditor.plugins.select2.enable = true;
var editor;
var parent_array = [];
var parent_array = [''];
//counts to increment standard and standardelement ids
var std_index = 0;
......@@ -465,7 +459,7 @@ jQuery(function($) {
var errors = editor.validate();
// Not valid
if (errors.length) {
$('#messages').empty().append($('<div>', {'class':'alert alert-danger', 'text':get_string('invalidjson', 'module.framework')}));
$('#messages').empty().append($('<div>', {'class':'alert alert-danger', 'text':get_string('invalidjsonineditor', 'module.framework')}));
}
// Valid
else {
......@@ -673,7 +667,7 @@ jQuery(function($) {
//get a list of existing standard elements
function update_parent_array() {
parent_array = [];
parent_array = [''];
$("[data-schemaid=\"standardelement\"]").each(function() {
//number of std elements
var num = parseInt($(this).data("schemapath").replace(/root\.standardelements\./, ''));
......@@ -714,15 +708,36 @@ jQuery(function($) {
//update the element id for the passed in standard element
function update_eid(element) {
if (element.value && element.value != '1.1') {
if (element.value) {
var index = element.name.replace(/.*\[(\d*)\].*/, '$1');
var eid_field = editor.getEditor("root.standardelements." + index + ".elementid");
if (eid_field) {
eid_field.setValue(element.value + "." + eid);//wrong variable.
eid_field.setValue(element.value + "." + get_eid(element.value));
}
}
}
/**
* Update the element id after the parent id has been changed
* @param parent_id The parent id selected from the dropdown
*/
function get_eid(parent_id) {
var pel_array = [];
$("[data-schemaid=\"standardelement\"] .form-control[name$=\"parentelementid\]\"").each(function () {
if (this.value) {
pel_array.push(this.value);
}
});
count_subel = 0;
$(pel_array).each(function(k, val) {
if (val == parent_id) {
count_subel++
}
});
return count_subel;
}
/*
* Manually add the handlers for the standard elements delete buttons
* needs to add it also after deleting one standard element because
......@@ -764,6 +779,7 @@ jQuery(function($) {
set_editor_dirty();
});
}
});//end of jQuery wrapper
// form change checker functions
......
......@@ -107,9 +107,8 @@ $string['standardelements'] = 'Standard elements';
$string['standardelement'] = 'Standard element';
$string['standardelementdesc'] = 'This description appears when you hover over this standard element on the SmartEvidence page. It is also displayed when you select this standard in the "Annotations" block. You can use simple HTML.';
$string['standardelementdefault'] = 'Description of the standard element';
$string['standardiddesc1'] = 'This needs to match the ID of the standard category under which you are creating this standard element.';
$string['elementid'] = 'Element ID';
$string['elementiddesc'] = 'This is the ID for this standard element. This can be a number or a short word. A sequence of numbers is easiest to indicate hierarchy.';
$string['elementiddesc'] = 'This is the ID for this standard element. A sequence of numbers is used to indicate hierarchy.';
$string['invalidjsonineditor'] = 'The current form has invalid json. Please scroll down the page to see the specific error.';
$string['validjson'] = 'The current form contents are valid and ok to submit';
$string['moveright'] = 'Move right';
......@@ -120,7 +119,7 @@ $string['selfassesseddescription'] = 'Decide whether a staff member can perform
$string['standardsdescription'] = 'Create the categories in which your framework is divided. Later on, you can assign individual standard elements and sub-elements to a standard category. You must have at least one category.';
$string['standardelementsdescription'] = 'Create the individual standard elements, i.e. descriptors, to which content can be aligned. The standard elements can be put into a hierarchical order if needed by using the "Parent ID" option.';
$string['parentelementid'] = 'Parent element ID';
$string['parentelementdesc'] = 'This is the ID of the standard element that serves as parent to this one here, i.e. the one that sits one level higher in the hierarchy.';
$string['parentelementdesc'] = 'The dropdown shows the current standard elements. If you want to make a sub-element of one of these, select it as the parent.';
$string['jsondatanotsubmitted'] = 'Your form data was not submitted to the database, please make sure you save the information you have entered in a separate file, refresh the form and try again or upload the json directly using the "Upload" tab';
$string['editor'] = 'Editor';
$string['Management'] = 'Management';
......
......@@ -821,6 +821,10 @@ div.form-group .form-control-label {
border-bottom-right-radius: 0.25rem;
}
.errormsg {
color: $state-danger-text;
}
// table cells that need to be fixed 70px width
.width-70 {
width: 70px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment