Index: lams_central/src/java/org/lamsfoundation/lams/web/ConfidenceLevelServlet.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/web/ConfidenceLevelServlet.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/web/ConfidenceLevelServlet.java (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -0,0 +1,80 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.web; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.confidencelevel.service.IConfidenceLevelService; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * Stores rating. + * + * @author Andrey Balan + */ +public class ConfidenceLevelServlet extends HttpServlet { + + private static Logger log = Logger.getLogger(ConfidenceLevelServlet.class); + private static IConfidenceLevelService confidenceLevelService; + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + getConfidenceLevelService(); + + Long questionUid = WebUtil.readLongParam(request, "questionUid"); + Long toolSessionId = WebUtil.readLongParam(request, "toolSessionId"); + + UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + Integer userId = user.getUserID(); + int confidenceLevel = WebUtil.readIntParam(request, "confidenceLevel"); + + confidenceLevelService.saveConfidenceLevel(toolSessionId, userId, questionUid, confidenceLevel); + } + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } + + private IConfidenceLevelService getConfidenceLevelService() { + if (confidenceLevelService == null) { + WebApplicationContext ctx = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()); + confidenceLevelService = (IConfidenceLevelService) ctx.getBean("confidenceLevelService"); + } + return confidenceLevelService; + } +} Index: lams_central/web/css/bootstrap-slider.css =================================================================== diff -u --- lams_central/web/css/bootstrap-slider.css (revision 0) +++ lams_central/web/css/bootstrap-slider.css (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -0,0 +1,41 @@ +/*! ======================================================= + VERSION 9.9.0 +========================================================= */ +/*! ========================================================= + * bootstrap-slider.js + * + * Maintainers: + * Kyle Kemp + * - Twitter: @seiyria + * - Github: seiyria + * Rohit Kalkur + * - Twitter: @Rovolutionary + * - Github: rovolution + * + * ========================================================= + * + * bootstrap-slider is released under the MIT License + * Copyright (c) 2017 Kyle Kemp, Rohit Kalkur, and contributors + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ========================================================= */.slider{display:inline-block;vertical-align:middle;position:relative}.slider.slider-horizontal{width:210px;height:20px}.slider.slider-horizontal .slider-track{height:10px;width:100%;margin-top:-5px;top:50%;left:0}.slider.slider-horizontal .slider-selection,.slider.slider-horizontal .slider-track-low,.slider.slider-horizontal .slider-track-high{height:100%;top:0;bottom:0}.slider.slider-horizontal .slider-tick,.slider.slider-horizontal .slider-handle{margin-left:-10px}.slider.slider-horizontal .slider-tick.triangle,.slider.slider-horizontal .slider-handle.triangle{position:relative;top:50%;transform:translateY(-50%);border-width:0 10px 10px 10px;width:0;height:0;border-bottom-color:#2e6da4;margin-top:0}.slider.slider-horizontal .slider-tick-container{white-space:nowrap;position:absolute;top:0;left:0;width:100%}.slider.slider-horizontal .slider-tick-label-container{white-space:nowrap;margin-top:20px}.slider.slider-horizontal .slider-tick-label-container .slider-tick-label{padding-top:4px;display:inline-block;text-align:center}.slider.slider-horizontal.slider-rtl .slider-track{left:initial;right:0}.slider.slider-horizontal.slider-rtl .slider-tick,.slider.slider-horizontal.slider-rtl .slider-handle{margin-left:initial;margin-right:-10px}.slider.slider-horizontal.slider-rtl .slider-tick-container{left:initial;right:0}.slider.slider-vertical{height:210px;width:20px}.slider.slider-vertical .slider-track{width:10px;height:100%;left:25%;top:0}.slider.slider-vertical .slider-selection{width:100%;left:0;top:0;bottom:0}.slider.slider-vertical .slider-track-low,.slider.slider-vertical .slider-track-high{width:100%;left:0;right:0}.slider.slider-vertical .slider-tick,.slider.slider-vertical .slider-handle{margin-top:-10px}.slider.slider-vertical .slider-tick.triangle,.slider.slider-vertical .slider-handle.triangle{border-width:10px 0 10px 10px;width:1px;height:1px;border-left-color:#2e6da4;border-right-color:#2e6da4;margin-left:0;margin-right:0}.slider.slider-vertical .slider-tick-label-container{white-space:nowrap}.slider.slider-vertical .slider-tick-label-container .slider-tick-label{padding-left:4px}.slider.slider-vertical.slider-rtl .slider-track{left:initial;right:25%}.slider.slider-vertical.slider-rtl .slider-selection{left:initial;right:0}.slider.slider-vertical.slider-rtl .slider-tick.triangle,.slider.slider-vertical.slider-rtl .slider-handle.triangle{border-width:10px 10px 10px 0}.slider.slider-vertical.slider-rtl .slider-tick-label-container .slider-tick-label{padding-left:initial;padding-right:4px}.slider.slider-disabled .slider-handle{background-image:-webkit-linear-gradient(top,#dfdfdf 0,#bebebe 100%);background-image:-o-linear-gradient(top,#dfdfdf 0,#bebebe 100%);background-image:linear-gradient(to bottom,#dfdfdf 0,#bebebe 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdfdfdf',endColorstr='#ffbebebe',GradientType=0)}.slider.slider-disabled .slider-track{background-image:-webkit-linear-gradient(top,#e5e5e5 0,#e9e9e9 100%);background-image:-o-linear-gradient(top,#e5e5e5 0,#e9e9e9 100%);background-image:linear-gradient(to bottom,#e5e5e5 0,#e9e9e9 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe5e5e5',endColorstr='#ffe9e9e9',GradientType=0);cursor:not-allowed}.slider input{display:none}.slider .tooltip.top{margin-top:-36px}.slider .tooltip-inner{white-space:nowrap;max-width:none}.slider .hide{display:none}.slider-track{position:absolute;cursor:pointer;background-image:-webkit-linear-gradient(top,#f5f5f5 0,#f9f9f9 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#f9f9f9 100%);background-image:linear-gradient(to bottom,#f5f5f5 0,#f9f9f9 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5',endColorstr='#fff9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);border-radius:4px}.slider-selection{position:absolute;background-image:-webkit-linear-gradient(top,#f9f9f9 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#f9f9f9 0,#f5f5f5 100%);background-image:linear-gradient(to bottom,#f9f9f9 0,#f5f5f5 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f9f9',endColorstr='#fff5f5f5',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;border-radius:4px}.slider-selection.tick-slider-selection{background-image:-webkit-linear-gradient(top,#8ac1ef 0,#82b3de 100%);background-image:-o-linear-gradient(top,#8ac1ef 0,#82b3de 100%);background-image:linear-gradient(to bottom,#8ac1ef 0,#82b3de 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff8ac1ef',endColorstr='#ff82b3de',GradientType=0)}.slider-track-low,.slider-track-high{position:absolute;background:transparent;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;border-radius:4px}.slider-handle{position:absolute;top:0;width:20px;height:20px;background-color:#337ab7;background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7',endColorstr='#ff2e6da4',GradientType=0);filter:none;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);border:0 solid transparent}.slider-handle.round{border-radius:50%}.slider-handle.triangle{background:transparent none}.slider-handle.custom{background:transparent none}.slider-handle.custom::before{line-height:20px;font-size:20px;content:'\2605';color:#726204}.slider-tick{position:absolute;width:20px;height:20px;background-image:-webkit-linear-gradient(top,#f9f9f9 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#f9f9f9 0,#f5f5f5 100%);background-image:linear-gradient(to bottom,#f9f9f9 0,#f5f5f5 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f9f9',endColorstr='#fff5f5f5',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;filter:none;opacity:.8;border:0 solid transparent}.slider-tick.round{border-radius:50%}.slider-tick.triangle{background:transparent none}.slider-tick.custom{background:transparent none}.slider-tick.custom::before{line-height:20px;font-size:20px;content:'\2605';color:#726204}.slider-tick.in-selection{background-image:-webkit-linear-gradient(top,#8ac1ef 0,#82b3de 100%);background-image:-o-linear-gradient(top,#8ac1ef 0,#82b3de 100%);background-image:linear-gradient(to bottom,#8ac1ef 0,#82b3de 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff8ac1ef',endColorstr='#ff82b3de',GradientType=0);opacity:1} \ No newline at end of file Index: lams_central/web/includes/javascript/bootstrap-slider.js =================================================================== diff -u --- lams_central/web/includes/javascript/bootstrap-slider.js (revision 0) +++ lams_central/web/includes/javascript/bootstrap-slider.js (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -0,0 +1,5 @@ +/*! ======================================================= + VERSION 9.9.0 +========================================================= */ +"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},windowIsDefined="object"===("undefined"==typeof window?"undefined":_typeof(window));!function(a){if("function"==typeof define&&define.amd)define(["jquery"],a);else if("object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports){var b;try{b=require("jquery")}catch(c){b=null}module.exports=a(b)}else window&&(window.Slider=a(window.jQuery))}(function(a){var b="slider",c="bootstrapSlider";windowIsDefined&&!window.console&&(window.console={}),windowIsDefined&&!window.console.log&&(window.console.log=function(){}),windowIsDefined&&!window.console.warn&&(window.console.warn=function(){});var d;return function(a){function b(){}function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l&&l!==k)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}var m=this.map(function(){var d=a.data(this,b);return d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d)),a(this)});return!m||m.length>1?m:m[0]}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;c(a)}(a),function(a){function e(b,c){function d(a,b){var c="data-slider-"+b.replace(/_/g,"-"),d=a.getAttribute(c);try{return JSON.parse(d)}catch(e){return d}}this._state={value:null,enabled:null,offset:null,size:null,percentage:null,inDrag:!1,over:!1},this.ticksCallbackMap={},this.handleCallbackMap={},"string"==typeof b?this.element=document.querySelector(b):b instanceof HTMLElement&&(this.element=b),c=c?c:{};for(var e=Object.keys(this.defaultOptions),f=0;f0)for(var t=0;t0){for(this.ticksContainer=document.createElement("div"),this.ticksContainer.className="slider-tick-container",f=0;f0)for(this.tickLabelContainer=document.createElement("div"),this.tickLabelContainer.className="slider-tick-label-container",f=0;f0&&(this.options.max=Math.max.apply(Math,this.options.ticks),this.options.min=Math.min.apply(Math,this.options.ticks)),Array.isArray(this.options.value)?(this.options.range=!0,this._state.value=this.options.value):this.options.range?this._state.value=[this.options.value,this.options.max]:this._state.value=this.options.value,this.trackLow=k||this.trackLow,this.trackSelection=j||this.trackSelection,this.trackHigh=l||this.trackHigh,"none"===this.options.selection?(this._addClass(this.trackLow,"hide"),this._addClass(this.trackSelection,"hide"),this._addClass(this.trackHigh,"hide")):("after"===this.options.selection||"before"===this.options.selection)&&(this._removeClass(this.trackLow,"hide"),this._removeClass(this.trackSelection,"hide"),this._removeClass(this.trackHigh,"hide")),this.handle1=m||this.handle1,this.handle2=n||this.handle2,p===!0)for(this._removeClass(this.handle1,"round triangle"),this._removeClass(this.handle2,"round triangle hide"),f=0;f0){for(var d,e,f,g=0,h=1;hthis.options.max?this.options.max:k},toPercentage:function(a){if(this.options.max===this.options.min)return 0;if(this.options.ticks_positions.length>0){for(var b,c,d,e=0,f=0;f0?this.options.ticks[f-1]:0,d=f>0?this.options.ticks_positions[f-1]:0,c=this.options.ticks[f],e=this.options.ticks_positions[f];break}if(f>0){var g=(a-b)/(c-b);return d+g*(e-d)}}return 100*(a-this.options.min)/(this.options.max-this.options.min)}},logarithmic:{toValue:function(a){var b=0===this.options.min?0:Math.log(this.options.min),c=Math.log(this.options.max),d=Math.exp(b+(c-b)*a/100);return Math.round(d)===this.options.max?this.options.max:(d=this.options.min+Math.round((d-this.options.min)/this.options.step)*this.options.step,dthis.options.max?this.options.max:d)},toPercentage:function(a){if(this.options.max===this.options.min)return 0;var b=Math.log(this.options.max),c=0===this.options.min?0:Math.log(this.options.min),d=0===a?0:Math.log(a);return 100*(d-c)/(b-c)}}};if(d=function(a,b){return e.call(this,a,b),this},d.prototype={_init:function(){},constructor:d,defaultOptions:{id:"",min:0,max:10,step:1,precision:0,orientation:"horizontal",value:5,range:!1,selection:"before",tooltip:"show",tooltip_split:!1,handle:"round",reversed:!1,rtl:"auto",enabled:!0,formatter:function(a){return Array.isArray(a)?a[0]+" : "+a[1]:a},natural_arrow_keys:!1,ticks:[],ticks_positions:[],ticks_labels:[],ticks_snap_bounds:0,ticks_tooltip:!1,scale:"linear",focus:!1,tooltip_position:null,labelledby:null,rangeHighlights:[]},getElement:function(){return this.sliderElem},getValue:function(){return this.options.range?this._state.value:this._state.value[0]},setValue:function(a,b,c){a||(a=0);var d=this.getValue();this._state.value=this._validateInputValue(a);var e=this._applyPrecision.bind(this);this.options.range?(this._state.value[0]=e(this._state.value[0]),this._state.value[1]=e(this._state.value[1]),this._state.value[0]=Math.max(this.options.min,Math.min(this.options.max,this._state.value[0])),this._state.value[1]=Math.max(this.options.min,Math.min(this.options.max,this._state.value[1]))):(this._state.value=e(this._state.value),this._state.value=[Math.max(this.options.min,Math.min(this.options.max,this._state.value))],this._addClass(this.handle2,"hide"),"after"===this.options.selection?this._state.value[1]=this.options.max:this._state.value[1]=this.options.min),this.options.max>this.options.min?this._state.percentage=[this._toPercentage(this._state.value[0]),this._toPercentage(this._state.value[1]),100*this.options.step/(this.options.max-this.options.min)]:this._state.percentage=[0,0,100],this._layout();var f=this.options.range?this._state.value:this._state.value[0];return this._setDataVal(f),b===!0&&this._trigger("slide",f),d!==f&&c===!0&&this._trigger("change",{oldValue:d,newValue:f}),this},destroy:function(){this._removeSliderEventHandlers(),this.sliderElem.parentNode.removeChild(this.sliderElem),this.element.style.display="",this._cleanUpEventCallbacksMap(),this.element.removeAttribute("data"),a&&(this._unbindJQueryEventHandlers(),this.$element.removeData("slider"))},disable:function(){return this._state.enabled=!1,this.handle1.removeAttribute("tabindex"),this.handle2.removeAttribute("tabindex"),this._addClass(this.sliderElem,"slider-disabled"),this._trigger("slideDisabled"),this},enable:function(){return this._state.enabled=!0,this.handle1.setAttribute("tabindex",0),this.handle2.setAttribute("tabindex",0),this._removeClass(this.sliderElem,"slider-disabled"),this._trigger("slideEnabled"),this},toggle:function(){return this._state.enabled?this.disable():this.enable(),this},isEnabled:function(){return this._state.enabled},on:function(a,b){return this._bindNonQueryEventHandler(a,b),this},off:function(b,c){a?(this.$element.off(b,c),this.$sliderElem.off(b,c)):this._unbindNonQueryEventHandler(b,c)},getAttribute:function(a){return a?this.options[a]:this.options},setAttribute:function(a,b){return this.options[a]=b,this},refresh:function(){return this._removeSliderEventHandlers(),e.call(this,this.element,this.options),a&&a.data(this.element,"slider",this),this},relayout:function(){return this._resize(),this._layout(),this},_removeSliderEventHandlers:function(){if(this.handle1.removeEventListener("keydown",this.handle1Keydown,!1),this.handle2.removeEventListener("keydown",this.handle2Keydown,!1),this.options.ticks_tooltip){for(var a=this.ticksContainer.getElementsByClassName("slider-tick"),b=0;b=0?c:this.attributes["aria-valuenow"].value,e=parseInt(d,10);b.value[0]=e,b.percentage[0]=a.options.ticks_positions[e],a._setToolTipOnMouseOver(b),a._showTooltip()};return b.addEventListener("mouseenter",d,!1),d},addMouseLeave:function(a,b){var c=function(){a._hideTooltip()};return b.addEventListener("mouseleave",c,!1),c}}},_layout:function(){var a;if(a=this.options.reversed?[100-this._state.percentage[0],this.options.range?100-this._state.percentage[1]:this._state.percentage[1]]:[this._state.percentage[0],this._state.percentage[1]],this.handle1.style[this.stylePos]=a[0]+"%",this.handle1.setAttribute("aria-valuenow",this._state.value[0]),isNaN(this.options.formatter(this._state.value[0]))&&this.handle1.setAttribute("aria-valuetext",this.options.formatter(this._state.value[0])),this.handle2.style[this.stylePos]=a[1]+"%",this.handle2.setAttribute("aria-valuenow",this._state.value[1]),isNaN(this.options.formatter(this._state.value[1]))&&this.handle2.setAttribute("aria-valuetext",this.options.formatter(this._state.value[1])),this.rangeHighlightElements.length>0&&Array.isArray(this.options.rangeHighlights)&&this.options.rangeHighlights.length>0)for(var b=0;b0){var g,h="vertical"===this.options.orientation?"height":"width";g="vertical"===this.options.orientation?"marginTop":this.options.rtl?"marginRight":"marginLeft";var i=this._state.size/(this.options.ticks.length-1);if(this.tickLabelContainer){var j=0;if(0===this.options.ticks_positions.length)"vertical"!==this.options.orientation&&(this.tickLabelContainer.style[g]=-i/2+"px"),j=this.tickLabelContainer.offsetHeight;else for(k=0;kj&&(j=this.tickLabelContainer.childNodes[k].offsetHeight);"horizontal"===this.options.orientation&&(this.sliderElem.style.marginBottom=j+"px")}for(var k=0;k=a[0]&&l<=a[1]&&this._addClass(this.ticks[k],"in-selection"):"after"===this.options.selection&&l>=a[0]?this._addClass(this.ticks[k],"in-selection"):"before"===this.options.selection&&l<=a[0]&&this._addClass(this.ticks[k],"in-selection"),this.tickLabels[k]&&(this.tickLabels[k].style[h]=i+"px","vertical"!==this.options.orientation&&void 0!==this.options.ticks_positions[k]?(this.tickLabels[k].style.position="absolute",this.tickLabels[k].style[this.stylePos]=l+"%",this.tickLabels[k].style[g]=-i/2+"px"):"vertical"===this.options.orientation&&(this.options.rtl?this.tickLabels[k].style.marginRight=this.sliderElem.offsetWidth+"px":this.tickLabels[k].style.marginLeft=this.sliderElem.offsetWidth+"px",this.tickLabelContainer.style[g]=this.sliderElem.offsetWidth/2*-1+"px"))}}var m;if(this.options.range){m=this.options.formatter(this._state.value),this._setText(this.tooltipInner,m),this.tooltip.style[this.stylePos]=(a[1]+a[0])/2+"%","vertical"===this.options.orientation?this._css(this.tooltip,"margin-"+this.stylePos,-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-"+this.stylePos,-this.tooltip.offsetWidth/2+"px");var n=this.options.formatter(this._state.value[0]);this._setText(this.tooltipInner_min,n);var o=this.options.formatter(this._state.value[1]);this._setText(this.tooltipInner_max,o),this.tooltip_min.style[this.stylePos]=a[0]+"%","vertical"===this.options.orientation?this._css(this.tooltip_min,"margin-"+this.stylePos,-this.tooltip_min.offsetHeight/2+"px"):this._css(this.tooltip_min,"margin-"+this.stylePos,-this.tooltip_min.offsetWidth/2+"px"),this.tooltip_max.style[this.stylePos]=a[1]+"%","vertical"===this.options.orientation?this._css(this.tooltip_max,"margin-"+this.stylePos,-this.tooltip_max.offsetHeight/2+"px"):this._css(this.tooltip_max,"margin-"+this.stylePos,-this.tooltip_max.offsetWidth/2+"px")}else m=this.options.formatter(this._state.value[0]),this._setText(this.tooltipInner,m),this.tooltip.style[this.stylePos]=a[0]+"%","vertical"===this.options.orientation?this._css(this.tooltip,"margin-"+this.stylePos,-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-"+this.stylePos,-this.tooltip.offsetWidth/2+"px");if("vertical"===this.options.orientation)this.trackLow.style.top="0",this.trackLow.style.height=Math.min(a[0],a[1])+"%",this.trackSelection.style.top=Math.min(a[0],a[1])+"%",this.trackSelection.style.height=Math.abs(a[0]-a[1])+"%",this.trackHigh.style.bottom="0",this.trackHigh.style.height=100-Math.min(a[0],a[1])-Math.abs(a[0]-a[1])+"%";else{"right"===this.stylePos?this.trackLow.style.right="0":this.trackLow.style.left="0",this.trackLow.style.width=Math.min(a[0],a[1])+"%","right"===this.stylePos?this.trackSelection.style.right=Math.min(a[0],a[1])+"%":this.trackSelection.style.left=Math.min(a[0],a[1])+"%",this.trackSelection.style.width=Math.abs(a[0]-a[1])+"%","right"===this.stylePos?this.trackHigh.style.left="0":this.trackHigh.style.right="0",this.trackHigh.style.width=100-Math.min(a[0],a[1])-Math.abs(a[0]-a[1])+"%";var p=this.tooltip_min.getBoundingClientRect(),q=this.tooltip_max.getBoundingClientRect();"bottom"===this.options.tooltip_position?p.right>q.left?(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top="",this.tooltip_max.style.bottom="22px"):(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top=this.tooltip_min.style.top,this.tooltip_max.style.bottom=""):p.right>q.left?(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top="18px"):(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top=this.tooltip_min.style.top)}},_createHighlightRange:function(a,b){return this._isHighlightRange(a,b)?a>b?{start:b,size:a-b}:{start:a,size:b-a}:null},_isHighlightRange:function(a,b){return a>=0&&100>=a&&b>=0&&100>=b?!0:!1},_resize:function(a){this._state.offset=this._offset(this.sliderElem),this._state.size=this.sliderElem[this.sizePos],this._layout()},_removeProperty:function(a,b){a.style.removeProperty?a.style.removeProperty(b):a.style.removeAttribute(b)},_mousedown:function(a){if(!this._state.enabled)return!1;this._state.offset=this._offset(this.sliderElem),this._state.size=this.sliderElem[this.sizePos];var b=this._getPercentage(a);if(this.options.range){var c=Math.abs(this._state.percentage[0]-b),d=Math.abs(this._state.percentage[1]-b);this._state.dragged=d>c?0:1,this._adjustPercentageForRangeSliders(b)}else this._state.dragged=0;this._state.percentage[this._state.dragged]=b,this._layout(),this.touchCapable&&(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)),this.mousemove&&document.removeEventListener("mousemove",this.mousemove,!1),this.mouseup&&document.removeEventListener("mouseup",this.mouseup,!1),this.mousemove=this._mousemove.bind(this),this.mouseup=this._mouseup.bind(this),this.touchCapable&&(document.addEventListener("touchmove",this.mousemove,!1),document.addEventListener("touchend",this.mouseup,!1)),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseup",this.mouseup,!1),this._state.inDrag=!0;var e=this._calculateValue();return this._trigger("slideStart",e),this._setDataVal(e),this.setValue(e,!1,!0),a.returnValue=!1,this.options.focus&&this._triggerFocusOnHandle(this._state.dragged),!0},_touchstart:function(a){if(void 0===a.changedTouches)return void this._mousedown(a);var b=a.changedTouches[0];this.touchX=b.pageX,this.touchY=b.pageY},_triggerFocusOnHandle:function(a){0===a&&this.handle1.focus(),1===a&&this.handle2.focus()},_keydown:function(a,b){if(!this._state.enabled)return!1;var c;switch(b.keyCode){case 37:case 40:c=-1;break;case 39:case 38:c=1}if(c){if(this.options.natural_arrow_keys){var d="vertical"===this.options.orientation&&!this.options.reversed,e="horizontal"===this.options.orientation&&this.options.reversed;(d||e)&&(c=-c)}var f=this._state.value[a]+c*this.options.step,g=f/this.options.max*100;if(this._state.keyCtrl=a,this.options.range){this._adjustPercentageForRangeSliders(g);var h=this._state.keyCtrl?this._state.value[0]:f,i=this._state.keyCtrl?f:this._state.value[1];f=[h,i]}return this._trigger("slideStart",f),this._setDataVal(f),this.setValue(f,!0,!0),this._setDataVal(f),this._trigger("slideStop",f),this._layout(),this._pauseEvent(b),delete this._state.keyCtrl,!1}},_pauseEvent:function(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.cancelBubble=!0,a.returnValue=!1},_mousemove:function(a){if(!this._state.enabled)return!1;var b=this._getPercentage(a);this._adjustPercentageForRangeSliders(b),this._state.percentage[this._state.dragged]=b,this._layout();var c=this._calculateValue(!0);return this.setValue(c,!0,!0),!1},_touchmove:function(a){if(void 0!==a.changedTouches){var b=a.changedTouches[0],c=b.pageX-this.touchX,d=b.pageY-this.touchY;this._state.inDrag||("vertical"===this.options.orientation&&5>=c&&c>=-5&&(d>=15||-15>=d)?this._mousedown(a):5>=d&&d>=-5&&(c>=15||-15>=c)&&this._mousedown(a))}},_adjustPercentageForRangeSliders:function(a){if(this.options.range){var b=this._getNumDigitsAfterDecimalPlace(a);b=b?b-1:0;var c=this._applyToFixedAndParseFloat(a,b);0===this._state.dragged&&this._applyToFixedAndParseFloat(this._state.percentage[1],b)c?(this._state.percentage[1]=this._state.percentage[0],this._state.dragged=0):0===this._state.keyCtrl&&this._state.value[1]/this.options.max*100a&&(this._state.percentage[1]=this._state.percentage[0],this._state.keyCtrl=0,this.handle1.focus())}},_mouseup:function(){if(!this._state.enabled)return!1;this.touchCapable&&(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),this._state.inDrag=!1,this._state.over===!1&&this._hideTooltip();var a=this._calculateValue(!0);return this._layout(),this._setDataVal(a),this._trigger("slideStop",a),!1},_calculateValue:function(a){var b;if(this.options.range?(b=[this.options.min,this.options.max],0!==this._state.percentage[0]&&(b[0]=this._toValue(this._state.percentage[0]),b[0]=this._applyPrecision(b[0])),100!==this._state.percentage[1]&&(b[1]=this._toValue(this._state.percentage[1]),b[1]=this._applyPrecision(b[1]))):(b=this._toValue(this._state.percentage[0]),b=parseFloat(b),b=this._applyPrecision(b)),a){for(var c=[b,1/0],d=0;d + + + + + + + Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20171016.sql =================================================================== diff -u --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20171016.sql (revision 0) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20171016.sql (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -0,0 +1,20 @@ +-- Turn off autocommit, so nothing is committed if there is an error +SET AUTOCOMMIT = 0; +SET FOREIGN_KEY_CHECKS=0; +----------------------Put all sql statements below here------------------------- + +-- LDEV-4451 add 'Enable Confidence levels' advanced setting +ALTER TABLE tl_laasse10_assessment ADD COLUMN enable_confidence_levels TINYINT(1) NOT NULL DEFAULT 0; + +--add questions' hashes in order to be able to search for the similar questions with the same title and question +ALTER TABLE tl_laasse10_assessment_question ADD COLUMN question_hash CHAR(40); +UPDATE tl_laasse10_assessment_question SET question_hash = SHA1(CONCAT(title, question)); + +UPDATE lams_tool SET tool_version='20171016' WHERE tool_signature='laasse10'; + +----------------------Put all sql statements above here------------------------- + +-- If there were no errors, commit and restore autocommit to on +COMMIT; +SET AUTOCOMMIT = 1; +SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dto/QuestionDTO.java =================================================================== diff -u -rc97b41d72e071f6293126bd85f6eba0b756f7836 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dto/QuestionDTO.java (.../QuestionDTO.java) (revision c97b41d72e071f6293126bd85f6eba0b756f7836) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dto/QuestionDTO.java (.../QuestionDTO.java) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -84,6 +84,8 @@ private Set matchingPairOptions; private List questionResults; + + private int confidenceLevel; public QuestionDTO(AssessmentQuestion question) { this.uid = question.getUid(); @@ -341,6 +343,13 @@ public void setQuestionResults(List questionResults2) { this.questionResults = questionResults2; } + + public int getConfidenceLevel() { + return confidenceLevel; + } + public void setConfidenceLevel(int confidenceLevel) { + this.confidenceLevel = confidenceLevel; + } public boolean isResponseSubmitted() { return responseSubmitted; Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/Assessment.java =================================================================== diff -u -r06bf1c491a054104ea4e5cc55fc867af5519c200 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/Assessment.java (.../Assessment.java) (revision 06bf1c491a054104ea4e5cc55fc867af5519c200) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/Assessment.java (.../Assessment.java) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -76,6 +76,8 @@ private boolean allowWrongAnswersAfterQuestion; private boolean allowGradesAfterAttempt; + + private boolean enableConfidenceLevels; private boolean allowHistoryResponses; @@ -525,7 +527,19 @@ public void setAllowGradesAfterAttempt(boolean allowGradesAfterAttempt) { this.allowGradesAfterAttempt = allowGradesAfterAttempt; } + + /** + * + * @return + */ + public boolean isEnableConfidenceLevels() { + return enableConfidenceLevels; + } + public void setEnableConfidenceLevels(boolean enableConfidenceLevels) { + this.enableConfidenceLevels = enableConfidenceLevels; + } + /** * * @return Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java =================================================================== diff -u -rc97b41d72e071f6293126bd85f6eba0b756f7836 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java (.../AssessmentQuestion.java) (revision c97b41d72e071f6293126bd85f6eba0b756f7836) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java (.../AssessmentQuestion.java) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -49,6 +49,11 @@ private String title; private String question; + + /** + * It stores sha1(title + description) value that allows us to search for the AssessmentQuestions with the same title and question + */ + private String questionHash; private int sequenceId; @@ -222,6 +227,16 @@ public void setQuestion(String question) { this.question = question; } + + /** + * Returns sha1(title + description) value that allows us to search for the AssessmentQuestions with the same title and question + */ + public String getQuestionHash() { + return questionHash; + } + public void setQuestionHash(String questionHash) { + this.questionHash = questionHash; + } /** * Returns image sequence number. Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestionResult.java =================================================================== diff -u -re10da332d88104fe61b1f646b8bcac22bbfd15f0 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestionResult.java (.../AssessmentQuestionResult.java) (revision e10da332d88104fe61b1f646b8bcac22bbfd15f0) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestionResult.java (.../AssessmentQuestionResult.java) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -54,6 +54,7 @@ // DTO fields: private AssessmentUser user; private String answerStringEscaped; + private int confidenceLevel; public AssessmentQuestionResult() { optionAnswers = new LinkedHashSet(); @@ -255,5 +256,13 @@ public void setAnswerStringEscaped(String answerStringEscaped) { this.answerStringEscaped = answerStringEscaped; } + + public int getConfidenceLevel() { + return confidenceLevel; + } + public void setConfidenceLevel(int confidenceLevel) { + this.confidenceLevel = confidenceLevel; + } + } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -rba995699c252120c1dfcbf13e0043993a804abe6 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision ba995699c252120c1dfcbf13e0043993a804abe6) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -51,6 +51,8 @@ import org.apache.tomcat.util.json.JSONArray; import org.apache.tomcat.util.json.JSONException; import org.apache.tomcat.util.json.JSONObject; +import org.lamsfoundation.lams.confidencelevel.ConfidenceLevel; +import org.lamsfoundation.lams.confidencelevel.service.IConfidenceLevelService; import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.gradebook.service.IGradebookService; import org.lamsfoundation.lams.learning.service.ILearnerService; @@ -107,9 +109,11 @@ import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.ExcelCell; +import org.lamsfoundation.lams.util.HashUtil; import org.lamsfoundation.lams.util.JsonUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.NumberUtil; +import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.util.audit.IAuditService; /** @@ -139,6 +143,8 @@ private AssessmentOutputFactory assessmentOutputFactory; // system services + + private IConfidenceLevelService confidenceLevelService; private ILamsToolService toolService; @@ -187,7 +193,7 @@ // create new user in a DB if (leader == null) { AssessmentServiceImpl.log.debug("creating new user with userId: " + leaderUserId); - User leaderDto = (User) getUserManagementService().findById(User.class, leaderUserId.intValue()); + User leaderDto = (User) userManagementService.findById(User.class, leaderUserId.intValue()); String userName = leaderDto.getLogin(); String fullName = leaderDto.getFirstName() + " " + leaderDto.getLastName(); leader = new AssessmentUser(leaderDto.getUserDTO(), assessmentSession); @@ -215,13 +221,14 @@ leader.getUserId()); AssessmentResult userResult = assessmentResultDao.getLastAssessmentResult(assessmentUid, user.getUserId()); Set leaderQuestionResults = leaderResult.getQuestionResults(); + Long toolSessionId = leaderResult.getSessionId(); // if response doesn't exist create new empty objects which we populate on the next step if (userResult == null) { userResult = new AssessmentResult(); userResult.setAssessment(leaderResult.getAssessment()); userResult.setUser(user); - userResult.setSessionId(leaderResult.getSessionId()); + userResult.setSessionId(toolSessionId); Set userQuestionResults = userResult.getQuestionResults(); for (AssessmentQuestionResult leaderQuestionResult : leaderQuestionResults) { @@ -281,6 +288,18 @@ } assessmentResultDao.saveObject(userResult); + + // copy leader's confidence levels to the current user + Assessment assessment = leaderResult.getAssessment(); + if (assessment.isEnableConfidenceLevels()) { + List confidences = confidenceLevelService.getConfidenceLevelsByUser(leader.getUserId().intValue(), toolSessionId); + Map questionUidToConfidenceLevelMap = new HashMap(); + for (ConfidenceLevel confidence : confidences) { + questionUidToConfidenceLevelMap.put(confidence.getQuestionUid(), confidence.getConfidenceLevel()); + } + + confidenceLevelService.saveConfidenceLevels(toolSessionId, user.getUserId().intValue(), questionUidToConfidenceLevelMap); + } } @Override @@ -403,6 +422,24 @@ @Override public void saveOrUpdateAssessment(Assessment assessment) { + //update questions' hashes in case questions' titles or descriptions got changed + for (AssessmentQuestion question : (Set) assessment.getQuestions()) { + String plainText = ""; + if (question.getTitle() != null) { + plainText += question.getTitle(); + } + if (question.getQuestion() != null) { + plainText += question.getQuestion(); + } + String newHash = HashUtil.sha1(plainText); + String oldHash = question.getQuestionHash(); + + if (oldHash == null || !oldHash.equals(newHash)) { + question.setQuestionHash(newHash); + } + } + + //store object in DB assessmentDao.saveObject(assessment); } @@ -535,6 +572,7 @@ } // store all answers (in all pages) + Map questionUidToConfidenceLevelMap = new HashMap(); for (Set questionsForOnePage : pagedQuestions) { for (QuestionDTO questionDto : questionsForOnePage) { @@ -569,13 +607,22 @@ continue; } } + + // store confidence levels entered by the learner + int level = questionDto.getConfidenceLevel(); + questionUidToConfidenceLevelMap.put(questionDto.getUid(), level); float userQeustionGrade = storeUserAnswer(result, questionDto, isAutosave); grade += userQeustionGrade; maximumGrade += questionDto.getGrade(); } } + + // store confidence levels entered by the learner + if (assessment.isEnableConfidenceLevels()) { + confidenceLevelService.saveConfidenceLevels(result.getSessionId(), userId.intValue(), questionUidToConfidenceLevelMap); + } // store grades and finished date only on user hitting submit all answers button (and not submit mark hedging // question) @@ -1052,6 +1099,23 @@ } } } + + // populate user entered confidence levels + if (assessment.isEnableConfidenceLevels()) { + List confidenceLevels = getConfidenceLevelsByUser(userId.intValue(), + sessionId); + + for (AssessmentQuestionResult questionResult : questionResultsToDisplay) { + //find according confidenceLevel + for (ConfidenceLevel confidenceLevel : confidenceLevels) { + if (questionResult.getAssessmentQuestion().getUid().equals(confidenceLevel.getQuestionUid())) { + questionResult.setConfidenceLevel(confidenceLevel.getConfidenceLevel()); + break; + } + } + } + } + resultDto.setQuestionResults(questionResultsToDisplay); //escaping @@ -1095,6 +1159,10 @@ } } + List confidenceLevels = assessment.isEnableConfidenceLevels() + ? getConfidenceLevelsByUser(userId.intValue(), sessionId) + : null; + //prepare list of UserSummaryItems ArrayList userSummaryItems = new ArrayList(); for (AssessmentQuestion question : questions) { @@ -1108,6 +1176,18 @@ // for displaying purposes only (no saving occurrs) questionResult.setFinishDate(result.getFinishDate()); + + // prepare for displaying purposes confidence levels + if (assessment.isEnableConfidenceLevels()) { + //find according confidenceLevel + for (ConfidenceLevel confidenceLevel : confidenceLevels) { + if (questionResult.getAssessmentQuestion().getUid() + .equals(confidenceLevel.getQuestionUid())) { + questionResult.setConfidenceLevel(confidenceLevel.getConfidenceLevel()); + break; + } + } + } questionResults.add(questionResult); break; @@ -2272,8 +2352,17 @@ eventNotificationService.notifyLessonMonitors(sessionId, message, false); } + @Override + public List getConfidenceLevelsByUser(Integer userId, Long toolSessionId) { + return confidenceLevelService.getConfidenceLevelsByUser(userId, toolSessionId); + } @Override + public List getConfidenceLevelsByQuestionAndSession(Long questionUid, Long toolSessionId) { + return confidenceLevelService.getConfidenceLevelsByQuestionAndSession(questionUid, toolSessionId); + } + + @Override public List getMarksArray(Long sessionId) { return assessmentUserDao.getRawUserMarksBySession(sessionId); } @@ -2377,6 +2466,10 @@ public void setAuditService(IAuditService auditService) { this.auditService = auditService; } + + public void setConfidenceLevelService(IConfidenceLevelService confidenceLevelService) { + this.confidenceLevelService = confidenceLevelService; + } public void setLearnerService(ILearnerService learnerService) { this.learnerService = learnerService; @@ -2476,7 +2569,7 @@ } toolContentObj.setCreatedBy(user); - assessmentDao.saveObject(toolContentObj); + saveOrUpdateAssessment(toolContentObj); } catch (ImportToolContentException e) { throw new ToolException(e); } @@ -2511,7 +2604,7 @@ } Assessment toContent = Assessment.newInstance(assessment, toContentId); - assessmentDao.saveObject(toContent); + saveOrUpdateAssessment(toContent); } @Override @@ -2712,10 +2805,6 @@ return false; } - public IExportToolContentService getExportContentService() { - return exportContentService; - } - public void setExportContentService(IExportToolContentService exportContentService) { this.exportContentService = exportContentService; } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java =================================================================== diff -u -r60d9a173d5590295376322fc3e857ae2dca37717 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java (.../IAssessmentService.java) (revision 60d9a173d5590295376322fc3e857ae2dca37717) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java (.../IAssessmentService.java) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -30,6 +30,7 @@ import java.util.Set; import java.util.TreeMap; +import org.lamsfoundation.lams.confidencelevel.ConfidenceLevel; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.assessment.dto.AssessmentResultDTO; import org.lamsfoundation.lams.tool.assessment.dto.AssessmentUserDTO; @@ -434,6 +435,24 @@ void changeQuestionResultMark(Long questionResultUid, float newMark); void notifyTeachersOnAttemptCompletion(Long sessionId, String userName); + + /** + * Returns all confidence levels user left in this activity. + * + * @param userId + * @param toolSessionId + * @return + */ + List getConfidenceLevelsByUser(Integer userId, Long toolSessionId); + + /** + * Returns all confidence levels user left in this activity. + * + * @param userId + * @param toolSessionId + * @return + */ + List getConfidenceLevelsByQuestionAndSession(Long questionUid, Long toolSessionId); /** * Get a message from the language files with the given key Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java =================================================================== diff -u -re0f0bfaf1b029e6241352c307a86381e9c5faf42 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java (.../LearningAction.java) (revision e0f0bfaf1b029e6241352c307a86381e9c5faf42) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java (.../LearningAction.java) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -56,6 +56,7 @@ import org.apache.struts.action.ActionRedirect; import org.apache.tomcat.util.json.JSONException; import org.apache.tomcat.util.json.JSONObject; +import org.lamsfoundation.lams.confidencelevel.ConfidenceLevel; import org.lamsfoundation.lams.learning.web.bean.ActivityPositionDTO; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.notebook.model.NotebookEntry; @@ -366,6 +367,22 @@ questionDto.setMatchingPairOptions(new LinkedHashSet(optionsSortedByOptionString)); } } + + // populate user entered confidence levels + if (assessment.isEnableConfidenceLevels()) { + List confidenceLevels = service.getConfidenceLevelsByUser(user.getUserId().intValue(), + toolSessionId); + + for (QuestionDTO questionDto : questionDtos) { + //find according confidenceLevel + for (ConfidenceLevel confidenceLevel : confidenceLevels) { + if (questionDto.getUid().equals(confidenceLevel.getQuestionUid())) { + questionDto.setConfidenceLevel(confidenceLevel.getConfidenceLevel()); + break; + } + } + } + } //paging List> pagedQuestionDtos = new ArrayList>(); @@ -879,6 +896,7 @@ String sessionMapID = WebUtil.readStrParam(request, AssessmentConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapID); + Assessment assessment = (Assessment) sessionMap.get(AssessmentConstants.ATTR_ASSESSMENT); List> pagedQuestionDtos = (List>) sessionMap .get(AssessmentConstants.ATTR_PAGED_QUESTION_DTOS); Set questionsForOnePage = pagedQuestionDtos.get(pageNumber - 1); @@ -964,6 +982,12 @@ questionDto.setAnswerString(answerString); } } + + // store confidence level entered by the learner + if (assessment.isEnableConfidenceLevels()) { + int confidenceLevel = WebUtil.readIntParam(request, AssessmentConstants.ATTR_CONFIDENCE_LEVEL_PREFIX + i); + questionDto.setConfidenceLevel(confidenceLevel); + } } } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/MonitoringAction.java =================================================================== diff -u -r60d9a173d5590295376322fc3e857ae2dca37717 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 60d9a173d5590295376322fc3e857ae2dca37717) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -50,6 +50,7 @@ import org.apache.tomcat.util.json.JSONArray; import org.apache.tomcat.util.json.JSONException; import org.apache.tomcat.util.json.JSONObject; +import org.lamsfoundation.lams.confidencelevel.ConfidenceLevel; import org.lamsfoundation.lams.gradebook.util.GradebookConstants; import org.lamsfoundation.lams.tool.assessment.AssessmentConstants; import org.lamsfoundation.lams.tool.assessment.dto.AssessmentResultDTO; @@ -204,9 +205,11 @@ initAssessmentService(); Long userId = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID); Long sessionId = WebUtil.readLongParam(request, AssessmentConstants.PARAM_SESSION_ID); + String sessionMapID = request.getParameter(AssessmentConstants.ATTR_SESSION_MAP_ID); AssessmentResultDTO result = service.getUserMasterDetail(sessionId, userId); request.setAttribute(AssessmentConstants.ATTR_ASSESSMENT_RESULT, result); + request.setAttribute(AssessmentConstants.ATTR_SESSION_MAP_ID, sessionMapID); return (result == null) ? null : mapping.findForward(AssessmentConstants.SUCCESS); } @@ -482,6 +485,10 @@ int totalPages = new Double( Math.ceil(new Integer(countSessionUsers).doubleValue() / new Integer(rowLimit).doubleValue())) .intValue(); + + List confidenceLevels = assessment.isEnableConfidenceLevels() + ? service.getConfidenceLevelsByQuestionAndSession(questionUid, sessionId) + : null; JSONArray rows = new JSONArray(); int i = 1; @@ -498,13 +505,30 @@ userData.put(questionResult.getMaxMark()); userData.put(fullName); userData.put(AssessmentEscapeUtils.printResponsesForJqgrid(questionResult)); + + // prepare for displaying purposes confidence levels + if (assessment.isEnableConfidenceLevels()) { + //find according confidenceLevel + int confidence = -1; + for (ConfidenceLevel confidenceLevel : confidenceLevels) { + if (questionResult.getAssessmentQuestion().getUid().equals(confidenceLevel.getQuestionUid())) { + confidence = confidenceLevel.getConfidenceLevel(); + break; + } + } + userData.put(confidence); + } + userData.put(questionResult.getMark()); } else { userData.put(""); userData.put(""); userData.put(fullName); userData.put("-"); + if (assessment.isEnableConfidenceLevels()) { + userData.put(-1); + } userData.put("-"); } Index: lams_tool_assessment/web/includes/javascript/monitoring.js =================================================================== diff -u --- lams_tool_assessment/web/includes/javascript/monitoring.js (revision 0) +++ lams_tool_assessment/web/includes/javascript/monitoring.js (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -0,0 +1,33 @@ + var gradientNumberFormat = function (cellvalue) { + var MIN_DATA_VALUE = 0, + MAX_DATA_VALUE = 10; + + var dataAsNumber = parseInt(cellvalue, 10); + if (dataAsNumber == -1) { + return ""; + } + if (dataAsNumber > MAX_DATA_VALUE) { + dataAsNumber = MAX_DATA_VALUE; + } + if (dataAsNumber < MIN_DATA_VALUE) { + dataAsNumber = MIN_DATA_VALUE; + } + var procents = (dataAsNumber - MIN_DATA_VALUE) * 100 / (MAX_DATA_VALUE - MIN_DATA_VALUE); + var gradientClass; + switch (true) { + case (procents < 40): + gradientClass = "gradient-red"; + break; + case (procents >= 40 && procents <= 60): + gradientClass = "gradient-orange"; + break; + default: + gradientClass = "gradient-green"; + break; + } + + return '
' + + $.fmatter.util.NumberFormat(cellvalue, $.jgrid.formatter["integer"]) + + '
'; + }; \ No newline at end of file Index: lams_tool_assessment/web/pages/authoring/advance.jsp =================================================================== diff -u -r5fff5c4348abd6cabbe10da89c813e16edec214f -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/web/pages/authoring/advance.jsp (.../advance.jsp) (revision 5fff5c4348abd6cabbe10da89c813e16edec214f) +++ lams_tool_assessment/web/pages/authoring/advance.jsp (.../advance.jsp) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -189,6 +189,13 @@ + +
+ +
Index: lams_tool_assessment/web/pages/learning/learning.jsp =================================================================== diff -u -re0f0bfaf1b029e6241352c307a86381e9c5faf42 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/web/pages/learning/learning.jsp (.../learning.jsp) (revision e0f0bfaf1b029e6241352c307a86381e9c5faf42) +++ lams_tool_assessment/web/pages/learning/learning.jsp (.../learning.jsp) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -29,16 +29,23 @@ + - + + <%-- param has higher level for request attribute --%> Index: lams_tool_assessment/web/pages/learning/results/allquestions.jsp =================================================================== diff -u -rc97b41d72e071f6293126bd85f6eba0b756f7836 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/web/pages/learning/results/allquestions.jsp (.../allquestions.jsp) (revision c97b41d72e071f6293126bd85f6eba0b756f7836) +++ lams_tool_assessment/web/pages/learning/results/allquestions.jsp (.../allquestions.jsp) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -57,6 +57,10 @@ <%@ include file="historyresponses.jsp"%> + + + <%@ include file="confidencelevel.jsp"%> + Index: lams_tool_assessment/web/pages/learning/results/confidencelevel.jsp =================================================================== diff -u --- lams_tool_assessment/web/pages/learning/results/confidencelevel.jsp (revision 0) +++ lams_tool_assessment/web/pages/learning/results/confidencelevel.jsp (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -0,0 +1,13 @@ +<%@ include file="/common/taglibs.jsp"%> + +
+ +
+ +
+ data-slider-value="${question.confidenceLevel}" + /> +
\ No newline at end of file Index: lams_tool_assessment/web/pages/monitoring/monitoring.jsp =================================================================== diff -u -r60d9a173d5590295376322fc3e857ae2dca37717 -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 60d9a173d5590295376322fc3e857ae2dca37717) +++ lams_tool_assessment/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -12,18 +12,9 @@ + - - - - + Index: lams_tool_assessment/web/pages/monitoring/parts/questionsummary.jsp =================================================================== diff -u -rdba93e2c7ec5cdc97ca92a5b7f0784c5b0c6242a -r373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c --- lams_tool_assessment/web/pages/monitoring/parts/questionsummary.jsp (.../questionsummary.jsp) (revision dba93e2c7ec5cdc97ca92a5b7f0784c5b0c6242a) +++ lams_tool_assessment/web/pages/monitoring/parts/questionsummary.jsp (.../questionsummary.jsp) (revision 373dcc4ea6d1a07c60268ceccd9d1e69d9c35f9c) @@ -11,17 +11,11 @@ - + + +