Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r09ce5b6ca2f36d8d6729c4028403c41fb15ab7a7 -r9f625d1d3925aab8738ae9e64b736cd40a47b015 --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 09ce5b6ca2f36d8d6729c4028403c41fb15ab7a7) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -2,7 +2,7 @@ #language code: en #locale code: AU - # CVS ID: $Id$ Exported from the LAMS Community by Ernie Ghiglione on Fri Nov 07 05:54:42 GMT 2008 + # CVS ID: $Id$ Exported from the LAMS Community by Ernie Ghiglione on Tue Jun 10 03:20:26 BST 2008 #=================== labels for LAMS Central =================# @@ -185,7 +185,7 @@ msg.no.lessons =No lessons label.return.to.myprofile =Return to My Profile label.help =Help? -msg.LAMS.copyright.statement.1 =LAMS\u2122 \u00a9 2002-2008 LAMS Foundation. +msg.LAMS.copyright.statement.1 =LAMS\u2122 \u00A9 2002-2008 LAMS Foundation. msg.LAMS.copyright.short =2002-2008 LAMS Foundation. label.completed =Completed! msg.import.file.format =The import file must be a .zip file exported from LAMS 2 or above, or a .las file exported from LAMS 1.0.2. @@ -222,5 +222,21 @@ index.searchlesson.tooltip =Search students across lessons lessonsearch.noresults =No Lessons found +textsearch.heading =Text that... +textsearch.all.words =has all these words: +textsearch.phrase =has this exact wording or phrase: +textsearch.any.words =has one or more of these words: +textsearch.excluded.words =has none of these unwanted words: +textsearch.save=Save +textsearch.cancel=Cancel +lessonsearch.title =Search students in lesson +lessonsearch.instuctions = Please enter the login, first or last name of the student. As you type the name of the matching students will appear. +lessonsearch.results= Lessons in which ''{0}'' has been found +lessonsearch.noresults = No Lessons found +index.searchlesson=Search +index.searchlesson.tooltip = Search students across lessons +#======= End labels: Exported 208 labels for en AU ===== #======= End labels: Exported 215 labels for en AU ===== + +#======= End labels: Exported 215 labels for en AU ===== Index: lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java =================================================================== diff -u -re76fd654d97033acef2c7bbe4c0def48e37f79f3 -r9f625d1d3925aab8738ae9e64b736cd40a47b015 --- lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java (.../DisplayGroupAction.java) (revision e76fd654d97033acef2c7bbe4c0def48e37f79f3) +++ lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java (.../DisplayGroupAction.java) (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -139,6 +139,7 @@ } if(contains(roles, Role.ROLE_GROUP_MANAGER) || contains(roles,Role.ROLE_MONITOR)) links.add(new IndexLinkBean("index.addlesson", "javascript:openAddLesson(" + org.getOrganisationId()+",'')", "add-lesson-button")); + links.add(new IndexLinkBean("index.searchlesson", "javascript:openSearchLesson(" + org.getOrganisationId()+",'')", "search-lesson-button")); }else{//CLASS_TYPE if(contains(roles, Role.ROLE_GROUP_MANAGER) || contains(roles,Role.ROLE_MONITOR)) links.add(new IndexLinkBean("index.addlesson","javascript:openAddLesson("+org.getParentOrganisation().getOrganisationId()+","+org.getOrganisationId()+")", "add-lesson-button")); Index: lams_central/src/java/org/lamsfoundation/lams/web/FindUserLessonsAction.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/web/FindUserLessonsAction.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/web/FindUserLessonsAction.java (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -0,0 +1,176 @@ +package org.lamsfoundation.lams.web; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.actions.DispatchAction; +import org.lamsfoundation.lams.index.IndexLessonBean; +import org.lamsfoundation.lams.learning.service.ILearnerService; +import org.lamsfoundation.lams.lesson.service.ILessonService; +import org.lamsfoundation.lams.usermanagement.Organisation; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.WebUtil; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * + * @author asukkar + * + * @struts.action path="/findUserLessons" parameter="dispatch" validate="false" + * + * @struts.action-forward name="success-getResults" path="/findUserLessons.jsp" + * @struts.action-forward name="success-autocomplete" path="/findUserLessonsAutocomplete.jsp" + */ +public class FindUserLessonsAction extends DispatchAction { + + private static final Logger logger = Logger.getLogger(FindUserLessonsAction.class); + + private static IUserManagementService userManagementService; + + private static ILessonService lessonService; + + private static ILearnerService learnerService; + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // setup service + if (userManagementService == null || lessonService == null) { + setupService(); + } + + return super.execute(mapping, form, request, response); + } + + public ActionForward getResults(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + // get query + String query = WebUtil.readStrParam(request, "query", true); + Integer courseID = WebUtil.readIntParam(request, "courseID", true); + Integer classID = WebUtil.readIntParam(request, "classID", true); + + if (courseID == null) { + throw new ServletException(); + } + + if (query != null) { + Organisation rootOrg = (Organisation) userManagementService.findById(Organisation.class, courseID); + + Set orgSet = getOrgSet(rootOrg); + + Set userSet = getUserSet(query, orgSet); + + Map> userLessonsMap = new HashMap>(); + for (User user : userSet) { + + for (Organisation org : orgSet) { + + // get all lessons for 'user' in 'org' + Map lessons = lessonService.getLessonsByOrgAndUser(user.getUserId(), org + .getOrganisationId()); + + // add lessons to map + Set userLessons = userLessonsMap.get(user); + + if (userLessons == null) { + userLessons = new HashSet(); + } + + userLessons.addAll(lessons.values()); + + userLessonsMap.put(user, userLessons); + + } + } + + request.setAttribute("userLessonsMap", userLessonsMap); + } + + // set attributes + request.setAttribute("courseID", courseID); + request.setAttribute("classID", classID); + request.setAttribute("originalQuery", query); + + return mapping.findForward("success-getResults"); + } + + private Set getOrgSet(Organisation rootOrg) { + Set orgSet = new HashSet(); + orgSet.add(rootOrg); + orgSet.addAll(rootOrg.getChildOrganisations()); + return orgSet; + } + + private Set getUserSet(String query, Set orgSet) { + + Set userSet = new HashSet(); + + String[] tokens = query.trim().split("\\s+"); // Separated by "whitespace" + + // subgroups + for (Organisation org : orgSet) { + for (String token : tokens) { + userSet.addAll(userManagementService.searchUserSingleTerm(token, org.getOrganisationId())); + } + } + return userSet; + } + + public ActionForward autocomplete(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + String query = WebUtil.readStrParam(request, "q", true); + Integer courseID = WebUtil.readIntParam(request, "courseID", true); + + Organisation rootOrg = (Organisation) userManagementService.findById(Organisation.class, courseID); + + Set userSet = getUserSet(query, getOrgSet(rootOrg)); + + List list = new LinkedList(); + + for (User user : userSet) { + list.add(user.getFirstName() + " " + user.getLastName()); + } + + request.setAttribute("results", list); + + return mapping.findForward("success-autocomplete"); + } + + private void setupService() { + if (userManagementService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + userManagementService = (IUserManagementService) ctx.getBean("userManagementService"); + } + + if (lessonService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + lessonService = (ILessonService) ctx.getBean("lessonService"); + } + + if (learnerService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + learnerService = (ILearnerService) ctx.getBean("learnerService"); + } + + } + +} \ No newline at end of file Index: lams_central/web/findUserLessons.jsp =================================================================== diff -u --- lams_central/web/findUserLessons.jsp (revision 0) +++ lams_central/web/findUserLessons.jsp (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -0,0 +1,103 @@ +<%@ page language="java" pageEncoding="UTF-8" + contentType="text/html;charset=utf-8"%> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-html" prefix="html"%> + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +

