Index: lams_central/web/includes/javascript/qb-question.js =================================================================== diff -u -re11f383d97ca45f4fc0d1c8a283b306439dff946 -r70a326811aab339193f6031102dfde367b21cc5c --- lams_central/web/includes/javascript/qb-question.js (.../qb-question.js) (revision e11f383d97ca45f4fc0d1c8a283b306439dff946) +++ lams_central/web/includes/javascript/qb-question.js (.../qb-question.js) (revision 70a326811aab339193f6031102dfde367b21cc5c) @@ -10,14 +10,14 @@ $("#question-settings-link").on('click', function() { $('.question-tab:visible').fadeToggle("fast", function() { $( ".settings-tab" ).show(); - }); + }); $('.settings-tab:visible').fadeToggle("fast", function() { $( ".question-tab" ).show(); - }); + }); //toggle Settings button class $(this).toggleClass("btn-default btn-primary"); - }); + }); // trigger is-new-question-version check when changing certain data in a question $('#assessmentQuestionForm').on('input', 'input, select, textarea', function(){ @@ -28,21 +28,66 @@ $('body').on('input paste', '[contenteditable]', function(){ checkQuestionNewVersion(false); }); + + $('#collection-uid-select').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(ADD_COLLECTION_LABEL), + newCollectionUid = -1; + if (newCollectionName) { + newCollectionName = newCollectionName.trim(); + let data = { + 'name' : newCollectionName + }; + data[csrfTokenName] = csrfTokenValue; + + $.ajax({ + 'url' : LAMS_URL + 'qb/collection/addCollection.do', + 'async' : false, + 'type' : 'post', + 'dataType' : 'text', + 'data' : data, + 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 { + $(' + + + + Index: lams_central/web/qb/authoring/addQuestionHeader.jsp =================================================================== diff -u -rdab57abcc025fa02ac2cc688421251f51c8942cf -r70a326811aab339193f6031102dfde367b21cc5c --- lams_central/web/qb/authoring/addQuestionHeader.jsp (.../addQuestionHeader.jsp) (revision dab57abcc025fa02ac2cc688421251f51c8942cf) +++ lams_central/web/qb/authoring/addQuestionHeader.jsp (.../addQuestionHeader.jsp) (revision 70a326811aab339193f6031102dfde367b21cc5c) @@ -1,8 +1,11 @@ <%@ 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)%> - + @@ -14,25 +17,29 @@ Index: lams_central/web/qb/authoring/addessay.jsp =================================================================== diff -u -r62136ef7274ade99c326404298d51c77085cffcb -r70a326811aab339193f6031102dfde367b21cc5c --- lams_central/web/qb/authoring/addessay.jsp (.../addessay.jsp) (revision 62136ef7274ade99c326404298d51c77085cffcb) +++ lams_central/web/qb/authoring/addessay.jsp (.../addessay.jsp) (revision 70a326811aab339193f6031102dfde367b21cc5c) @@ -1,153 +1,161 @@ <%@ 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)%> - - - - - + + + + + - - - - - - - - - - + + + + + + + + + - - - + + + +
- +
- - + + @@ -161,120 +169,120 @@ - +
-
- +
+ - -
- +
+
+
- +
- +
- +
- +
- + - -
- + +
+
- - -
- -
+ + +
+ +
- +
- - -
- - - Python - JavaScript - Java - Scala - Kotlin - C - Objective C - C++ - C# - -
+ + +
+ + + Python + JavaScript + Java + Scala + Kotlin + C + Objective C + C++ + C# + +
- +
-
- +
- + +
+ + +
- +
- + +
+ + +
- +
- +
- +
- + -
- - + + + <%@ include file="addQuestionFooter.jsp"%> - -
+ + \ No newline at end of file Index: lams_central/web/qb/authoring/addtruefalse.jsp =================================================================== diff -u -rc04504bfdd9685850e15792838241a748f13560e -r70a326811aab339193f6031102dfde367b21cc5c --- lams_central/web/qb/authoring/addtruefalse.jsp (.../addtruefalse.jsp) (revision c04504bfdd9685850e15792838241a748f13560e) +++ lams_central/web/qb/authoring/addtruefalse.jsp (.../addtruefalse.jsp) (revision 70a326811aab339193f6031102dfde367b21cc5c) @@ -1,11 +1,14 @@ <%@ 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)%> - + - + @@ -20,63 +23,67 @@ const SAVE_QUESTION_URL = "/lams/qb/edit/saveOrUpdateQuestion.do"; const VALIDATION_ERROR_LABEL = ""; const VALIDATION_ERRORS_LABEL = "{errors_counter}"; - - var isNewQuestion = ${isNewQuestion}; + const ADD_COLLECTION_LABEL = ''; + const LAMS_URL = ''; + + var isNewQuestion = ${isNewQuestion}, + csrfTokenName = '', + csrfTokenValue = ''; - - - + + +
- +
+ method="post" autocomplete="off"> @@ -109,94 +116,94 @@ - +
-
- +
+ - -
- +
+
+
- +
- +
- +
- +
- + - +
- +
-
- +
+ - -
- +
+
+
- - -
- -
+ + +
+ +
- +
- - -
- -
+ + +
+ +
- +
- +
- +
- - + +
- +
- - + +
- +
-
+
- + <%@ include file="addQuestionFooter.jsp"%> - -
+ + \ No newline at end of file Index: lams_central/web/questions/questionChoice.jsp =================================================================== diff -u -r3bc02e2e2858938ef1fce59766cb6e682de8107d -r70a326811aab339193f6031102dfde367b21cc5c --- lams_central/web/questions/questionChoice.jsp (.../questionChoice.jsp) (revision 3bc02e2e2858938ef1fce59766cb6e682de8107d) +++ lams_central/web/questions/questionChoice.jsp (.../questionChoice.jsp) (revision 70a326811aab339193f6031102dfde367b21cc5c) @@ -184,9 +184,6 @@ previouslySelectedOption.removeAttr('selected'); $('option[value="' + newValue + '"]', collectionSelect).attr('selected', 'selected'); } - - - }); }); @@ -218,7 +215,6 @@ -