Index: lams_common/db/sql/insert_types_data.sql =================================================================== diff -u -r9ea6e437478e6cb7bbb7a64a14a5f379df3e0b95 -rffafd64613340f1eff7781c7b138b805400df8cf --- lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision 9ea6e437478e6cb7bbb7a64a14a5f379df3e0b95) +++ lams_common/db/sql/insert_types_data.sql (.../insert_types_data.sql) (revision ffafd64613340f1eff7781c7b138b805400df8cf) @@ -290,10 +290,6 @@ VALUES (26, 'tr', 'TR', 'Türkçe', 'LTR', 'tr'); INSERT INTO lams_supported_locale (locale_id, language_iso_code, country_iso_code, description, direction, fckeditor_code) VALUES (27, 'ca', 'ES', 'Català', 'LTR', 'ca'); -INSERT INTO lams_supported_locale (locale_id, language_iso_code, country_iso_code, description, direction, fckeditor_code) -VALUES (28, 'sl', 'SI', 'Slovenščina', 'LTR', 'sl'); -INSERT INTO lams_supported_locale (locale_id, language_iso_code, country_iso_code, description, direction, fckeditor_code) -VALUES (29, 'es', 'MX', 'Español (Mexico)', 'LTR', 'es'); -- which current tool supports the old 1.0.x tools? INSERT INTO lams_tool_import_support VALUES (1, 'lafrum11', 'messageboard'); @@ -321,4 +317,4 @@ INSERT INTO lams_openid_config(config_key, config_value) values ("trustedIDPs", ""); -- initialise db version -INSERT INTO patches VALUES ('lams', 02040005, NOW(), 'F'); +INSERT INTO patches VALUES ('lams', 02040006, NOW(), 'F'); Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040006.sql =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040006.sql (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02040006.sql (revision ffafd64613340f1eff7781c7b138b805400df8cf) @@ -0,0 +1,9 @@ +SET AUTOCOMMIT = 0; + +-- SIF-10 Addding a release date to the lesson table so we can +-- track release events +alter table lams_lesson add column release_date DATETIME; +alter table lams_lesson add index idx_release_date (release_date); + +COMMIT; +SET AUTOCOMMIT = 1; \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java =================================================================== diff -u -racc8d2acf5b6b0002e0c8129947040a779ab4077 -rffafd64613340f1eff7781c7b138b805400df8cf --- lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java (.../Lesson.java) (revision acc8d2acf5b6b0002e0c8129947040a779ab4077) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/Lesson.java (.../Lesson.java) (revision ffafd64613340f1eff7781c7b138b805400df8cf) @@ -142,6 +142,8 @@ /** Persistent field. Defaults to FALSE if not set to anything by a constructor parameter. */ private Boolean marksReleased; + private Date releaseDate; + //--------------------------------------------------------------------- // constructors //--------------------------------------------------------------------- @@ -636,4 +638,16 @@ public void setMarksReleased(Boolean marksReleased) { this.marksReleased = marksReleased; } + + /** + * @hibernate.property type="java.util.Date" column="release_date" + * + */ + public Date getReleaseDate() { + return releaseDate; + } + + public void setReleaseDate(Date releaseDate) { + this.releaseDate = releaseDate; + } } Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookMonitoringAction.java =================================================================== diff -u -r2f21856ec2ab85b47c93cfcc3fa2c8769be65077 -rffafd64613340f1eff7781c7b138b805400df8cf --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookMonitoringAction.java (.../GradebookMonitoringAction.java) (revision 2f21856ec2ab85b47c93cfcc3fa2c8769be65077) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookMonitoringAction.java (.../GradebookMonitoringAction.java) (revision ffafd64613340f1eff7781c7b138b805400df8cf) @@ -23,6 +23,7 @@ /* $Id$ */ package org.lamsfoundation.lams.gradebook.web.action; +import java.util.Date; import java.util.LinkedHashMap; import javax.servlet.ServletOutputStream; @@ -58,316 +59,321 @@ /** * @author lfoxton * - * Handles the monitor interfaces for gradebook + * Handles the monitor interfaces for gradebook * - * This is where marking for an activity/lesson takes place + * This is where marking for an activity/lesson takes place * * - * @struts.action path="/gradebookMonitoring" parameter="dispatch" - * scope="request" name="monitoringForm" validate="false" + * @struts.action path="/gradebookMonitoring" parameter="dispatch" scope="request" + * name="monitoringForm" validate="false" * * @struts:action-forward name="monitorgradebook" path="/gradebookMonitor.jsp" - * @struts:action-forward name="monitorcoursegradebook" - * path="/gradebookCourseMonitor.jsp" + * @struts:action-forward name="monitorcoursegradebook" path="/gradebookCourseMonitor.jsp" * @struts:action-forward name="error" path=".error" * @struts:action-forward name="message" path=".message" */ public class GradebookMonitoringAction extends LamsDispatchAction { - private static Logger logger = Logger.getLogger(GradebookMonitoringAction.class); + private static Logger logger = Logger.getLogger(GradebookMonitoringAction.class); - private static IGradebookService gradebookService; - private static IUserManagementService userService; - private static ILessonService lessonService; + private static IGradebookService gradebookService; + private static IUserManagementService userService; + private static ILessonService lessonService; - @SuppressWarnings("unchecked") - public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + @SuppressWarnings("unchecked") + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - try { - initServices(); - Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - logger.debug("request monitorGradebook for lesson: " + lessonId.toString()); - UserDTO user = getUser(); - if (user == null) { - logger.error("User missing from session. "); - return mapping.findForward("error"); - } else { - Lesson lesson = lessonId != null ? lessonService.getLesson(lessonId) : null; - if (lesson == null) { - logger.error("Lesson " + lessonId + " does not exist. Unable to monitor lesson"); - return mapping.findForward("error"); - } + try { + initServices(); + Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + logger.debug("request monitorGradebook for lesson: " + lessonId.toString()); + UserDTO user = getUser(); + if (user == null) { + logger.error("User missing from session. "); + return mapping.findForward("error"); + } else { + Lesson lesson = lessonId != null ? lessonService.getLesson(lessonId) : null; + if (lesson == null) { + logger.error("Lesson " + lessonId + " does not exist. Unable to monitor lesson"); + return mapping.findForward("error"); + } - if (lesson.getLessonClass() == null || !lesson.getLessonClass().isStaffMember(getRealUser(user))) { - logger.error("User " + user.getLogin() - + " is not a monitor in the requested lesson. Cannot access the lesson for monitor."); - return displayMessage(mapping, request, "error.authorisation"); - } + if (lesson.getLessonClass() == null || !lesson.getLessonClass().isStaffMember(getRealUser(user))) { + logger.error("User " + user.getLogin() + + " is not a monitor in the requested lesson. Cannot access the lesson for monitor."); + return displayMessage(mapping, request, "error.authorisation"); + } - logger.debug("user is staff"); + logger.debug("user is staff"); - boolean marksReleased = lesson.getMarksReleased() != null && lesson.getMarksReleased(); + boolean marksReleased = lesson.getMarksReleased() != null && lesson.getMarksReleased(); - LessonDetailsDTO lessonDetatilsDTO = lesson.getLessonDetails(); - request.setAttribute("lessonDetails", lessonDetatilsDTO); - request.setAttribute("marksReleased", marksReleased); + LessonDetailsDTO lessonDetatilsDTO = lesson.getLessonDetails(); + request.setAttribute("lessonDetails", lessonDetatilsDTO); + request.setAttribute("marksReleased", marksReleased); - return mapping.findForward("monitorgradebook"); - } - } catch (Exception e) { - logger.error("Failed to load gradebook monitor", e); - return mapping.findForward("error"); + return mapping.findForward("monitorgradebook"); + } + } catch (Exception e) { + logger.error("Failed to load gradebook monitor", e); + return mapping.findForward("error"); + } } - } - @SuppressWarnings("unchecked") - public ActionForward courseMonitor(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + @SuppressWarnings("unchecked") + public ActionForward courseMonitor(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - try { - initServices(); - Integer oranisationID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID); + try { + initServices(); + Integer oranisationID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID); - logger.debug("request monitorGradebook for organisation: " + oranisationID.toString()); - UserDTO user = getUser(); - if (user == null) { - logger.error("User missing from session. "); - return mapping.findForward("error"); - } else { + logger.debug("request monitorGradebook for organisation: " + oranisationID.toString()); + UserDTO user = getUser(); + if (user == null) { + logger.error("User missing from session. "); + return mapping.findForward("error"); + } else { - Organisation organisation = (Organisation) userService.findById(Organisation.class, oranisationID); - if (organisation == null) { - logger.error("Organisation " + oranisationID + " does not exist. Unable to load gradebook"); - return mapping.findForward("error"); - } + Organisation organisation = (Organisation) userService.findById(Organisation.class, oranisationID); + if (organisation == null) { + logger.error("Organisation " + oranisationID + " does not exist. Unable to load gradebook"); + return mapping.findForward("error"); + } - // Validate whether this user is a monitor for this organisation - if (!userService.isUserInRole(user.getUserID(), oranisationID, Role.MONITOR)) { - logger.error("User " + user.getLogin() - + " is not a monitor in the requested course. Cannot access the course for gradebook."); - return displayMessage(mapping, request, "error.authorisation"); - } + // Validate whether this user is a monitor for this organisation + if (!userService.isUserInRole(user.getUserID(), oranisationID, Role.MONITOR)) { + logger.error("User " + user.getLogin() + + " is not a monitor in the requested course. Cannot access the course for gradebook."); + return displayMessage(mapping, request, "error.authorisation"); + } - logger.debug("user is staff"); + logger.debug("user is staff"); - request.setAttribute("organisationID", oranisationID); - request.setAttribute("organisationName", organisation.getName()); + request.setAttribute("organisationID", oranisationID); + request.setAttribute("organisationName", organisation.getName()); - return mapping.findForward("monitorcoursegradebook"); - } - } catch (Exception e) { - logger.error("Failed to load gradebook monitor", e); - return mapping.findForward("error"); + return mapping.findForward("monitorcoursegradebook"); + } + } catch (Exception e) { + logger.error("Failed to load gradebook monitor", e); + return mapping.findForward("error"); + } } - } - /** - * Updates a user's mark or feedback for an entire lesson - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws Exception - */ - public ActionForward updateUserLessonGradebookData(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) throws Exception { - initServices(); - Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - Integer userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_ID); - String markStr = WebUtil.readStrParam(request, GradebookConstants.PARAM_MARK, true); - String feedback = WebUtil.readStrParam(request, GradebookConstants.PARAM_FEEDBACK, true); - Lesson lesson = lessonService.getLesson(lessonID); - User learner = (User) userService.findById(User.class, userID); + /** + * Updates a user's mark or feedback for an entire lesson + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws Exception + */ + public ActionForward updateUserLessonGradebookData(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws Exception { + initServices(); + Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + Integer userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_ID); + String markStr = WebUtil.readStrParam(request, GradebookConstants.PARAM_MARK, true); + String feedback = WebUtil.readStrParam(request, GradebookConstants.PARAM_FEEDBACK, true); + Lesson lesson = lessonService.getLesson(lessonID); + User learner = (User) userService.findById(User.class, userID); - if (lesson != null || learner != null) { + if (lesson != null || learner != null) { - if (markStr != null && !markStr.equals("")) { - Double mark = Double.parseDouble(markStr); - gradebookService.updateUserLessonGradebookMark(lesson, learner, mark); - } + if (markStr != null && !markStr.equals("")) { + Double mark = Double.parseDouble(markStr); + gradebookService.updateUserLessonGradebookMark(lesson, learner, mark); + } - if (feedback != null) { - gradebookService.updateUserLessonGradebookFeedback(lesson, learner, feedback); - } + if (feedback != null) { + gradebookService.updateUserLessonGradebookFeedback(lesson, learner, feedback); + } - } else { - logger.error("No lesson could be found for: " + lessonID); + } else { + logger.error("No lesson could be found for: " + lessonID); + } + return null; } - return null; - } - /** - * Updates a user's mark or feedback for an activity, then aggregates their - * total lesson mark - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws Exception - */ - public ActionForward updateUserActivityGradebookData(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) throws Exception { - initServices(); - Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + /** + * Updates a user's mark or feedback for an activity, then aggregates their total lesson mark + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws Exception + */ + public ActionForward updateUserActivityGradebookData(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws Exception { + initServices(); + Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - GBGridView view = GradebookUtil.readGBGridViewParam(request, GradebookConstants.PARAM_VIEW, false); + GBGridView view = GradebookUtil.readGBGridViewParam(request, GradebookConstants.PARAM_VIEW, false); - Long activityID = null; - Integer userID = null; + Long activityID = null; + Integer userID = null; - // Fetch the id based on which grid it came from - if (view == GBGridView.MON_ACTIVITY) { - String rowID = WebUtil.readStrParam(request, AttributeNames.PARAM_ACTIVITY_ID); + // Fetch the id based on which grid it came from + if (view == GBGridView.MON_ACTIVITY) { + String rowID = WebUtil.readStrParam(request, AttributeNames.PARAM_ACTIVITY_ID); - // Splitting the rowID param to get the activity/group id pair - String[] split = rowID.split("_"); - if (split.length == 2) { - activityID = Long.parseLong(split[0]); - } else { - activityID = Long.parseLong(rowID); - } + // Splitting the rowID param to get the activity/group id pair + String[] split = rowID.split("_"); + if (split.length == 2) { + activityID = Long.parseLong(split[0]); + } else { + activityID = Long.parseLong(rowID); + } - userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_ID); + userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_ID); - } else if (view == GBGridView.MON_USER) { - activityID = WebUtil.readLongParam(request, GradebookConstants.PARAM_ID); - userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_USERID); + } else if (view == GBGridView.MON_USER) { + activityID = WebUtil.readLongParam(request, GradebookConstants.PARAM_ID); + userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_USERID); + } + + String markStr = WebUtil.readStrParam(request, GradebookConstants.PARAM_MARK, true); + String feedback = WebUtil.readStrParam(request, GradebookConstants.PARAM_FEEDBACK, true); + + Activity activity = (Activity) userService.findById(Activity.class, activityID); + User learner = (User) userService.findById(User.class, userID); + Lesson lesson = lessonService.getLesson(lessonID); + + if (lesson != null && activity != null && learner != null && activity.isToolActivity()) { + + if (markStr != null && !markStr.equals("")) { + Double mark = Double.parseDouble(markStr); + gradebookService.updateUserActivityGradebookMark(lesson, learner, activity, mark, true); + } + + if (feedback != null) { + gradebookService.updateUserActivityGradebookFeedback(activity, learner, feedback); + } + + } else { + logger.error("Lesson or activity missing for lesson: " + lessonID + "and activity: " + activityID); + } + return null; } - String markStr = WebUtil.readStrParam(request, GradebookConstants.PARAM_MARK, true); - String feedback = WebUtil.readStrParam(request, GradebookConstants.PARAM_FEEDBACK, true); + /** + * Toggles the release mark flag for a lesson + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws Exception + */ + public ActionForward toggleReleaseMarks(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + initServices(); + Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - Activity activity = (Activity) userService.findById(Activity.class, activityID); - User learner = (User) userService.findById(User.class, userID); - Lesson lesson = lessonService.getLesson(lessonID); + Lesson lesson = lessonService.getLesson(lessonID); - if (lesson != null && activity != null && learner != null && activity.isToolActivity()) { + boolean marksReleased = lesson.getMarksReleased() != null && lesson.getMarksReleased(); + if (!marksReleased) { - if (markStr != null && !markStr.equals("")) { - Double mark = Double.parseDouble(markStr); - gradebookService.updateUserActivityGradebookMark(lesson, learner, activity, mark, true); - } + // If marks not released, set a new release date + lesson.setReleaseDate(new Date()); + } - if (feedback != null) { - gradebookService.updateUserActivityGradebookFeedback(activity, learner, feedback); - } + lesson.setMarksReleased(!marksReleased); - } else { - logger.error("Lesson or activity missing for lesson: " + lessonID + "and activity: " + activityID); + userService.save(lesson); + + writeResponse(response, CONTENT_TYPE_TEXT_PLAIN, ENCODING_UTF8, "success"); + return null; } - return null; - } - /** - * Toggles the release mark flag for a lesson - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws Exception - */ - public ActionForward toggleReleaseMarks(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { - initServices(); - Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + public ActionForward exportExcelLessonGradebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - Lesson lesson = lessonService.getLesson(lessonID); + initServices(); - boolean marksReleased = lesson.getMarksReleased() != null && lesson.getMarksReleased(); + Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + Lesson lesson = lessonService.getLesson(lessonID); - lesson.setMarksReleased(!marksReleased); - userService.save(lesson); + if (lesson != null) { + String fileName = lesson.getLessonName().replaceAll(" ", "_") + ".xls"; - writeResponse(response, CONTENT_TYPE_TEXT_PLAIN, ENCODING_UTF8, "success"); - return null; - } + response.setContentType("application/x-download"); + response.setHeader("Content-Disposition", "attachment;filename=" + fileName); + logger.debug("Exporting to a spreadsheet gradebook lesson: " + lessonID); + ServletOutputStream out = response.getOutputStream(); - public ActionForward exportExcelLessonGradebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + LinkedHashMap dataToExport = new LinkedHashMap(); - initServices(); + ExcelCell[][] summaryData = gradebookService.getSummaryDataForExcel(lesson); + dataToExport.put(gradebookService.getMessage("gradebook.export.lesson.summary"), summaryData); - Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - Lesson lesson = lessonService.getLesson(lessonID); + ExcelCell[][] activityData = gradebookService.getActivityViewDataForExcel(lesson); + dataToExport.put(gradebookService.getMessage("gradebook.gridtitle.activitygrid"), activityData); - if (lesson != null) { - String fileName = lesson.getLessonName().replaceAll(" ", "_") + ".xls"; - - response.setContentType("application/x-download"); - response.setHeader("Content-Disposition", "attachment;filename=" + fileName); - logger.debug("Exporting to a spreadsheet gradebook lesson: " + lessonID); - ServletOutputStream out = response.getOutputStream(); - - LinkedHashMap dataToExport = new LinkedHashMap(); - - ExcelCell[][] summaryData = gradebookService.getSummaryDataForExcel(lesson); - dataToExport.put(gradebookService.getMessage("gradebook.export.lesson.summary"), summaryData); - - ExcelCell[][] activityData = gradebookService.getActivityViewDataForExcel(lesson); - dataToExport.put(gradebookService.getMessage("gradebook.gridtitle.activitygrid"), activityData); - - ExcelCell[][] userData = gradebookService.getUserViewDataForExcel(lesson); - dataToExport.put(gradebookService.getMessage("gradebook.export.learner.view"), userData); - - GradebookUtil.exportGradebookLessonToExcel(out, gradebookService.getMessage("gradebook.export.dateheader"), dataToExport); + ExcelCell[][] userData = gradebookService.getUserViewDataForExcel(lesson); + dataToExport.put(gradebookService.getMessage("gradebook.export.learner.view"), userData); - } else { - throw new Exception("Attempt to retrieve gradebook data for null lesson"); + GradebookUtil.exportGradebookLessonToExcel(out, gradebookService.getMessage("gradebook.export.dateheader"), + dataToExport); + + } else { + throw new Exception("Attempt to retrieve gradebook data for null lesson"); + } + return null; } - return null; - } - private UserDTO getUser() { - HttpSession ss = SessionManager.getSession(); - return (UserDTO) ss.getAttribute(AttributeNames.USER); - } + private UserDTO getUser() { + HttpSession ss = SessionManager.getSession(); + return (UserDTO) ss.getAttribute(AttributeNames.USER); + } - private User getRealUser(UserDTO dto) { - return getUserService().getUserByLogin(dto.getLogin()); - } + private User getRealUser(UserDTO dto) { + return getUserService().getUserByLogin(dto.getLogin()); + } - private ActionForward displayMessage(ActionMapping mapping, HttpServletRequest req, String messageKey) { - req.setAttribute("messageKey", messageKey); - return mapping.findForward("message"); - } + private ActionForward displayMessage(ActionMapping mapping, HttpServletRequest req, String messageKey) { + req.setAttribute("messageKey", messageKey); + return mapping.findForward("message"); + } - private void initServices() { - getUserService(); - getLessonService(); - getGradebookService(); - } + private void initServices() { + getUserService(); + getLessonService(); + getGradebookService(); + } - private IUserManagementService getUserService() { - if (userService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); - userService = (IUserManagementService) ctx.getBean("userManagementService"); + private IUserManagementService getUserService() { + if (userService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + userService = (IUserManagementService) ctx.getBean("userManagementService"); + } + return userService; } - return userService; - } - private ILessonService getLessonService() { - if (lessonService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); - lessonService = (ILessonService) ctx.getBean("lessonService"); + private ILessonService getLessonService() { + if (lessonService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + lessonService = (ILessonService) ctx.getBean("lessonService"); + } + return lessonService; } - return lessonService; - } - private IGradebookService getGradebookService() { - if (gradebookService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); - gradebookService = (IGradebookService) ctx.getBean("gradebookService"); + private IGradebookService getGradebookService() { + if (gradebookService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + gradebookService = (IGradebookService) ctx.getBean("gradebookService"); + } + return gradebookService; } - return gradebookService; - } }