+ +

+ +
+ +
+ + + + + + + +

+
+ + +

+ +

+ + +
${user.key.firstName} + ${user.key.lastName} +
    + +
  • ${lesson.name}
  • +
    +
+
+
+
+
+
+ + + + \ No newline at end of file Index: lams_central/web/findUserLessonsAutocomplete.jsp =================================================================== diff -u --- lams_central/web/findUserLessonsAutocomplete.jsp (revision 0) +++ lams_central/web/findUserLessonsAutocomplete.jsp (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -0,0 +1,6 @@ +<%@ page language="java" pageEncoding="UTF-8" + contentType="text/html;charset=utf-8"%> +<%@ taglib uri="tags-core" prefix="c"%> +${result} + + Index: lams_central/web/includes/javascript/jquery-ui/jquery-ui-autocomplete-1.6rc2.min.js =================================================================== diff -u --- lams_central/web/includes/javascript/jquery-ui/jquery-ui-autocomplete-1.6rc2.min.js (revision 0) +++ lams_central/web/includes/javascript/jquery-ui/jquery-ui-autocomplete-1.6rc2.min.js (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -0,0 +1,80 @@ +;(function($){var _remove=$.fn.remove;$.fn.remove=function(){$("*",this).add(this).triggerHandler("remove");return _remove.apply(this,arguments);};function isVisible(element){function checkStyles(element){var style=element.style;return(style.display!='none'&&style.visibility!='hidden');} +var visible=checkStyles(element);(visible&&$.each($.dir(element,'parentNode'),function(){return(visible=checkStyles(this));}));return visible;} +$.extend($.expr[':'],{data:function(a,i,m){return $.data(a,m[3]);},tabbable:function(a,i,m){var nodeName=a.nodeName.toLowerCase();return(a.tabIndex>=0&&(('a'==nodeName&&a.href)||(/input|select|textarea|button/.test(nodeName)&&'hidden'!=a.type&&!a.disabled))&&isVisible(a));}});$.keyCode={BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38};function getter(namespace,plugin,method,args){function getMethods(type){var methods=$[namespace][plugin][type]||[];return(typeof methods=='string'?methods.split(/,?\s+/):methods);} +var methods=getMethods('getter');if(args.length==1&&typeof args[0]=='string'){methods=methods.concat(getMethods('getterSetter'));} +return($.inArray(method,methods)!=-1);} +$.widget=function(name,prototype){var namespace=name.split(".")[0];name=name.split(".")[1];$.fn[name]=function(options){var isMethodCall=(typeof options=='string'),args=Array.prototype.slice.call(arguments,1);if(isMethodCall&&options.substring(0,1)=='_'){return this;} +if(isMethodCall&&getter(namespace,name,options,args)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);} +return this.each(function(){var instance=$.data(this,name);(!instance&&!isMethodCall&&$.data(this,name,new $[namespace][name](this,options)));(instance&&isMethodCall&&$.isFunction(instance[options])&&instance[options].apply(instance,args));});};$[namespace][name]=function(element,options){var self=this;this.widgetName=name;this.widgetEventPrefix=$[namespace][name].eventPrefix||name;this.widgetBaseClass=namespace+'-'+name;this.options=$.extend({},$.widget.defaults,$[namespace][name].defaults,$.metadata&&$.metadata.get(element)[name],options);this.element=$(element).bind('setData.'+name,function(e,key,value){return self._setData(key,value);}).bind('getData.'+name,function(e,key){return self._getData(key);}).bind('remove',function(){return self.destroy();});this._init();};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);$[namespace][name].getterSetter='option';};$.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName);},option:function(key,value){var options=key,self=this;if(typeof key=="string"){if(value===undefined){return this._getData(key);} +options={};options[key]=value;} +$.each(options,function(key,value){self._setData(key,value);});},_getData:function(key){return this.options[key];},_setData:function(key,value){this.options[key]=value;if(key=='disabled'){this.element[value?'addClass':'removeClass'](this.widgetBaseClass+'-disabled');}},enable:function(){this._setData('disabled',false);},disable:function(){this._setData('disabled',true);},_trigger:function(type,e,data){var eventName=(type==this.widgetEventPrefix?type:this.widgetEventPrefix+type);e=e||$.event.fix({type:eventName,target:this.element[0]});return this.element.triggerHandler(eventName,[e,data],this.options[type]);}};$.widget.defaults={disabled:false};$.ui={plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set){return;} +for(var i=0;i').addClass(name).css({position:'absolute',top:'-5000px',left:'-5000px',display:'block'}).appendTo('body');$.ui.cssCache[name]=!!((!(/auto|default/).test(tmp.css('cursor'))||(/^[1-9]/).test(tmp.css('height'))||(/^[1-9]/).test(tmp.css('width'))||!(/none/).test(tmp.css('backgroundImage'))||!(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))));try{$('body').get(0).removeChild(tmp.get(0));}catch(e){} +return $.ui.cssCache[name];},disableSelection:function(el){return $(el).attr('unselectable','on').css('MozUserSelect','none').bind('selectstart.ui',function(){return false;});},enableSelection:function(el){return $(el).attr('unselectable','off').css('MozUserSelect','').unbind('selectstart.ui');},hasScroll:function(e,a){if($(e).css('overflow')=='hidden'){return false;} +var scroll=(a&&a=='left')?'scrollLeft':'scrollTop',has=false;if(e[scroll]>0){return true;} +e[scroll]=1;has=(e[scroll]>0);e[scroll]=0;return has;}};$.ui.mouse={_mouseInit:function(){var self=this;this.element.bind('mousedown.'+this.widgetName,function(e){return self._mouseDown(e);});if($.browser.msie){this._mouseUnselectable=this.element.attr('unselectable');this.element.attr('unselectable','on');} +this.started=false;},_mouseDestroy:function(){this.element.unbind('.'+this.widgetName);($.browser.msie&&this.element.attr('unselectable',this._mouseUnselectable));},_mouseDown:function(e){(this._mouseStarted&&this._mouseUp(e));this._mouseDownEvent=e;var self=this,btnIsLeft=(e.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(e.target).parents().add(e.target).filter(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._mouseCapture(e)){return true;} +this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self.mouseDelayMet=true;},this.options.delay);} +if(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)){this._mouseStarted=(this._mouseStart(e)!==false);if(!this._mouseStarted){e.preventDefault();return true;}} +this._mouseMoveDelegate=function(e){return self._mouseMove(e);};this._mouseUpDelegate=function(e){return self._mouseUp(e);};$(document).bind('mousemove.'+this.widgetName,this._mouseMoveDelegate).bind('mouseup.'+this.widgetName,this._mouseUpDelegate);return false;},_mouseMove:function(e){if($.browser.msie&&!e.button){return this._mouseUp(e);} +if(this._mouseStarted){this._mouseDrag(e);return false;} +if(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,e)!==false);(this._mouseStarted?this._mouseDrag(e):this._mouseUp(e));} +return!this._mouseStarted;},_mouseUp:function(e){$(document).unbind('mousemove.'+this.widgetName,this._mouseMoveDelegate).unbind('mouseup.'+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._mouseStop(e);} +return false;},_mouseDistanceMet:function(e){return(Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance);},_mouseDelayMet:function(e){return this.mouseDelayMet;},_mouseStart:function(e){},_mouseDrag:function(e){},_mouseStop:function(e){},_mouseCapture:function(e){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);(function($){$.widget("ui.autocomplete",{_init:function(){$.extend(this.options,{delay:this.options.url?$.Autocompleter.defaults.delay:10,max:!this.options.scroll?10:150,highlight:this.options.highlight||function(value){return value;},formatMatch:this.options.formatMatch||this.options.formatItem});new $.Autocompleter(this.element[0],this.options);},result:function(handler){return this.element.bind("result",handler);},search:function(handler){return this.element.trigger("search",[handler]);},flushCache:function(){return this.element.trigger("flushCache");},setData:function(key,value){return this.element.trigger("setOptions",[{key:value}]);},destroy:function(){return this.element.trigger("unautocomplete");}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);if(options.result)$input.bind('result.autocomplete',options.result);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false;}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev();}else{onChange(0,true);} +break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next();}else{onChange(0,true);} +break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp();}else{onChange(0,true);} +break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown();}else{onChange(0,true);} +break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false;} +break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break;}}).focus(function(){hasFocus++;}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults();}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true);}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i1){v=words.slice(0,words.length-1).join(options.multipleSeparator)+options.multipleSeparator+v;} +v+=options.multipleSeparator;} +$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true;} +function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return;} +var currentValue=$input.val();if(!skipPrevCheck&¤tValue==previousValue) +return;previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase) +currentValue=currentValue.toLowerCase();request(currentValue,receiveData,hideResultsNow);}else{stopLoading();select.hide();}};function trimWords(value){if(!value){return[""];} +var words=value.split(options.multipleSeparator);var result=[];$.each(words,function(i,value){if($.trim(value)) +result[i]=$.trim(value);});return result;} +function lastWord(value){if(!options.multiple) +return value;var words=trimWords(value);return words[words.length-1];} +function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$.Autocompleter.Selection(input,previousValue.length,previousValue.length+sValue.length);}};function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200);};function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.autocomplete("search",function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""));} +else +$input.val("");}});} +if(wasVisible) +$.Autocompleter.Selection(input,input.value.length,input.value.length);};function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show();}else{hideResultsNow();}};function request(term,success,failure){if(!options.matchCase) +term=term.toLowerCase();var data=cache.load(term);if(data&&data.length){success(term,data);}else if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param;});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed);}});} +else if(options.source&&typeof options.source=='function'){var resultData=options.source(term);var parsed=(options.parse)?options.parse(resultData):resultData;cache.add(term,parsed);success(term,parsed);}else{select.emptyList();failure(term);}};function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"$1");},scroll:true,scrollHeight:180};$.extend($.ui.autocomplete,{defaults:$.Autocompleter.defaults});$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase) +s=s.toLowerCase();var i=s.indexOf(sub);if(i==-1)return false;return i==0||options.matchContains;};function add(q,value){if(length>options.cacheLength){flush();} +if(!data[q]){length++;} +data[q]=value;} +function populate(){if(!options.data)return false;var stMatchSets={},nullData=0;if(!options.url)options.cacheLength=1;stMatchSets[""]=[];for(var i=0,ol=options.data.length;i0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x);}});}} +return csub;}else +if(data[q]){return data[q];}else +if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x;}});return csub;}}} +return null;}};};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ui-autocomplete-over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit) +return;element=$("
").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("
    ").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=='LI'){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE);}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false;}).mousedown(function(){config.mouseDownOnSelect=true;}).mouseup(function(){config.mouseDownOnSelect=false;});if(options.width>0) +element.css("width",options.width);needsInit=false;} +function target(event){var element=event.target;while(element&&element.tagName!="LI") +element=element.parentNode;if(!element) +return[];return element;} +function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight;});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight());}else if(offset=listItems.size()){active=0;}} +function limitNumberOfItems(available){return options.max&&options.max").html(options.highlight(formatted,term)).addClass(i%2==0?"ui-autocomplete-even":"ui-autocomplete-odd").appendTo(list)[0];$.data(li,"ui-autocomplete-data",data[i]);} +listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0;} +if($.fn.bgiframe) +list.bgiframe();} +return{display:function(d,q){init();data=d;term=q;fillList();},next:function(){moveSelect(1);},prev:function(){moveSelect(-1);},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active);}else{moveSelect(-8);}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active);}else{moveSelect(8);}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE) +active=-1;$(input).triggerHandler("autocompletehide",[{},{options:options}],options["hide"]);},visible:function(){return element&&element.is(":visible");},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0]);},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:'auto'});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight;});var scrollbarsVisible=listHeight>options.scrollHeight;list.css('height',scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")));}}} +$(input).triggerHandler("autocompleteshow",[{},{options:options}],options["show"]);},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ui-autocomplete-data");},emptyList:function(){list&&list.empty();},unbind:function(){element&&element.remove();}};};$.Autocompleter.Selection=function(field,start,end){if(field.createTextRange){var selRange=field.createTextRange();selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select();}else if(field.setSelectionRange){field.setSelectionRange(start,end);}else{if(field.selectionStart){field.selectionStart=start;field.selectionEnd=end;}} +field.focus();};})(jQuery); \ No newline at end of file Fisheye: Tag ebdfb238b6c5bb4579d2ce44c61907ea51831fc1 refers to a dead (removed) revision in file `lams_central/web/includes/javascript/jquery-ui/themes/default/ui.all.css'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_central/web/includes/javascript/openUrls.js =================================================================== diff -u -r8731e616b46718381efcd8b48ec294953cfd4283 -r9f625d1d3925aab8738ae9e64b736cd40a47b015 --- lams_central/web/includes/javascript/openUrls.js (.../openUrls.js) (revision 8731e616b46718381efcd8b48ec294953cfd4283) +++ lams_central/web/includes/javascript/openUrls.js (.../openUrls.js) (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -292,5 +292,9 @@ } } + function openSearchLesson( courseID, classID ) { + window.open('findUserLessons.do?dispatch=getResults&courseID='+courseID+'&classID='+classID,'slWindow','width=610,height=480,scrollbars'); + } + //--> Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml =================================================================== diff -u -r78dd6b4b06a4791176be2a470ccae1fab59f0b72 -r9f625d1d3925aab8738ae9e64b736cd40a47b015 --- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml (.../Lesson.hbm.xml) (revision 78dd6b4b06a4791176be2a470ccae1fab59f0b72) +++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/lesson/Lesson.hbm.xml (.../Lesson.hbm.xml) (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -265,5 +265,23 @@ AND gi.grouping_id = g.grouping_id AND g.group_id = gi.staff_group_id + + + + + + + + SELECT l.lesson_id, l.name, l.description, l.lesson_state_id, lp.lesson_completed_flag + FROM (lams_lesson l, lams_learning_design ld, lams_group g, lams_user_group ug) + LEFT JOIN lams_learner_progress lp ON lp.user_id = ug.user_id AND lp.lesson_id = l.lesson_id + WHERE l.learning_design_id = ld.learning_design_id + AND ld.copy_type_id != 3 + AND l.organisation_id = :orgId + AND l.class_grouping_id = g.grouping_id + AND l.lesson_state_id != 7 + AND ug.group_id = g.group_id + AND ug.user_id = :userId + Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java =================================================================== diff -u -ref2417616a93e7d6f1eaee601fd78455a90564d6 -r9f625d1d3925aab8738ae9e64b736cd40a47b015 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision ef2417616a93e7d6f1eaee601fd78455a90564d6) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -69,7 +69,7 @@ * the desired organisation . * @return a List with all active lessons in it. */ - public List getActiveLessonsForLearner(final Integer learnerId, final Integer organisationID); + public List getActiveLessonsForLearner(final Integer learnerId, final Integer organisationID); /** * Saves or Updates a Lesson. @@ -161,15 +161,20 @@ * Gets all non-removed lessons for a user in an org; set isStaff flag whether you want lessons where user is in the * staff list, or just in the learner list. * - * @param userId - * a user id that identifies the user. - * @param orgId - * an org id that identifies the organisation. - * @param isStaff - * boolean flag for whether user is staff in returned lessons. + * @param userId a user id that identifies the user. + * @param orgId an org id that identifies the organisation. * @return a List containing a list of tuples containing lesson details and the lesson completed flag for the user. */ public List getLessonsByOrgAndUserWithCompletedFlag(final Integer userId, final Integer orgId, final boolean isStaff); + + /** + * Gets all non-removed lessons for a user in an org; + * + * @param userId a user id that identifies the user. + * @param orgId an org id that identifies the organisation. + * @return a List containing a list of tuples containing lesson details and the lesson completed flag for the user. + */ + public List getLessonsByOrgAndUser(final Integer userId, final Integer orgId); /** * Get lessons based on learning designs where the original learning design has the given id. Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java =================================================================== diff -u -ref2417616a93e7d6f1eaee601fd78455a90564d6 -r9f625d1d3925aab8738ae9e64b736cd40a47b015 --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision ef2417616a93e7d6f1eaee601fd78455a90564d6) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -122,7 +122,7 @@ * the desired organisation. * @return a List with all active lessons in it. */ - public List getActiveLessonsForLearner(final Integer learnerId, final Integer organisationId) { + public List getActiveLessonsForLearner(final Integer learnerId, final Integer organisationId) { List lessons = null; HibernateTemplate hibernateTemplate = new HibernateTemplate(this.getSessionFactory()); @@ -135,7 +135,7 @@ return result; } }); - return lessons; + return (List)lessons; } /** @@ -301,6 +301,25 @@ }); return dtos; } + + /** + * @see org.lamsfoundation.lams.lesson.dao.ILessonDAO#getLessonsByOrgAndUserWithCompletedFlag(Integer, Integer, + * boolean) + */ + public List getLessonsByOrgAndUser(final Integer userId, final Integer orgId) { + List dtos = null; + HibernateTemplate hibernateTemplate = new HibernateTemplate(this.getSessionFactory()); + dtos = (List) hibernateTemplate.execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + Query query = session.getNamedQuery("lessonsByOrgAndUser"); + query.setInteger("userId", userId.intValue()); + query.setInteger("orgId", orgId.intValue()); + List result = query.list(); + return result; + } + }); + return dtos; + } /** * @see org.lamsfoundation.lams.lesson.dao.ILessonDAO#getLessonsByOriginalLearningDesign(Integer) Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java =================================================================== diff -u -ref2417616a93e7d6f1eaee601fd78455a90564d6 -r9f625d1d3925aab8738ae9e64b736cd40a47b015 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision ef2417616a93e7d6f1eaee601fd78455a90564d6) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -44,9 +44,8 @@ * * A lesson has two different "lists" of learners. *
      - *
    1. The learners who are in the learner group attached to the lesson. This is fixed when the lesson is started and - * is a list of all the learners who could ever participate in to the lesson. This is available via - * lesson.getAllLearners() + *
    2. The learners who are in the learner group attached to the lesson. This is fixed when the lesson is started and is + * a list of all the learners who could ever participate in to the lesson. This is available via lesson.getAllLearners() *
    3. The learners who have started the lesson. They may or may not be logged in currently, or if they are logged in * they may or may not be doing this lesson. This is available via getActiveLessonLearners(). *
    @@ -61,7 +60,9 @@ /** Get all the learners who have started the lesson. They may not be currently online. */ public abstract List getActiveLessonLearners(Long lessonId); - /** Get all the learners who have started the lesson and are part of a given group. They may not be currently online. */ + /** + * Get all the learners who have started the lesson and are part of a given group. They may not be currently online. + */ public abstract List getActiveLessonLearnersByGroup(Long lessonId, Long groupId); /** @@ -103,11 +104,11 @@ * ForceComplete) * * @param lessonId - * lesson id (mandatory) + * lesson id (mandatory) * @param groupingActivity - * the activity that has create grouping. (mandatory) + * the activity that has create grouping. (mandatory) * @param learner - * the learner to be check before grouping. (mandatory) + * the learner to be check before grouping. (mandatory) */ public void performGrouping(Long lessonId, GroupingActivity groupingActivity, User learner) throws LessonServiceException; @@ -116,11 +117,11 @@ * Perform the grouping, setting the given list of learners as one group. * * @param groupingActivity - * the activity that has create grouping. (mandatory) + * the activity that has create grouping. (mandatory) * @param groupName - * (optional) + * (optional) * @param learners - * to form one group (mandatory) + * to form one group (mandatory) */ public void performGrouping(GroupingActivity groupingActivity, String groupName, List learners) throws LessonServiceException; @@ -130,11 +131,11 @@ * grouping but no grouping activity (e.g. in branching). * * @param grouping - * the object on which to perform the grouing. (mandatory) + * the object on which to perform the grouing. (mandatory) * @param groupName - * (optional) + * (optional) * @param learners - * to form one group (mandatory) + * to form one group (mandatory) */ public void performGrouping(Grouping grouping, String groupName, List learners) throws LessonServiceException; @@ -143,23 +144,23 @@ * chosen grouping and branching * * @param lessonId - * lesson id (mandatory) + * lesson id (mandatory) * @param groupId - * group id (mandatory) + * group id (mandatory) * @param grouping - * the object on which to perform the grouing. (mandatory) + * the object on which to perform the grouing. (mandatory) */ public void performGrouping(Grouping grouping, Long groupId, List learners) throws LessonServiceException; /** * Perform grouping for the given learner. * * @param grouping - * the object on which to perform the grouing. (mandatory) + * the object on which to perform the grouing. (mandatory) * @param groupId - * group id (mandatory) + * group id (mandatory) * @param learner - * learner to group (mandatory) + * learner to group (mandatory) * @throws LessonServiceException */ public void performGrouping(Grouping grouping, Long groupId, User learner) throws LessonServiceException; @@ -168,11 +169,11 @@ * Remove learners from the given group. * * @param grouping - * the grouping from which to remove the learners (mandatory) + * the grouping from which to remove the learners (mandatory) * @param groupName - * if not null only remove user from this group, if null remove learner from any group. + * if not null only remove user from this group, if null remove learner from any group. * @param learners - * the learners to be removed (mandatory) + * the learners to be removed (mandatory) */ public void removeLearnersFromGroup(Grouping grouping, Long groupId, List learners) throws LessonServiceException; @@ -182,9 +183,9 @@ * unique. * * @param grouping - * the grouping. (mandatory) + * the grouping. (mandatory) * @param groupName - * (mandatory) + * (mandatory) * @return the new group */ public Group createGroup(Grouping grouping, String name) throws LessonServiceException; @@ -194,9 +195,9 @@ * GroupingException. * * @param grouping - * the grouping that contains the group to remove. (mandatory) + * the grouping that contains the group to remove. (mandatory) * @param groupName - * (mandatory) + * (mandatory) */ public void removeGroup(Grouping grouping, Long groupId) throws LessonServiceException; @@ -216,9 +217,9 @@ * closed issue if this code is called from the LoginRequestValve (as the users will be from a previous session) * * @param lessonId - * new learner id + * new learner id * @param userIds - * array of new learner ids + * array of new learner ids */ public void addLearners(Long lessonId, Integer[] userIds) throws LessonServiceException; @@ -227,9 +228,9 @@ * userIds) if calling from an external system. * * @param lesson - * lesson + * lesson * @param users - * the users to add as learners + * the users to add as learners */ public void addLearners(Lesson lesson, Collection users) throws LessonServiceException; @@ -250,7 +251,7 @@ * * @param lessonId * @param userIds - * array of new staff ids + * array of new staff ids */ public void addStaffMembers(Long lessonId, Integer[] userIds) throws LessonServiceException; @@ -259,9 +260,9 @@ * Integer[] userIds) if calling from an external system. * * @param lesson - * lesson + * lesson * @param users - * the users to add as learners + * the users to add as learners */ public void addStaffMembers(Lesson lesson, Collection users) throws LessonServiceException; @@ -270,7 +271,7 @@ * to the system gates * * @param activity - * The activity for which learner progress references should be removed. + * The activity for which learner progress references should be removed. */ public void removeProgressReferencesToActivity(Activity activity) throws LessonServiceException; @@ -279,7 +280,7 @@ * were any completed progress records, and the design was extended, then they are no longer marked as completed. * * @param lessonId - * The lesson for which learner progress entries should be updated. + * The lesson for which learner progress entries should be updated. */ public void performMarkLessonUncompleted(Long lessonId) throws LessonServiceException; @@ -314,25 +315,32 @@ /** * Returns map of lessons in an organisation for a particular learner or staff user. * - * @param userId - * user's id - * @param orgId - * org's id - * @param isStaff - * return lessons where user is staff, or where user is learner + * @param userId user's id + * @param orgId org's id + * @param isStaff return lessons where user is staff, or where user is learner * @return map of lesson beans used in the index page */ public Map getLessonsByOrgAndUserWithCompletedFlag(Integer userId, Integer orgId, boolean isStaff); /** + * + * Returns map of lessons in an organisation for a particular user + * + * @param userId + * @param organisationId + * @return map of lesson beans + */ + public abstract Map getLessonsByOrgAndUser(Integer userId, Integer organisationId); + + /** * Gets the learner's progress details for a particular lesson. Will return null if the user has not started the * lesson. * * @param learnerId - * user's id + * user's id * @param lessonId - * lesson's id + * lesson's id * @return learner's progress or null */ public LearnerProgress getUserProgressForLesson(Integer learnerId, Long lessonId); @@ -350,8 +358,19 @@ * Finds out which lesson the given tool content belongs to and returns its monitoring users. * * @param sessionId - * tool session ID + * tool session ID * @return list of teachers that monitor the lesson which contains the tool with given session ID */ public List getMonitorsByToolSessionId(Long sessionId); + + /** + * Gets all lessons that are active for a learner, in a given organisation + * + * @param learnerId + * a User that identifies the learner. + * @param organisationId + * the desired organisation. + * @return a List with all active lessons in it. + */ + public List getActiveLessonsForLearner(final Integer learnerId, final Integer organisationId); } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java =================================================================== diff -u -ref2417616a93e7d6f1eaee601fd78455a90564d6 -r9f625d1d3925aab8738ae9e64b736cd40a47b015 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision ef2417616a93e7d6f1eaee601fd78455a90564d6) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision 9f625d1d3925aab8738ae9e64b736cd40a47b015) @@ -59,9 +59,8 @@ * * A lesson has three different "lists" of learners. *
      - *
    1. The learners who are in the learner group attached to the lesson. This is fixed when the lesson is started and - * is a list of all the learners who could ever participate in to the lesson. This is available via - * lesson.getAllLearners() + *
    2. The learners who are in the learner group attached to the lesson. This is fixed when the lesson is started and is + * a list of all the learners who could ever participate in to the lesson. This is available via lesson.getAllLearners() *
    3. The learners who have started the lesson. They may or may not be logged in currently, or if they are logged in * they may or may not be doing this lesson. This is available via getActiveLessonLearners(). *
    @@ -82,7 +81,7 @@ private IBaseDAO baseDAO; private ILearnerProgressDAO learnerProgressDAO; - /* ******* Spring injection methods ************************************** */ + /* Spring injection methods */ public void setLessonDAO(ILessonDAO lessonDAO) { this.lessonDAO = lessonDAO; } @@ -107,7 +106,7 @@ this.baseDAO = baseDAO; } - /* *********** Service methods ********************************************** */ + /* Service methods */ /* * (non-Javadoc) * @@ -121,7 +120,7 @@ * (non-Javadoc) * * @see org.lamsfoundation.lams.lesson.service.ILessonService#getActiveLessonLearnersByGroup(java.lang.Long, - * java.lang.Long) + * java.lang.Long) */ public List getActiveLessonLearnersByGroup(Long lessonId, Long groupId) { return lessonDAO.getActiveLearnerByLessonAndGroup(lessonId, groupId); @@ -183,11 +182,11 @@ * Can only be run on a Random Grouping * * @param lessonId - * lesson id (mandatory) + * lesson id (mandatory) * @param groupingActivity - * the activity that has create grouping. (mandatory) + * the activity that has create grouping. (mandatory) * @param learner - * the learner to be check before grouping. (mandatory) + * the learner to be check before grouping. (mandatory) */ public void performGrouping(Long lessonId, GroupingActivity groupingActivity, User learner) throws LessonServiceException { @@ -226,11 +225,11 @@ * Perform the grouping, setting the given list of learners as one group. * * @param groupingActivity - * the activity that has create grouping. (mandatory) + * the activity that has create grouping. (mandatory) * @param groupName - * (optional) + * (optional) * @param learners - * to form one group (mandatory) + * to form one group (mandatory) */ public void performGrouping(GroupingActivity groupingActivity, String groupName, List learners) throws LessonServiceException { @@ -244,11 +243,11 @@ * grouping but no grouping activity (e.g. in branching). * * @param groupingActivity - * the activity that has create grouping. (mandatory) + * the activity that has create grouping. (mandatory) * @param groupName - * (optional) + * (optional) * @param learners - * to form one group (mandatory) + * to form one group (mandatory) */ public void performGrouping(Grouping grouping, String groupName, List learners) throws LessonServiceException { @@ -272,11 +271,11 @@ * Perform grouping for the given learner. * * @param grouping - * the object on which to perform the grouing. (mandatory) + * the object on which to perform the grouing. (mandatory) * @param groupId - * group id (mandatory) + * group id (mandatory) * @param learner - * learner to group (mandatory) + * learner to group (mandatory) * @throws LessonServiceException */ public void performGrouping(Grouping grouping, Long groupId, User learner) throws LessonServiceException { @@ -304,11 +303,11 @@ * be their normal branch). * * @param grouping - * The grouping that needs to have the grouping performed.. (mandatory) + * The grouping that needs to have the grouping performed.. (mandatory) * @param the - * id of the preferred group (optional) + * id of the preferred group (optional) * @param learners - * to form one group (mandatory) + * to form one group (mandatory) */ public void performGrouping(Grouping grouping, Long groupId, List learners) throws LessonServiceException { if (grouping != null) { @@ -334,11 +333,11 @@ * Remove learners from the given group. * * @param grouping - * the grouping that contains the users to be removed (mandatory) + * the grouping that contains the users to be removed (mandatory) * @param groupID - * if not null only remove user from this group, if null remove learner from any group. + * if not null only remove user from this group, if null remove learner from any group. * @param learners - * the learners to be removed (mandatory) + * the learners to be removed (mandatory) */ public void removeLearnersFromGroup(Grouping grouping, Long groupID, List learners) throws LessonServiceException { @@ -362,9 +361,9 @@ * already exists then it will force the name to be unique. * * @param grouping - * the grouping. (mandatory) + * the grouping. (mandatory) * @param groupName - * (mandatory) + * (mandatory) * @return the new group */ public Group createGroup(Grouping grouping, String name) throws LessonServiceException { @@ -390,9 +389,9 @@ * GroupingException. * * @param grouping - * the grouping that contains the group to be removed (mandatory) + * the grouping that contains the group to be removed (mandatory) * @param groupID - * (mandatory) + * (mandatory) */ public void removeGroup(Grouping grouping, Long groupID) throws LessonServiceException { if (grouping != null) { @@ -414,7 +413,7 @@ * Add a learner to the lesson class. Checks for duplicates. * * @param userId - * new learner id + * new learner id * @return true if added user, returns false if the user already a learner and hence not added. */ public boolean addLearner(Long lessonId, Integer userId) throws LessonServiceException { @@ -454,7 +453,7 @@ * * @param lessonId * @param userIds - * array of new learner ids + * array of new learner ids */ public void addLearners(Long lessonId, Integer[] userIds) throws LessonServiceException { @@ -489,9 +488,9 @@ * userIds) if calling from an external system. * * @param lesson - * lesson + * lesson * @param users - * the users to add as learners + * the users to add as learners */ public void addLearners(Lesson lesson, Collection users) throws LessonServiceException { @@ -509,7 +508,7 @@ * Add a new staff member to the lesson class. Checks for duplicates. * * @param userId - * new learner id + * new learner id * @return true if added user, returns false if the user already a staff member and hence not added. */ public boolean addStaffMember(Long lessonId, Integer userId) { @@ -545,7 +544,7 @@ * * @param lessonId * @param userIds - * array of new staff ids + * array of new staff ids */ public void addStaffMembers(Long lessonId, Integer[] userIds) throws LessonServiceException { @@ -577,9 +576,9 @@ * Integer[] userIds) if calling from an external system. * * @param lesson - * lesson + * lesson * @param users - * the users to add as learners + * the users to add as learners */ public void addStaffMembers(Lesson lesson, Collection users) throws LessonServiceException { @@ -599,7 +598,7 @@ * to the system gates * * @param activity - * The activity for which learner progress references should be removed. + * The activity for which learner progress references should be removed. */ public void removeProgressReferencesToActivity(Activity activity) throws LessonServiceException { if (activity != null) { @@ -665,7 +664,7 @@ * were any completed progress records, and the design was extended, then they are no longer marked as completed. * * @param lessonId - * The lesson for which learner progress entries should be updated. + * The lesson for which learner progress entries should be updated. */ public void performMarkLessonUncompleted(Long lessonId) throws LessonServiceException { int count = 0; @@ -746,14 +745,34 @@ return map; } + public Map getLessonsByOrgAndUser(Integer userId, Integer organisationId) { + TreeMap map = new TreeMap(); + List list = lessonDAO.getLessonsByOrgAndUser(userId, organisationId); + if (list != null) { + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + Object[] tuple = (Object[]) iterator.next(); + Long lessonId = (Long) tuple[0]; + String lessonName = (String) tuple[1]; + String lessonDescription = (String) tuple[2]; + Integer lessonState = (Integer) tuple[3]; + Boolean lessonCompleted = (Boolean) tuple[4]; + IndexLessonBean bean = new IndexLessonBean(lessonId, lessonName, lessonDescription, lessonState, + (lessonCompleted == null ? false : lessonCompleted.booleanValue())); + map.put(new Long(lessonId), bean); + } + } + return map; + } + /** * Gets the learner's progress details for a particular lesson. Will return null if the user has not started the * lesson. * * @param learnerId - * user's id + * user's id * @param lessonId - * lesson's id + * lesson's id * @return learner's progress or null */ public LearnerProgress getUserProgressForLesson(Integer learnerId, Long lessonId) { @@ -770,4 +789,8 @@ public List getMonitorsByToolSessionId(Long sessionId) { return lessonDAO.getMonitorsByToolSessionId(sessionId); } + + public List getActiveLessonsForLearner(Integer learnerId, Integer organisationId) { + return lessonDAO.getActiveLessonsForLearner(learnerId, organisationId); + } }