Index: lams_central/web/authoring/template/comms.jsp =================================================================== diff -u -r453de6ad12d35426d9f71ec3e39a41546df6159c -r022dc32b5cf44038ae98d71a6d8e0c8e19b8bcef --- lams_central/web/authoring/template/comms.jsp (.../comms.jsp) (revision 453de6ad12d35426d9f71ec3e39a41546df6159c) +++ lams_central/web/authoring/template/comms.jsp (.../comms.jsp) (revision 022dc32b5cf44038ae98d71a6d8e0c8e19b8bcef) @@ -136,7 +136,7 @@ // Triggers the import window. The saving is done in a method saveQTI(formHTML, formName, callerID) which should be defined in the main template jsp file. // CallerID can be set to define which tab has triggered the QTI import, as TBL has import on both the RAT Questions and App Ex tabs. function importQTI(callerID, limit, type){ - var url = 'questions/questionFile.jsp?collectionChoice=true&callerID='+callerID; + var url = 'questions/questionFile.jsp?collectionChoice=false&callerID='+callerID; if ( limit ) { url = url + '&limitType='+limit; } @@ -451,5 +451,4 @@ $('.editable-open').editableContainer('hide', 'cancel'); return 'Can not be empty!'; } - } - + } \ No newline at end of file Index: lams_central/web/authoring/template/tbl/tbl.jsp =================================================================== diff -u -rf4f2bdc7f40b65cec61ba1d534ca0c5f97b4c84a -r022dc32b5cf44038ae98d71a6d8e0c8e19b8bcef --- lams_central/web/authoring/template/tbl/tbl.jsp (.../tbl.jsp) (revision f4f2bdc7f40b65cec61ba1d534ca0c5f97b4c84a) +++ lams_central/web/authoring/template/tbl/tbl.jsp (.../tbl.jsp) (revision 022dc32b5cf44038ae98d71a6d8e0c8e19b8bcef) @@ -1,5 +1,8 @@ <%@ include file="/common/taglibs.jsp"%> +<%@ page import="org.lamsfoundation.lams.util.Configuration" %> +<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %> +<%=Configuration.get(ConfigurationKeys.QB_COLLECTIONS_CREATE_ALLOW)%> @@ -75,6 +78,49 @@ jQuery.validator.addMethod("validateNoSpecialCharacters", validateNoSpecialCharacters, ': '); initializeWizard(validator); + + $('#qb-collection-uid').change(function(){ + let collectionSelect = $(this), + newValue = collectionSelect.val(), + previouslySelectedOption = $('option[selected]', collectionSelect); + if (newValue == -1) { + // create a new collection on the fly + let newCollectionName = prompt(''), + newCollectionUid = -1; + if (newCollectionName) { + newCollectionName = newCollectionName.trim(); + $.ajax({ + 'url' : '${lams}qb/collection/addCollection.do', + 'async' : false, + 'type' : 'post', + 'dataType' : 'text', + 'data' : { + 'name' : newCollectionName, + '' : '' + }, + success : function (response){ + if (!isNaN(response)) { + newCollectionUid = +response; + } + }, + error : function (xhr) { + alert(xhr.responseText); + } + }); + } + + if (newCollectionUid == -1 || newCollectionUid == 0) { + // revert to previous selection + previouslySelectedOption.prop('selected', true); + } else { + $('').attr('value', newCollectionUid).attr('selected', 'selected') + .prop('selected', true).text(newCollectionName).insertBefore($('option[value="-1"]', collectionSelect)); + } + } else { + previouslySelectedOption.removeAttr('selected'); + $('option[value="' + newValue + '"]', collectionSelect).attr('selected', 'selected'); + } + }); }); function createApplicationExercise(type, callingAppexNumber) { @@ -264,11 +310,15 @@ - " + " class="form-control form-control-inline"> + + + +