Index: lams_central/web/css/vsaAllocate.css =================================================================== diff -u --- lams_central/web/css/vsaAllocate.css (revision 0) +++ lams_central/web/css/vsaAllocate.css (revision d99e586940f6f2ca7a230ed6770dc51803d71e23) @@ -0,0 +1,46 @@ +.sortable-on { + border: 3px solid #286090; + border-radius: 10px; + height: 200px; + padding: 10px; + overflow-y: auto; +} + +.sortable-on .portrait-generic-sm { + margin-right: 5px; +} + +.sortable-on .portrait-anonymous { + color: #ddd; +} + +.tbl-correct-list { + border: 3px solid #3c763d; + background-color: #3c763d10; +} + +.tbl-incorrect-list { + border: 3px solid #a94442; + background-color: #a9444210; +} + +.answer-queue { + border: 2px solid #ddd; +} + +.answer-alternatives { + text-align: left; + margin-top: 5px; +} + +.answer-alternatives button { + margin: 2px; +} + +.filtered { + background-color: lightgrey; +} + +.list-group-item { + cursor: pointer; +} \ No newline at end of file Index: lams_central/web/includes/javascript/vsaAllocate.js =================================================================== diff -u --- lams_central/web/includes/javascript/vsaAllocate.js (revision 0) +++ lams_central/web/includes/javascript/vsaAllocate.js (revision d99e586940f6f2ca7a230ed6770dc51803d71e23) @@ -0,0 +1,83 @@ +$(document).ready(function(){ + //init options sorting feature + $('.sortable-on').each(function() { + let questionUid = $(this).data('question-uid'); + updateAnswerQueueSize(questionUid); + + new Sortable(this, { + group: 'question' + questionUid, + animation: 150, + filter: '.filtered', // 'filtered' class is not draggable + onEnd: function (evt) { + let data = { + questionUid: questionUid, + targetOptionUid: $(evt.to).data("option-uid"), + previousOptionUid: $(evt.from).data("option-uid"), + answer: $('.answer-text', evt.item).text() + }; + data[csrfTokenName] = csrfTokenValue; + + $.ajax({ + url: WEB_APP_URL + 'monitoring/allocateUserAnswer.do', + data: data, + method: 'post', + dataType: "json", + success: function (data) { + updateAnswerQueueSize(questionUid); + + if (data.isAnswerDuplicated) { + alert(VS_ANSWER_ALLOCATED_ALERT); + $(evt.item).appendTo("#answer-group" + data.optionUid); + $(evt.item).addClass("filtered"); + } + } + }); + } + }); + }); + + $('.answer-alternatives button').click(function(){ + var button = $(this), + answer = button.text(), + container = button.closest('.answer-alternatives'), + questionUid = container.data('question-uid'), + optionUid = container.data('option-uid'), + isCorrect = container.data('option-correct'), + data = { + questionUid: questionUid, + targetOptionUid: -1, + previousOptionUid: optionUid, + answer: answer + }; + + if (isCorrect && !confirm(VS_ANSWER_DEALLOCATE_CONFIRM)) { + return; + } + + data[csrfTokenName] = csrfTokenValue; + + $.ajax({ + url: WEB_APP_URL + 'monitoring/allocateUserAnswer.do', + data: data, + method: 'post', + dataType: "json", + success: function (data) { + if (data.answerFoundInResults) { + $('
') + .append($('')) + .append($('').text(answer)) + .appendTo('#answer-queue' + questionUid); + + updateAnswerQueueSize(questionUid); + } + + button.remove(); + } + }); + }); +}); + +function updateAnswerQueueSize(questionUid) { + var answerQueueLength = $('#answer-queue' + questionUid + ' .list-group-item').length; + $('#answer-queue-size' + questionUid).text(answerQueueLength ? ' (' + answerQueueLength + ')' : ''); +} \ No newline at end of file Index: lams_central/web/qb/vsa/vsaAllocate.jsp =================================================================== diff -u --- lams_central/web/qb/vsa/vsaAllocate.jsp (revision 0) +++ lams_central/web/qb/vsa/vsaAllocate.jsp (revision d99e586940f6f2ca7a230ed6770dc51803d71e23) @@ -0,0 +1,64 @@ + +<%@ include file="/common/taglibs.jsp"%> +