diff --git a/.idea/compiler.xml b/.idea/compiler.xml index da78bd3101..6075adace3 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -5,7 +5,6 @@ - diff --git a/package.json b/package.json index 48f97a8336..1aa32a66bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wise", - "version": "5.7.5", + "version": "5.7.6", "description": "Web-based Inquiry Science Environment", "main": "app.js", "dependencies": { diff --git a/pom.xml b/pom.xml index 65c3267bbc..50ba12b720 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ wise war Web-based Inquiry Science Environment - 5.7.5 + 5.7.6 http://wise5.org @@ -124,7 +124,6 @@ **/org/wise/portal/service/**/*.java **/org/wise/portal/domain/**/*.java - **/org/wise/portal/presentation/web/controllers/admin/*.java **/org/wise/portal/presentation/web/controllers/general/contactwise/*.java **/org/wise/portal/presentation/web/controllers/teacher/**/*.java **/org/wise/portal/presentation/web/controllers/*.java @@ -148,7 +147,6 @@ **/org/wise/portal/service/**/*.java **/org/wise/portal/domain/**/*.java - **/org/wise/portal/presentation/web/controllers/admin/*.java **/org/wise/portal/presentation/web/controllers/general/contactwise/*.java **/org/wise/portal/presentation/web/controllers/teacher/**/*.java **/org/wise/portal/presentation/web/controllers/*.java diff --git a/src/main/java/org/wise/portal/domain/admin/DailyAdminJob.java b/src/main/java/org/wise/portal/domain/admin/DailyAdminJob.java index 0b27c0c617..a04278f16a 100644 --- a/src/main/java/org/wise/portal/domain/admin/DailyAdminJob.java +++ b/src/main/java/org/wise/portal/domain/admin/DailyAdminJob.java @@ -147,7 +147,6 @@ public void doJob() { try { JSONObject wiseStatisticsJSONObject = new JSONObject(); wiseStatisticsJSONObject.put("wiseName", wiseProperties.getProperty("wise.name")); - wiseStatisticsJSONObject.put("wiseBaseURL", wiseProperties.getProperty("wiseBaseURL")); PortalStatistics latestPortalStatistics = portalStatisticsService.getLatestPortalStatistics(); wiseStatisticsJSONObject.put("portal", latestPortalStatistics.getJSONObject()); @@ -680,7 +679,6 @@ public void postStatistics(String wiseStatisticsString) { List urlParameters = new ArrayList(); urlParameters.add(new BasicNameValuePair("name", wiseProperties.getProperty("wise.name"))); - urlParameters.add(new BasicNameValuePair("wiseBaseURL", wiseProperties.getProperty("wiseBaseURL"))); urlParameters.add(new BasicNameValuePair("stats", wiseStatisticsString)); try { diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/InformationController.java b/src/main/java/org/wise/portal/presentation/web/controllers/InformationController.java index 8c31e4ffe5..420636b351 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/InformationController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/InformationController.java @@ -136,14 +136,13 @@ public void handleGetConfigWISE4(HttpServletRequest request, HttpServletResponse throws ObjectNotFoundException, IOException { User signedInUser = ControllerUtil.getSignedInUser(); String mode = request.getParameter("mode"); - - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = request.getContextPath(); JSONObject config = new JSONObject(); String projectIdString = request.getParameter("projectId"); // if projectId provided, this is a request for preview if (projectIdString != null) { Project project = projectService.getById(Long.parseLong(projectIdString)); - addPreviewConfigParametersWISE4(request, signedInUser, mode, wiseBaseURL, config, project); + addPreviewConfigParametersWISE4(request, signedInUser, mode, contextPath, config, project); printConfigToResponse(response, config); return; } @@ -155,7 +154,7 @@ public void handleGetConfigWISE4(HttpServletRequest request, HttpServletResponse if (workgroup == null && signedInUser == null && !signedInUser.isAdmin()) { return; } - addRunConfigParametersWISE4(request, signedInUser, mode, wiseBaseURL, config, runId, run, workgroup); + addRunConfigParametersWISE4(request, signedInUser, mode, contextPath, config, runId, run, workgroup); printConfigToResponse(response, config); return; } @@ -219,18 +218,19 @@ public void handleGetConfigWISE5ClassroomMonitor(HttpServletRequest request, getRunConfigParameters(request, config, run); User signedInUser = ControllerUtil.getSignedInUser(); - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = request.getContextPath(); + if (hasRunReadAccess(signedInUser, run)) { config.put("runCode", run.getRuncode()); - config.put("teacherDataURL", wiseBaseURL + "/teacher/data"); - config.put("runDataExportURL", wiseBaseURL + "/teacher/export"); - config.put("studentNotebookURL", wiseBaseURL + "/teacher/notebook/" + runId); + config.put("teacherDataURL", contextPath + "/teacher/data"); + config.put("runDataExportURL", contextPath + "/teacher/export"); + config.put("studentNotebookURL", contextPath + "/teacher/notebook/" + runId); } Project project = run.getProject(); if (hasRunWriteAccess(signedInUser, run)) { String projectId = project.getId().toString(); - String saveProjectURL = wiseBaseURL + "/project/save/" + projectId; + String saveProjectURL = contextPath + "/project/save/" + projectId; config.put("saveProjectURL", saveProjectURL); } @@ -444,7 +444,7 @@ private JSONArray getPeriodsJSONArray(Run run) { private void addPreviewConfigParametersWISE4( HttpServletRequest request, User signedInUser, String mode, - String wiseBaseURL, JSONObject config, Project project) { + String contextPath, JSONObject config, Project project) { try { config.put("runId", ""); config.put("runName", ""); @@ -462,11 +462,11 @@ private void addPreviewConfigParametersWISE4( } catch (JSONException e) { e.printStackTrace(); } - addCommonConfigParametersWISE4(request, signedInUser, mode, wiseBaseURL, config, project); + addCommonConfigParametersWISE4(request, signedInUser, mode, contextPath, config, project); } private void addRunConfigParametersWISE4(HttpServletRequest request, User signedInUser, - String mode, String wiseBaseURL, JSONObject config, String runId, Run run, Workgroup workgroup) { + String mode, String contextPath, JSONObject config, String runId, Run run, Workgroup workgroup) { Long workgroupId = null; Long periodId = null; if (workgroup != null && workgroup.isStudentWorkgroup()) { @@ -482,47 +482,46 @@ private void addRunConfigParametersWISE4(HttpServletRequest request, User signed config.put("runId", Long.parseLong(runId)); config.put("runName", run.getName()); config.put("isRunActive", !run.isEnded()); - config.put("flagsURL", wiseBaseURL + "/annotation?type=flag&runId=" + runId); - config.put("inappropriateFlagsURL", wiseBaseURL + "/annotation?type=inappropriateFlag&runId=" + runId); - config.put("annotationsURL", wiseBaseURL + "/annotation?type=annotation&runId=" + runId); - config.put("studentDataURL", wiseBaseURL + "/studentData.html"); + config.put("flagsURL", contextPath + "/annotation?type=flag&runId=" + runId); + config.put("inappropriateFlagsURL", contextPath + "/annotation?type=inappropriateFlag&runId=" + runId); + config.put("annotationsURL", contextPath + "/annotation?type=annotation&runId=" + runId); + config.put("studentDataURL", contextPath + "/studentData.html"); config.put("gradingType", request.getParameter("gradingType")); config.put("getRevisions", request.getParameter("getRevisions")); - config.put("peerReviewURL", wiseBaseURL + "/peerReview.html?type=peerreview"); - config.put("ideaBasketURL", getIdeaBasketURL(runId, wiseBaseURL, run, periodId, workgroupId)); - config.put("portfolioURL", getPortfolioURL(runId, wiseBaseURL, periodId, workgroupId)); - config.put("studentAssetManagerURL", wiseBaseURL + "/assetManager?type=studentAssetManager&runId=" + runId); + config.put("peerReviewURL", contextPath + "/peerReview.html?type=peerreview"); + config.put("ideaBasketURL", getIdeaBasketURL(runId, contextPath, run, periodId, workgroupId)); + config.put("portfolioURL", getPortfolioURL(runId, contextPath, periodId, workgroupId)); + config.put("studentAssetManagerURL", contextPath + "/assetManager?type=studentAssetManager&runId=" + runId); config.put("runInfo", run.getInfo()); config.put("isRealTimeEnabled", true); // TODO: make this run-specific setting - config.put("webSocketURL", getWebSocketURL(request, wiseBaseURL)); - config.put("studentStatusURL", wiseBaseURL + "/studentStatus"); - config.put("runStatusURL", wiseBaseURL + "/runStatus"); + config.put("webSocketURL", getWebSocketURL(request, contextPath)); + config.put("studentStatusURL", contextPath + "/studentStatus"); + config.put("runStatusURL", contextPath + "/runStatus"); config.put("postLevel", run.getPostLevel()); - config.put("userInfoURL", wiseBaseURL + "/userInfo?runId=" + runId); + config.put("userInfoURL", contextPath + "/userInfo?runId=" + runId); if ("grading".equals(mode)) { - config.put("premadeCommentsURL", wiseBaseURL + "/teacher/grading/premadeComments.html"); - config.put("getXLSExportURL", wiseBaseURL + "/export?type=xlsexport&runId=" + runId); - config.put("getSpecialExportURL", wiseBaseURL + "/specialExport?type=specialExport&runId=" + runId); - config.put("getStudentListURL", wiseBaseURL + "/teacher/management/studentListExport?runId=" + runId); + config.put("premadeCommentsURL", contextPath + "/teacher/grading/premadeComments.html"); + config.put("getXLSExportURL", contextPath + "/export?type=xlsexport&runId=" + runId); + config.put("getSpecialExportURL", contextPath + "/specialExport?type=specialExport&runId=" + runId); + config.put("getStudentListURL", contextPath + "/teacher/management/studentListExport?runId=" + runId); } } catch (JSONException e) { e.printStackTrace(); } Project project = run.getProject(); - addCommonConfigParametersWISE4(request, signedInUser, mode, wiseBaseURL, config, project); + addCommonConfigParametersWISE4(request, signedInUser, mode, contextPath, config, project); } private void addCommonConfigParametersWISE4( HttpServletRequest request, User signedInUser, String mode, - String wiseBaseURL, JSONObject config, Project project) { + String contextPath, JSONObject config, Project project) { assert project != null; try { - config.put("wiseBaseURL", wiseBaseURL); - String contextPath = request.getContextPath(); + config.put("wiseBaseURL", contextPath); config.put("contextPath", contextPath); config.put("mode", mode); - config.put("projectMetadataURL", wiseBaseURL + "/metadata.html"); + config.put("projectMetadataURL", contextPath + "/metadata.html"); String curriculumBaseWWW = wiseProperties.getProperty("curriculum_base_www"); String rawProjectUrl = project.getModulePath(); String projectURL = curriculumBaseWWW + rawProjectUrl; @@ -532,9 +531,9 @@ private void addCommonConfigParametersWISE4( addProjectBaseURL(config, projectURL); config.put("studentUploadsBaseURL", wiseProperties.getProperty("studentuploads_base_www")); config.put("theme", "WISE"); - config.put("cRaterRequestURL", wiseBaseURL + "/cRater"); + config.put("cRaterRequestURL", contextPath + "/cRater"); config.put("mainHomePageURL", contextPath); - config.put("renewSessionURL", wiseBaseURL + "/session/renew"); + config.put("renewSessionURL", contextPath + "/session/renew"); config.put("sessionLogOutURL", contextPath + "/logout"); addStep(request, config); setUserLocale(request, signedInUser, config); @@ -555,8 +554,8 @@ private void addStep(HttpServletRequest request, JSONObject config) throws JSONE } } - private String getPortfolioURL(String runId, String wiseBaseURL, Long periodId, Long workgroupId) { - String portfolioURL = wiseBaseURL + "/portfolio?runId=" + runId; + private String getPortfolioURL(String runId, String contextPath, Long periodId, Long workgroupId) { + String portfolioURL = contextPath + "/portfolio?runId=" + runId; if (periodId != null) { portfolioURL += "&periodId=" + periodId; } @@ -566,8 +565,8 @@ private String getPortfolioURL(String runId, String wiseBaseURL, Long periodId, return portfolioURL; } - private String getIdeaBasketURL(String runId, String wiseBaseURL, Run run, Long periodId, Long workgroupId) { - String ideaBasketURL = wiseBaseURL + "/ideaBasket?runId=" + runId + "&projectId=" + run.getProject().getId().toString(); + private String getIdeaBasketURL(String runId, String contextPath, Run run, Long periodId, Long workgroupId) { + String ideaBasketURL = contextPath + "/ideaBasket?runId=" + runId + "&projectId=" + run.getProject().getId().toString(); if (periodId != null) { ideaBasketURL += "&periodId=" + periodId; } @@ -585,11 +584,11 @@ private String getIdeaBasketURL(String runId, String wiseBaseURL, Run run, Long * e.g. * ws://localhost:8080/wise */ - private String getWebSocketURL(HttpServletRequest request, String wiseBaseURL) { + private String getWebSocketURL(HttpServletRequest request, String contextPath) { String webSocketBaseURL = wiseProperties.getProperty("webSocketBaseUrl"); if (webSocketBaseURL == null) { - if (wiseBaseURL.contains("http")) { - webSocketBaseURL = wiseBaseURL.replace("http", "ws"); + if (contextPath.contains("http")) { + webSocketBaseURL = contextPath.replace("http", "ws"); } else { String portalContextPath = ControllerUtil.getPortalUrlString(request); webSocketBaseURL = portalContextPath.replace("http", "ws"); @@ -664,26 +663,26 @@ private void setUserLocale(HttpServletRequest request, User signedInUser, JSONOb private void getRunConfigParameters(HttpServletRequest request, JSONObject config, Run run) throws JSONException, ObjectNotFoundException { - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = request.getContextPath(); Long runId = run.getId(); - String annotationsURL = wiseBaseURL + "/annotation?type=annotation&runId=" + runId; - String studentStatusURL = wiseBaseURL + "/studentStatus"; - String runStatusURL = wiseBaseURL + "/runStatus"; + String annotationsURL = contextPath + "/annotation?type=annotation&runId=" + runId; + String studentStatusURL = contextPath + "/studentStatus"; + String runStatusURL = contextPath + "/runStatus"; config.put("runName", run.getName()); config.put("runId", runId); config.put("annotationsURL", annotationsURL); config.put("runInfo", run.getInfo()); config.put("isRealTimeEnabled", run.isRealTimeEnabled()); - config.put("webSocketURL", getWebSocketURL(request, wiseBaseURL)); + config.put("webSocketURL", getWebSocketURL(request, contextPath)); config.put("studentStatusURL", studentStatusURL); config.put("runStatusURL", runStatusURL); config.put("userInfo", getUserInfo(run)); - config.put("studentDataURL", wiseBaseURL + "/student/data"); // the url to get/post student data - config.put("studentAssetsURL", wiseBaseURL + "/student/asset/" + runId); - config.put("studentNotebookURL", wiseBaseURL + "/student/notebook/" + runId); - config.put("achievementURL", wiseBaseURL + "/achievement/" + runId); - config.put("notificationURL", wiseBaseURL + "/notification/" + runId); + config.put("studentDataURL", contextPath + "/student/data"); // the url to get/post student data + config.put("studentAssetsURL", contextPath + "/student/asset/" + runId); + config.put("studentNotebookURL", contextPath + "/student/notebook/" + runId); + config.put("achievementURL", contextPath + "/achievement/" + runId); + config.put("notificationURL", contextPath + "/notification/" + runId); String openCPUURL = wiseProperties.getProperty("openCPUURL"); if (openCPUURL != null) { config.put("openCPUURL", openCPUURL); @@ -729,21 +728,19 @@ private void addCommonConfigParameters( String curriculumBaseWWW = wiseProperties.getProperty("curriculum_base_www"); String projectURL = curriculumBaseWWW + rawProjectUrl; - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); - config.put("wiseBaseURL", wiseBaseURL); + String contextPath = request.getContextPath(); + config.put("wiseBaseURL", contextPath); config.put("projectId", project.getId()); config.put("parentProjectId", project.getParentProjectId()); - config.put("previewProjectURL", wiseBaseURL + "/project/" + project.getId()); + config.put("previewProjectURL", contextPath + "/project/" + project.getId()); config.put("theme", "WISE"); config.put("projectURL", projectURL); addProjectBaseURL(config, projectURL); config.put("studentUploadsBaseURL", wiseProperties.getProperty("studentuploads_base_www")); - config.put("cRaterRequestURL", wiseBaseURL + "/cRater"); - - String contextPath = request.getContextPath(); //get the context path e.g. /wise + config.put("cRaterRequestURL", contextPath + "/cRater"); config.put("contextPath", contextPath); config.put("mainHomePageURL", contextPath); - config.put("renewSessionURL", wiseBaseURL + "/session/renew"); + config.put("renewSessionURL", contextPath + "/session/renew"); config.put("sessionLogOutURL", contextPath + "/logout"); User signedInUser = ControllerUtil.getSignedInUser(); diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/StatisticsController.java b/src/main/java/org/wise/portal/presentation/web/controllers/StatisticsController.java index 8562b2ef5b..5725db22ac 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/StatisticsController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/StatisticsController.java @@ -118,10 +118,6 @@ protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpSer return null; } else { ModelAndView modelAndView = new ModelAndView(); - - //add the wise base url to the model so the jsp can access it - modelAndView.addObject("wiseBaseURL", wiseProperties.getProperty("wiseBaseURL")); - return modelAndView; } } diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/VLEController.java b/src/main/java/org/wise/portal/presentation/web/controllers/VLEController.java index 5add832f93..b9763b4cc5 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/VLEController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/VLEController.java @@ -23,11 +23,6 @@ */ package org.wise.portal.presentation.web.controllers; -import java.util.Properties; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; @@ -37,8 +32,12 @@ import org.springframework.web.servlet.ModelAndView; import org.wise.portal.dao.ObjectNotFoundException; import org.wise.portal.domain.run.Run; -import org.wise.portal.service.run.RunService; import org.wise.portal.service.project.ProjectService; +import org.wise.portal.service.run.RunService; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Properties; /** * Controller for handling student VLE-portal interactions. @@ -63,13 +62,13 @@ protected ModelAndView launchVLEWISE4Run(HttpServletRequest request, HttpServlet throws Exception { String runIdString = request.getParameter("runId"); Run run = runService.retrieveById(Long.parseLong(runIdString)); - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = request.getContextPath(); ModelAndView modelAndView = new ModelAndView("vle"); modelAndView.addObject("run", run); - modelAndView.addObject("vleurl", wiseBaseURL + "/vle/vle.html"); + modelAndView.addObject("vleurl", contextPath + "/vle/vle.html"); modelAndView.addObject("vleConfigUrl", - wiseBaseURL + "/vleconfig?runId=" + run.getId() + "&mode=run"); + contextPath + "/vleconfig?runId=" + run.getId() + "&mode=run"); String curriculumBaseWWW = wiseProperties.getProperty("curriculum_base_www"); String rawProjectUrl = run.getProject().getModulePath(); String contentUrl = curriculumBaseWWW + rawProjectUrl; @@ -78,20 +77,20 @@ protected ModelAndView launchVLEWISE4Run(HttpServletRequest request, HttpServlet } @RequestMapping(value = "/student/run/{runId}") - protected String launchVLEWISE5Run(@PathVariable Long runId, ModelMap modelMap) { - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); - modelMap.put("configURL", wiseBaseURL + "/config/studentRun/" + runId); + protected String launchVLEWISE5Run(HttpServletRequest request, @PathVariable Long runId, ModelMap modelMap) { + String contextPath = request.getContextPath(); + modelMap.put("configURL", contextPath + "/config/studentRun/" + runId); return "student"; } @RequestMapping(value = "/project/{projectId}", method = RequestMethod.GET) - protected String launchVLEWISE5Preview(@PathVariable String projectId, ModelMap modelMap) { + protected String launchVLEWISE5Preview(HttpServletRequest request, @PathVariable String projectId, ModelMap modelMap) { try { if (!"demo".equals(projectId)) { projectService.getById(Long.parseLong(projectId)); } - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); - modelMap.put("configURL", wiseBaseURL + "/config/preview/" + projectId); + String contextPath = request.getContextPath(); + modelMap.put("configURL", contextPath + "/config/preview/" + projectId); return "student"; } catch (ObjectNotFoundException onfe) { onfe.printStackTrace(); diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/admin/FindProjectRunsController.java b/src/main/java/org/wise/portal/presentation/web/controllers/admin/FindProjectRunsController.java index 5e99b6bfd0..b5d15079d4 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/admin/FindProjectRunsController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/admin/FindProjectRunsController.java @@ -31,8 +31,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import org.wise.portal.dao.ObjectNotFoundException; import org.wise.portal.domain.project.Project; @@ -43,15 +45,13 @@ import org.wise.portal.service.user.UserService; /** - * Controller to find project runs for admin users + * Controller for admins to find project runs * @author Patrick Lawler */ @Controller @RequestMapping("/admin/run/manageprojectruns.html") public class FindProjectRunsController { - private final static String VIEW = "admin/run/manageprojectruns"; - @Autowired private RunService runService; @@ -64,41 +64,29 @@ public class FindProjectRunsController { @Autowired private Properties wiseProperties; - @RequestMapping(method=RequestMethod.GET) - protected ModelAndView handleGET( - HttpServletRequest request) { - - ModelAndView modelAndView = new ModelAndView(); + @RequestMapping(method = RequestMethod.GET) + protected String findRun( + @RequestParam(value = "runLookupType", required = true) String runLookupType, + @RequestParam(value = "runLookupValue", required = true) String runLookupValue, + ModelMap modelMap) { List runList = new ArrayList(); - - // check if runLookupType was passed in, can be ["runId","projectId","teacherUsername"] - String runLookupType = request.getParameter("runLookupType"); - String runLookupValue = request.getParameter("runLookupValue"); - - if (runLookupType != null && runLookupValue != null) { - if ("runId".equals(runLookupType)) { - runList = this.getRunListByRunId(Long.parseLong(runLookupValue)); - } else if ("projectId".equals(runLookupType)) { - runList = this.getRunListByProjectId(Long.parseLong(runLookupValue)); - } else if ("teacherUsername".equals(runLookupType)) { - runList = this.getRunListByUsername(runLookupValue); - } else if ("runTitle".equals(runLookupType)) { - runList = this.getRunListByRunTitle(runLookupValue); - } + if ("runId".equals(runLookupType)) { + runList = this.getRunListByRunId(Long.parseLong(runLookupValue)); + } else if ("projectId".equals(runLookupType)) { + runList = this.getRunListByProjectId(Long.parseLong(runLookupValue)); + } else if ("teacherUsername".equals(runLookupType)) { + runList = this.getRunListByUsername(runLookupValue); + } else if ("runTitle".equals(runLookupType)) { + runList = this.getRunListByRunTitle(runLookupValue); } - - modelAndView = new ModelAndView(VIEW); - modelAndView.addObject("runList", runList); - - String isRealTimeEnabledStr = wiseProperties.getProperty("isRealTimeEnabled", "false"); - modelAndView.addObject("isRealTimeEnabled", Boolean.valueOf(isRealTimeEnabledStr)); - - return modelAndView; + modelMap.put("runList", runList); + return "admin/run/manageprojectruns"; } /** * Returns a List list of any runs that are - * associated with the given Long project id. + * associated with the given Long project id, including runs that were made + * using copies of the project * * @param projectId * @return List - list of runs associated with the projectId @@ -147,17 +135,14 @@ private List getRunListByUsername(String username) { */ private List getRunListByRunId(Long runId) { List runList = new ArrayList(); - try { Run run = this.runService.retrieveById(runId); - if (run != null) { runList.add(run); } } catch(ObjectNotFoundException e) { e.printStackTrace(); } - return runList; } diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/admin/UserInfoController.java b/src/main/java/org/wise/portal/presentation/web/controllers/admin/UserInfoController.java index 322f62328a..b6859b326e 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/admin/UserInfoController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/admin/UserInfoController.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2007-2017 Regents of the University of California (Regents). + * Copyright (c) 2007-2018 Regents of the University of California (Regents). * Created by WISE, Graduate School of Education, University of California, Berkeley. * * This software is distributed under the GNU General Public License, v3, @@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; @@ -43,7 +44,8 @@ import org.wise.portal.service.user.UserService; /** - * Controller for displaying user information + * Controller for displaying user information to admin users + * and student information to their teachers * @author Sally Ahn */ @Controller @@ -61,34 +63,29 @@ public class UserInfoController { protected final static String USER_INFO_MAP = "userInfoMap"; @RequestMapping(value = {"/student/account/info", "/teacher/account/info"}) - protected ModelAndView handleGetUserAccountInfo( - @RequestParam("userName") String userName) throws Exception { + protected String getUserAccountInfo( + @RequestParam("userName") String userName, + ModelMap modelMap) throws Exception { User signedInUser = ControllerUtil.getSignedInUser(); - User infoUser = this.userService.retrieveUserByUsername(userName); + User user = this.userService.retrieveUserByUsername(userName); if (signedInUser.isAdmin() || - this.studentService.isStudentAssociatedWithTeacher(infoUser, signedInUser)) { - MutableUserDetails userDetails = (MutableUserDetails) infoUser.getUserDetails(); - ModelAndView modelAndView = new ModelAndView(); - + this.studentService.isStudentAssociatedWithTeacher(user, signedInUser)) { + MutableUserDetails userDetails = (MutableUserDetails) user.getUserDetails(); HashMap userInfoMap = userDetails.getInfo(); - userInfoMap.put("ID", infoUser.getId()); - modelAndView.addObject(USER_INFO_MAP, userInfoMap); - - if (infoUser.getUserDetails().hasGrantedAuthority(UserDetailsService.STUDENT_ROLE)) { - modelAndView.addObject("isStudent", true); - List runList = runService.getRunList(infoUser); - modelAndView.addObject("runList", runList); - modelAndView.setViewName("student/account/info"); + userInfoMap.put("ID", user.getId()); + modelMap.put(USER_INFO_MAP, userInfoMap); + if (user.getUserDetails().hasGrantedAuthority(UserDetailsService.STUDENT_ROLE)) { + modelMap.put("isStudent", true); + modelMap.put("runList", runService.getRunList(user)); + return "student/account/info"; } else { - modelAndView.addObject("isStudent", false); - List runListByOwner = runService.getRunListByOwner(infoUser); - modelAndView.addObject("runList", runListByOwner); - modelAndView.setViewName("teacher/account/info"); + modelMap.put("isStudent", false); + modelMap.put("runList", runService.getRunListByOwner(user)); + return "teacher/account/info"; } - return modelAndView; } else { - return new ModelAndView("errors/accessdenied"); + return "errors/accessdenied"; } } } diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/admin/ViewAllUsersController.java b/src/main/java/org/wise/portal/presentation/web/controllers/admin/ViewAllUsersController.java index 947dd6fd81..05682e33ec 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/admin/ViewAllUsersController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/admin/ViewAllUsersController.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2007-2015 Regents of the University of California (Regents). + * Copyright (c) 2007-2018 Regents of the University of California (Regents). * Created by WISE, Graduate School of Education, University of California, Berkeley. * * This software is distributed under the GNU General Public License, v3, @@ -30,7 +30,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -61,8 +60,6 @@ public class ViewAllUsersController{ @Autowired private DailyAdminJob adminJob; - protected static final String VIEW_NAME = "admin/account/manageusers"; - protected static final String TEACHERS = "teachers"; protected static final String STUDENTS = "students"; @@ -81,26 +78,19 @@ public class ViewAllUsersController{ private static final String LOGGED_IN_TEACHER_USERNAMES = "loggedInTeacherUsernames"; - /** - * @see org.springframework.web.servlet.mvc.AbstractController#handleRequestInternal(javax.servlet.http.HttpServletRequest, - * javax.servlet.http.HttpServletResponse) - */ @RequestMapping(method = RequestMethod.GET) @SuppressWarnings("unchecked") - protected String handleRequestInternal( - HttpServletRequest servletRequest, - ModelMap modelMap) throws Exception { - - String onlyShowLoggedInUser = servletRequest.getParameter("onlyShowLoggedInUser"); - String onlyShowUsersWhoLoggedIn = servletRequest.getParameter("onlyShowUsersWhoLoggedIn"); + protected String showUsers(HttpServletRequest request, ModelMap modelMap) throws Exception { + String onlyShowLoggedInUser = request.getParameter("onlyShowLoggedInUser"); + String onlyShowUsersWhoLoggedIn = request.getParameter("onlyShowUsersWhoLoggedIn"); if (onlyShowLoggedInUser != null && onlyShowLoggedInUser.equals("true")) { // get logged in users from servlet context HashMap allLoggedInUsers = - (HashMap) servletRequest.getSession() + (HashMap) request.getSession() .getServletContext().getAttribute(WISESessionListener.ALL_LOGGED_IN_USERS); HashMap studentsToRunIds = - (HashMap) servletRequest.getSession() + (HashMap) request.getSession() .getServletContext().getAttribute("studentsToRunIds"); ArrayList loggedInStudent = new ArrayList(); @@ -166,20 +156,18 @@ protected String handleRequestInternal( modelMap.put("teachersWhoLoggedInSince", teachersWhoLoggedInSince); } else { // result depends on passed-in userType parameter - String userType = servletRequest.getParameter(USER_TYPE); + String userType = request.getParameter(USER_TYPE); if (userType == null) { List allUsernames = this.userService.retrieveAllUsernames(); modelMap.put(USERNAMES, allUsernames); } else if (userType.equals(STUDENT)) { - List usernames = this.userDetailsService.retrieveAllUsernames(StudentUserDetails.class.getName()); modelMap.put(STUDENTS, usernames); } else if (userType.equals(TEACHER)) { List usernames = this.userDetailsService.retrieveAllUsernames(TeacherUserDetails.class.getName()); - modelMap.put(TEACHERS, usernames); } } - return VIEW_NAME; + return "admin/account/manageusers"; } } diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/author/project/AuthorProjectController.java b/src/main/java/org/wise/portal/presentation/web/controllers/author/project/AuthorProjectController.java index fbe1dc5f11..e1562093ae 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/author/project/AuthorProjectController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/author/project/AuthorProjectController.java @@ -23,22 +23,6 @@ */ package org.wise.portal.presentation.web.controllers.author.project; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -77,6 +61,15 @@ import org.wise.vle.web.AssetManager; import org.wise.vle.web.SecurityUtils; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.File; +import java.io.IOException; +import java.util.*; + /** * Controller for users with author privileges to author WISE4 projects * @@ -812,10 +805,10 @@ protected ModelAndView handleConvertRequestInternal( */ private ModelAndView handleLaunchAuthoring(HttpServletRequest request) { User author = ControllerUtil.getSignedInUser(); - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = request.getContextPath(); - String vleUrl = wiseBaseURL + "/vle/author.html"; - String portalAuthorUrl = wiseBaseURL + "/author/authorproject.html"; + String vleUrl = contextPath + "/vle/author.html"; + String portalAuthorUrl = contextPath + "/author/authorproject.html"; String command = request.getParameter("param1"); String projectIdStr = request.getParameter(PROJECT_ID_PARAM_NAME); @@ -1469,32 +1462,29 @@ private ModelAndView handleGetConfig(HttpServletRequest request, HttpServletResp //get the username String username = user.getUserDetails().getUsername(); - //get the wise base url - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); - //get the context path e.g. /wise String contextPath = request.getContextPath(); //get the url to get and post metadata - String projectMetadataURL = wiseBaseURL + "/metadata.html"; + String projectMetadataURL = contextPath + "/metadata.html"; //get the url to make CRater requests - String cRaterRequestURL = wiseBaseURL + "/cRater"; + String cRaterRequestURL = contextPath + "/cRater"; //get the curriculum_base_www variable from the wise.properties file String curriculumBaseUrl = wiseProperties.getProperty("curriculum_base_www"); //get the url to preview project - String previewProjectUrl = wiseBaseURL + "/previewproject.html"; + String previewProjectUrl = contextPath + "/previewproject.html"; //get the url to make CRater requests - String deleteProjectUrl = wiseBaseURL + "/teacher/projects/deleteproject.html"; + String deleteProjectUrl = contextPath + "/teacher/projects/deleteproject.html"; //get the url to make analyze project requests - String analyzeProjectUrl = wiseBaseURL + "/teacher/projects/analyzeproject.html"; + String analyzeProjectUrl = contextPath + "/teacher/projects/analyzeproject.html"; //the get/post url for premade comments - String premadeCommentsURL = wiseBaseURL + "/teacher/grading/premadeComments.html"; + String premadeCommentsURL = contextPath + "/teacher/grading/premadeComments.html"; //create a JSONObject to contain the config params JSONObject config = new JSONObject(); @@ -1504,7 +1494,7 @@ private ModelAndView handleGetConfig(HttpServletRequest request, HttpServletResp config.put("username", username); config.put("projectMetadataURL", projectMetadataURL); config.put("curriculumBaseUrl", curriculumBaseUrl); - config.put("indexURL", wiseBaseURL + WISEAuthenticationProcessingFilter.TEACHER_DEFAULT_TARGET_PATH); + config.put("indexURL", contextPath + WISEAuthenticationProcessingFilter.TEACHER_DEFAULT_TARGET_PATH); int maxInactiveInterval = request.getSession().getMaxInactiveInterval() * 1000; config.put("sessionTimeoutInterval", maxInactiveInterval); // add sessiontimeout interval, in milleseconds int sessionTimeoutCheckInterval = maxInactiveInterval / 20; // check 20 times during the session. @@ -1519,7 +1509,7 @@ private ModelAndView handleGetConfig(HttpServletRequest request, HttpServletResp config.put("deleteProjectUrl", deleteProjectUrl); config.put("analyzeProjectUrl", analyzeProjectUrl); config.put("premadeCommentsURL", premadeCommentsURL); - config.put("wiseBaseURL", wiseBaseURL); + config.put("wiseBaseURL", contextPath); config.put("contextPath", contextPath); // if projectId provided, this is a request for preview diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/author/project/WISE5AuthorProjectController.java b/src/main/java/org/wise/portal/presentation/web/controllers/author/project/WISE5AuthorProjectController.java index ea91bbaac1..44922ea77c 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/author/project/WISE5AuthorProjectController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/author/project/WISE5AuthorProjectController.java @@ -116,8 +116,8 @@ protected String authorProject(HttpServletRequest request, HttpServletResponse r // do nothing } - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); - modelMap.put("configURL", wiseBaseURL + "/authorConfig"); + String contextPath = request.getContextPath(); + modelMap.put("configURL", contextPath + "/authorConfig"); return "author"; } @@ -343,7 +343,7 @@ protected void getAuthorProjectConfig(HttpServletRequest request, HttpServletRes JSONObject config = getDefaultAuthoringConfigJsonObject(request); try { - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = request.getContextPath(); String curriculumBaseWWW = wiseProperties.getProperty("curriculum_base_www"); String rawProjectUrl = project.getModulePath(); String projectURL = curriculumBaseWWW + rawProjectUrl; @@ -358,16 +358,16 @@ protected void getAuthorProjectConfig(HttpServletRequest request, HttpServletRes config.put("projectId", projectId); config.put("projectURL", projectURL); config.put("projectAssetTotalSizeMax", projectAssetTotalSizeMax); - config.put("projectAssetURL", wiseBaseURL + "/project/asset/" + projectId); + config.put("projectAssetURL", contextPath + "/project/asset/" + projectId); config.put("projectBaseURL", projectBaseURL); - config.put("previewProjectURL", wiseBaseURL + "/project/" + projectId); - config.put("cRaterRequestURL", wiseBaseURL + "/cRater"); - config.put("importStepsURL", wiseBaseURL + "/project/importSteps/" + projectId); + config.put("previewProjectURL", contextPath + "/project/" + projectId); + config.put("cRaterRequestURL", contextPath + "/cRater"); + config.put("importStepsURL", contextPath + "/project/importSteps/" + projectId); config.put("mode", "author"); if (projectService.canAuthorProject(project, ControllerUtil.getSignedInUser())) { - config.put("saveProjectURL", wiseBaseURL + "/project/save/" + projectId); - config.put("commitProjectURL", wiseBaseURL + "/project/commit/" + projectId); + config.put("saveProjectURL", contextPath + "/project/save/" + projectId); + config.put("commitProjectURL", contextPath + "/project/commit/" + projectId); } Long runId = this.getRunId(projectId); @@ -390,18 +390,17 @@ private JSONObject getDefaultAuthoringConfigJsonObject(HttpServletRequest reques User user = ControllerUtil.getSignedInUser(); try { String contextPath = request.getContextPath(); - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); config.put("contextPath", contextPath); - config.put("copyProjectURL", wiseBaseURL + "/project/copy"); - config.put("mainHomePageURL", wiseBaseURL); - config.put("renewSessionURL", wiseBaseURL + "/session/renew"); - config.put("sessionLogOutURL", wiseBaseURL + "/logout"); - config.put("registerNewProjectURL", wiseBaseURL + "/project/new"); - config.put("wiseBaseURL", wiseBaseURL); - config.put("notifyProjectBeginURL", wiseBaseURL + "/project/notifyAuthorBegin/"); - config.put("notifyProjectEndURL", wiseBaseURL + "/project/notifyAuthorEnd/"); - config.put("getLibraryProjectsURL", wiseBaseURL + "/author/authorproject.html?command=projectList&projectPaths=&projectTag=library&wiseVersion=5"); - config.put("teacherDataURL", wiseBaseURL + "/teacher/data"); + config.put("copyProjectURL", contextPath + "/project/copy"); + config.put("mainHomePageURL", contextPath); + config.put("renewSessionURL", contextPath + "/session/renew"); + config.put("sessionLogOutURL", contextPath + "/logout"); + config.put("registerNewProjectURL", contextPath + "/project/new"); + config.put("wiseBaseURL", contextPath); + config.put("notifyProjectBeginURL", contextPath + "/project/notifyAuthorBegin/"); + config.put("notifyProjectEndURL", contextPath + "/project/notifyAuthorEnd/"); + config.put("getLibraryProjectsURL", contextPath + "/author/authorproject.html?command=projectList&projectPaths=&projectTag=library&wiseVersion=5"); + config.put("teacherDataURL", contextPath + "/teacher/data"); String projectMetadataSettings = null; try { @@ -503,8 +502,8 @@ private JSONObject getDefaultAuthoringConfigJsonObject(HttpServletRequest reques * e.g. * ws://localhost:8080/wise */ - if (wiseBaseURL.contains("http")) { - webSocketBaseURL = wiseBaseURL.replace("http", "ws"); + if (contextPath.contains("http")) { + webSocketBaseURL = contextPath.replace("http", "ws"); } else { String portalContextPath = ControllerUtil.getPortalUrlString(request); webSocketBaseURL = portalContextPath.replace("http", "ws"); diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/forgotaccount/teacher/ForgotAccountTeacherIndexController.java b/src/main/java/org/wise/portal/presentation/web/controllers/forgotaccount/teacher/ForgotAccountTeacherIndexController.java index f2aa62d359..fb13ecf0e8 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/forgotaccount/teacher/ForgotAccountTeacherIndexController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/forgotaccount/teacher/ForgotAccountTeacherIndexController.java @@ -23,14 +23,6 @@ */ package org.wise.portal.presentation.web.controllers.forgotaccount.teacher; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.Properties; -import java.util.regex.Pattern; - -import javax.servlet.http.HttpServletRequest; - import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -38,7 +30,6 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.ui.ModelMap; -import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -49,6 +40,13 @@ import org.wise.portal.service.mail.MailService; import org.wise.portal.service.user.UserService; +import javax.servlet.http.HttpServletRequest; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.Properties; +import java.util.regex.Pattern; + /** * Controller for lost password teacher username and email lookup * @@ -171,13 +169,13 @@ protected String onSubmit(@ModelAttribute("userDetails") TeacherUserDetails user * e.g. * http://wise4.berkeley.edu/wise/forgotaccount/resetpassword.html?k=1234567890abc */ - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = request.getContextPath(); String portalContextURL = ""; - if (wiseBaseURL.startsWith("http")) { - // in case wiseBaseURL is absolute, in the form "http://xyz:8080/wise" - portalContextURL = wiseBaseURL; + if (contextPath.startsWith("http")) { + // in case contextPath is absolute, in the form "http://xyz:8080/wise" + portalContextURL = contextPath; } else { - // in case wiseBaseURL is relative, in the form "/wise" + // in case contextPath is relative, in the form "/wise" portalContextURL = ControllerUtil.getPortalUrlString(request); } String passwordResetLink = portalContextURL + "/forgotaccount/resetpassword.html?k=" + randomAlphanumeric; diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/student/StartProjectController.java b/src/main/java/org/wise/portal/presentation/web/controllers/student/StartProjectController.java index 7450a91ebe..87938c6124 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/student/StartProjectController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/student/StartProjectController.java @@ -23,17 +23,6 @@ */ package org.wise.portal.presentation.web.controllers.student; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - import org.hibernate.StaleObjectStateException; import org.json.JSONArray; import org.springframework.beans.factory.annotation.Autowired; @@ -47,10 +36,15 @@ import org.wise.portal.domain.workgroup.Workgroup; import org.wise.portal.presentation.web.controllers.ControllerUtil; import org.wise.portal.service.attendance.StudentAttendanceService; -import org.wise.portal.service.run.RunService; import org.wise.portal.service.project.ProjectService; +import org.wise.portal.service.run.RunService; import org.wise.portal.service.workgroup.WorkgroupService; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.util.*; + /** * Controller to allow students to launch the VLE using the project. * This link is *always* used to start the project for students, whether: @@ -170,7 +164,7 @@ protected synchronized ModelAndView handleRequestInternal( // create a student attendance entry addStudentAttendanceEntry(workgroupId, runId, presentUserIds, absentUserIds); - return projectService.launchProject(workgroup); + return projectService.launchProject(workgroup, request.getContextPath()); } else { // need to create a workgroup for this user, take them to create workgroup wizard ModelAndView modelAndView = new ModelAndView(SELECT_TEAM_URL); @@ -219,7 +213,7 @@ protected synchronized ModelAndView handleRequestInternal( // update servlet session notifyServletSession(request, run); - return projectService.launchProject(workgroup); + return projectService.launchProject(workgroup, request.getContextPath()); } else { ModelAndView modelAndView = new ModelAndView(TEAM_SIGN_IN_URL); modelAndView.addObject("runId", runId); @@ -264,7 +258,7 @@ protected synchronized ModelAndView handleRequestInternal( // update servlet session notifyServletSession(request, run); - return projectService.launchProject(workgroup); + return projectService.launchProject(workgroup, request.getContextPath()); } else { ModelAndView modelAndView = new ModelAndView(TEAM_SIGN_IN_URL); modelAndView.addObject("runId", runId); diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/student/TeamSignInController.java b/src/main/java/org/wise/portal/presentation/web/controllers/student/TeamSignInController.java index 88ab7406de..dbe746cb07 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/student/TeamSignInController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/student/TeamSignInController.java @@ -23,17 +23,6 @@ */ package org.wise.portal.presentation.web.controllers.student; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.hibernate.StaleObjectStateException; import org.json.JSONArray; import org.springframework.beans.factory.annotation.Autowired; @@ -57,12 +46,16 @@ import org.wise.portal.presentation.web.controllers.ControllerUtil; import org.wise.portal.service.attendance.StudentAttendanceService; import org.wise.portal.service.group.GroupService; -import org.wise.portal.service.run.RunService; import org.wise.portal.service.project.ProjectService; +import org.wise.portal.service.run.RunService; import org.wise.portal.service.student.StudentService; import org.wise.portal.service.user.UserService; import org.wise.portal.service.workgroup.WorkgroupService; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.*; + /** * Controller for handling team sign-ins before students start the project. The first user * entered in the form must be already signed-in and associated with a specific @@ -333,7 +326,7 @@ protected synchronized String onSubmit(@ModelAttribute("teamSignInForm") TeamSig } StartProjectController.notifyServletSession(request, run); - ModelAndView modelAndView = projectService.launchProject(workgroup); + ModelAndView modelAndView = projectService.launchProject(workgroup, request.getContextPath()); // clear the command object from the session status.setComplete(); diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/teacher/TeacherAccountController.java b/src/main/java/org/wise/portal/presentation/web/controllers/teacher/TeacherAccountController.java index e8fafe6c22..5b229aab86 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/teacher/TeacherAccountController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/teacher/TeacherAccountController.java @@ -23,13 +23,6 @@ */ package org.wise.portal.presentation.web.controllers.teacher; -import java.util.Calendar; -import java.util.Locale; -import java.util.Properties; - -import javax.mail.MessagingException; -import javax.servlet.http.HttpServletRequest; - import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; @@ -55,6 +48,12 @@ import org.wise.portal.service.mail.IMailFacade; import org.wise.portal.service.user.UserService; +import javax.mail.MessagingException; +import javax.servlet.http.HttpServletRequest; +import java.util.Calendar; +import java.util.Locale; +import java.util.Properties; + /** * Controller for creating and updating WISE teacher accounts * @@ -171,7 +170,7 @@ protected String createNewTeacher( userDetails.setDisplayname(userDetails.getFirstname() + " " + userDetails.getLastname()); userDetails.setEmailValid(true); User createdUser = this.userService.createUser(userDetails); - NewAccountEmailService newAccountEmailService = new NewAccountEmailService(createdUser, request.getLocale()); + NewAccountEmailService newAccountEmailService = new NewAccountEmailService(createdUser, request.getLocale(), request); Thread thread = new Thread(newAccountEmailService); thread.start(); modelMap.addAttribute("username", userDetails.getUsername()); @@ -310,10 +309,12 @@ public boolean isOnRegisterNewTeacherPage(HttpServletRequest request) { class NewAccountEmailService implements Runnable { private User newUser; private Locale locale; + private HttpServletRequest request; - public NewAccountEmailService(User newUser, Locale locale) { + public NewAccountEmailService(User newUser, Locale locale, HttpServletRequest request) { this.newUser = newUser; this.locale = locale; + this.request = request; } public void run() { @@ -322,14 +323,14 @@ public void run() { if (!sendEmailEnabled) { return; } else { - this.sendEmail(); + this.sendEmail(this.request); } } /** * Sends a welcome email to the new user with WISE resources. */ - private void sendEmail() { + private void sendEmail(HttpServletRequest request) { TeacherUserDetails newUserDetails = (TeacherUserDetails) newUser.getUserDetails(); String userUsername = newUserDetails.getUsername(); String userEmailAddress[] = {newUserDetails.getEmailAddress()}; @@ -337,8 +338,8 @@ private void sendEmail() { wiseProperties.getProperty("uber_admin").split(",")); String defaultSubject = messageSource.getMessage("presentation.web.controllers.teacher.registerTeacherController.welcomeTeacherEmailSubject", null, Locale.US); String subject = messageSource.getMessage("presentation.web.controllers.teacher.registerTeacherController.welcomeTeacherEmailSubject", null, defaultSubject, this.locale); - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); - String gettingStartedUrl = wiseBaseURL + "/pages/gettingstarted.html"; + String portalString = ControllerUtil.getPortalUrlString(request); + String gettingStartedUrl = portalString + "/pages/gettingstarted.html"; String defaultBody = messageSource.getMessage("presentation.web.controllers.teacher.registerTeacherController.welcomeTeacherEmailBody", new Object[] {userUsername,gettingStartedUrl}, Locale.US); String message = messageSource.getMessage("presentation.web.controllers.teacher.registerTeacherController.welcomeTeacherEmailBody", new Object[] {userUsername,gettingStartedUrl}, defaultBody, this.locale); diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/teacher/grading/GradeWorkController.java b/src/main/java/org/wise/portal/presentation/web/controllers/teacher/grading/GradeWorkController.java index c1bffc4152..34aab1d47d 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/teacher/grading/GradeWorkController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/teacher/grading/GradeWorkController.java @@ -23,12 +23,6 @@ */ package org.wise.portal.presentation.web.controllers.teacher.grading; -import java.io.IOException; -import java.util.Properties; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -39,7 +33,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.view.RedirectView; import org.wise.portal.dao.ObjectNotFoundException; import org.wise.portal.domain.project.impl.ProjectType; import org.wise.portal.domain.run.Run; @@ -47,6 +40,11 @@ import org.wise.portal.presentation.web.controllers.ControllerUtil; import org.wise.portal.service.run.RunService; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Properties; + /** * A Controller for Grading Student Work * @@ -70,7 +68,7 @@ public class GradeWorkController { * @throws Exception */ @RequestMapping(value = "/classroomMonitor/{runId}") - protected ModelAndView launchClassroomMonitorWISE5(@PathVariable Integer runId) throws Exception { + protected ModelAndView launchClassroomMonitorWISE5(HttpServletRequest request, @PathVariable Integer runId) throws Exception { Run run = null; try { run = runService.retrieveById(new Long(runId)); @@ -87,8 +85,8 @@ protected ModelAndView launchClassroomMonitorWISE5(@PathVariable Integer runId) this.runService.hasRunPermission(run, user, BasePermission.WRITE) || this.runService.hasRunPermission(run, user, BasePermission.READ)) { - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); - String getClassroomMonitorConfigUrl = wiseBaseURL + "/config/classroomMonitor/" + runId; + String contextPath = request.getContextPath(); + String getClassroomMonitorConfigUrl = contextPath + "/config/classroomMonitor/" + runId; ModelAndView modelAndView = new ModelAndView("classroomMonitor"); modelAndView.addObject("configURL", getClassroomMonitorConfigUrl); @@ -137,14 +135,14 @@ protected ModelAndView handleRequestInternal( this.runService.hasRunPermission(run, user, BasePermission.WRITE) || this.runService.hasRunPermission(run, user, BasePermission.READ)) { - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = request.getContextPath(); - String getGradeWorkUrl = wiseBaseURL + "/vle/gradework.html"; - String getGradingConfigUrl = wiseBaseURL + "/vleconfig?runId=" + run.getId().toString() + "&gradingType=" + gradingType + "&mode=grading&getRevisions=" + getRevisions; + String getGradeWorkUrl = contextPath + "/vle/gradework.html"; + String getGradingConfigUrl = contextPath + "/vleconfig?runId=" + run.getId().toString() + "&gradingType=" + gradingType + "&mode=grading&getRevisions=" + getRevisions; // get the classroom monitor urls - String getClassroomMonitorUrl = wiseBaseURL + "/vle/classroomMonitor.html"; - String getClassroomMonitorConfigUrl = wiseBaseURL + "/vleconfig?runId=" + run.getId().toString() + "&gradingType=" + gradingType + "&mode=grading&getRevisions=" + getRevisions; + String getClassroomMonitorUrl = contextPath + "/vle/classroomMonitor.html"; + String getClassroomMonitorConfigUrl = contextPath + "/vleconfig?runId=" + run.getId().toString() + "&gradingType=" + gradingType + "&mode=grading&getRevisions=" + getRevisions; // set the permission variable so that we can access it in the .jsp if (this.runService.hasRunPermission(run, user, BasePermission.WRITE)) { diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/teacher/run/UpdateRunController.java b/src/main/java/org/wise/portal/presentation/web/controllers/teacher/run/UpdateRunController.java index b93724e4f5..1955792ecb 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/teacher/run/UpdateRunController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/teacher/run/UpdateRunController.java @@ -23,19 +23,11 @@ */ package org.wise.portal.presentation.web.controllers.teacher.run; -import java.util.Date; -import java.util.Properties; - -import javax.mail.MessagingException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.view.RedirectView; import org.wise.portal.domain.project.Project; import org.wise.portal.domain.run.Run; import org.wise.portal.domain.user.User; @@ -43,8 +35,14 @@ import org.wise.portal.presentation.web.exception.NotAuthorizedException; import org.wise.portal.service.authentication.UserDetailsService; import org.wise.portal.service.mail.IMailFacade; -import org.wise.portal.service.run.RunService; import org.wise.portal.service.project.ProjectService; +import org.wise.portal.service.run.RunService; + +import javax.mail.MessagingException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Date; +import java.util.Properties; /** * Controller for updating run settings, like add period, @@ -139,7 +137,7 @@ protected ModelAndView handlePOST(HttpServletRequest request, HttpServletRespons this.runService.updateSurvey(Long.parseLong(runId), survey); // send email to WISE staff with Survey - String linkToSurvey = wiseProperties.getProperty("wiseBaseURL")+"/teacher/run/survey.html?runId="+runId; + String linkToSurvey = ControllerUtil.getPortalUrlString(request)+"/teacher/run/survey.html?runId="+runId; String emailBody = user.getUserDetails().getUsername()+ " completed a survey for "+run.getName()+" (Run ID="+runId+").\n\nLink to view survey on WISE: "+linkToSurvey+"\n\n"+survey; EmailService emailService = new EmailService("Survey completed [Run ID="+runId+"]: "+run.getName(), emailBody); diff --git a/src/main/java/org/wise/portal/service/project/ProjectService.java b/src/main/java/org/wise/portal/service/project/ProjectService.java index 50369299d0..68922cad02 100644 --- a/src/main/java/org/wise/portal/service/project/ProjectService.java +++ b/src/main/java/org/wise/portal/service/project/ProjectService.java @@ -23,11 +23,6 @@ */ package org.wise.portal.service.project; -import java.io.IOException; -import java.io.Serializable; -import java.util.List; -import java.util.Set; - import org.springframework.security.access.annotation.Secured; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.ModelAndView; @@ -40,6 +35,11 @@ import org.wise.portal.domain.workgroup.Workgroup; import org.wise.portal.presentation.web.exception.NotAuthorizedException; +import java.io.IOException; +import java.io.Serializable; +import java.util.List; +import java.util.Set; + /** * A Service for Projects * @@ -152,7 +152,7 @@ void removeSharedTeacherFromProject(String username, Project project) * @return * @throws Exception */ - ModelAndView launchProject(Workgroup workgroup) throws Exception; + ModelAndView launchProject(Workgroup workgroup, String contextPath) throws Exception; /** * Launches a Preview of the Project. diff --git a/src/main/java/org/wise/portal/service/project/impl/ProjectServiceImpl.java b/src/main/java/org/wise/portal/service/project/impl/ProjectServiceImpl.java index 66c03c2b40..2be33dde87 100644 --- a/src/main/java/org/wise/portal/service/project/impl/ProjectServiceImpl.java +++ b/src/main/java/org/wise/portal/service/project/impl/ProjectServiceImpl.java @@ -301,8 +301,8 @@ public List getAdminProjectList() { /** * @see ProjectService#launchProject(Workgroup) */ - public ModelAndView launchProject(Workgroup workgroup) throws Exception { - return new ModelAndView(new RedirectView(generateStudentStartProjectUrlString(workgroup))); + public ModelAndView launchProject(Workgroup workgroup, String contextPath) throws Exception { + return new ModelAndView(new RedirectView(generateStudentStartProjectUrlString(workgroup, contextPath))); } /** @@ -313,20 +313,20 @@ public ModelAndView previewProject(PreviewProjectParameters params) throws Excep if (project.getWiseVersion().equals(4)) { return previewProjectWISE4(params, project); } else { - return previewProjectWISE5(project); + return previewProjectWISE5(params, project); } } - private ModelAndView previewProjectWISE5(Project project) { - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); - String wise5URL = wiseBaseURL + "/project/" + project.getId(); + private ModelAndView previewProjectWISE5(PreviewProjectParameters params, Project project) { + String contextPath = params.getHttpServletRequest().getContextPath(); + String wise5URL = contextPath + "/project/" + project.getId(); return new ModelAndView(new RedirectView(wise5URL)); } private ModelAndView previewProjectWISE4(PreviewProjectParameters params, Project project) { - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); + String contextPath = params.getHttpServletRequest().getContextPath(); String vleConfigUrl = - wiseBaseURL + "/vleconfig" + "?projectId=" + project.getId() + "&mode=preview"; + contextPath + "/vleconfig" + "?projectId=" + project.getId() + "&mode=preview"; String step = params.getStep(); if (step != null) { @@ -348,7 +348,7 @@ private ModelAndView previewProjectWISE4(PreviewProjectParameters params, Projec } ModelAndView modelAndView = new ModelAndView("vle"); - String vleurl = wiseBaseURL + "/vle/vle.html"; + String vleurl = contextPath + "/vle/vle.html"; modelAndView.addObject("vleurl", vleurl); modelAndView.addObject("vleConfigUrl", vleConfigUrl); String curriculumBaseWWW = wiseProperties.getProperty("curriculum_base_www"); @@ -393,15 +393,14 @@ public void updateProject(Project project, User user) throws NotAuthorizedExcept * @param workgroup Workgroup requesting to launch the project * @return url string that, when accessed, will launch the project */ - public String generateStudentStartProjectUrlString(Workgroup workgroup) { + public String generateStudentStartProjectUrlString(Workgroup workgroup, String contextPath) { Run run = workgroup.getRun(); Project project = run.getProject(); Integer wiseVersion = project.getWiseVersion(); - String wiseBaseURL = wiseProperties.getProperty("wiseBaseURL"); if (wiseVersion.equals(4)) { - return wiseBaseURL + "/student/vle/vle.html?runId=" + run.getId() + "&workgroupId=" + workgroup.getId(); + return contextPath + "/student/vle/vle.html?runId=" + run.getId() + "&workgroupId=" + workgroup.getId(); } else if (wiseVersion.equals(5)) { - return wiseBaseURL + "/student/run/" + run.getId(); + return contextPath + "/student/run/" + run.getId(); } return null; } diff --git a/src/main/resources/version.txt b/src/main/resources/version.txt index 6ab7204dab..bdbab22610 100644 --- a/src/main/resources/version.txt +++ b/src/main/resources/version.txt @@ -1 +1 @@ -5.7.5 +5.7.6 diff --git a/src/main/resources/wise_sample.properties b/src/main/resources/wise_sample.properties index 92c390f0df..94260be5a0 100644 --- a/src/main/resources/wise_sample.properties +++ b/src/main/resources/wise_sample.properties @@ -3,7 +3,7 @@ # This section is for portal definitions # NOTE FOR WINDOWS USERS: you can use paths like this: C:/apache-tomcat-7.0.32/webapps/curriculum instead of C:\.... # wise.name - name this WISE instance. Used when sending email to users. (e.g. "Hello from My Local WISE Instance", "Password changed on My Local WISE Instance") -# defaultLocale - the default locale for this WISE instance. [en, es, he, zh_CN,...] First-time users will see WISE in this locale when they visit the homepage. +# defaultLocale - the default locale for this WISE instance. [en, es, he, zh_CN,...] First-time users will see WISE in this locale when they visit the homepage. # wiseBaseURL - hosted wise location, viewable by browser. ex: if running locally, http://localhost:8080/wise. if running publicly, http://wise4.xyz.com:8080/wise, etc. # wiseBaseDir - absolute server path to the wise folder in CATALINA_HOME/webapps/wise. ex: /home/userx/apache-tomcat-6.0.29/webapps/wise # curriculum_base_www - hosted curriculum location, viewable by browser. ex: if running locally, http://localhost:8080/curriculum. if running publicly, http://wise4.xyz.com:8080/curriculum, etc. @@ -28,7 +28,6 @@ wise.name=My WISE Production Instance defaultLocale=en supportedLocales=en,ar,zh_TW,zh_CN,nl,fr,de,el,he,it,ja,ko,pt,es,th,tr -wiseBaseURL=http://localhost:8080/wise wiseBaseDir=/Users/wise/tomcat/webapps/wise curriculum_base_www=http://localhost:8080/curriculum curriculum_base_dir=/Users/wise/tomcat/webapps/curriculum @@ -70,7 +69,7 @@ hibernate.bytecode.use_reflection_optimizer=true hibernate.hbm2ddl.auto=none # Sample HSQLDB setting (for development server) -# You can also use HSQLDB embedded database, but it's not recommended for +# You can also use HSQLDB embedded database, but it's not recommended for # production/qa purposes. # Comment out the above MySQL section and uncomment the below. @@ -112,9 +111,9 @@ c3p0.idleConnectionTestPeriod=100 # - when a run is set up or shared # - when a project is shared # - daily reports for admins -# +# # One easy thing to do is create a gmail account and use it as an smtp server to send emails on behalf of the portal. -# With this approach, +# With this approach, # mail.user is the gmail username # mail.password is the gmail password # mail.from is the gmail address (ex xyz@gmail.com) @@ -167,12 +166,12 @@ cronJobExpression=0 0 0 * * ? ########## run codes prefixes ########## -# List available run codes for each locale here. -# Each line should follow this format runcode_prefixes_[locale]=comma separated values for runcode prefixes. +# List available run codes for each locale here. +# Each line should follow this format runcode_prefixes_[locale]=comma separated values for runcode prefixes. # For example, runcode_prefixes_en=urchin,lion for english, runcode_prefixes_es=queso,azul for spanish runcode_prefixes_en=Tiger,Lion,Fox,Owl,Panda,Hawk,Mole,Falcon,Orca,Eagle,Manta,Otter,Cat,Zebra,Flea,Wolf,Dragon,Seal,Cobra,Bug,Gecko,Fish,Koala,Mouse,Wombat,Shark,Whale,Sloth,Slug,Ant,Mantis,Bat,Rhino,Gator,Monkey,Swan,Ray,Crow,Goat,Marmot,Dog,Finch,Puffin,Fly,Camel,Kiwi,Spider,Lizard,Robin,Bear,Boa,Cow,Crab,Mule,Moth,Lynx,Moose,Skunk,Mako,Liger,Llama,Shrimp,Parrot,Pig,Clam,Urchin,Toucan,Frog,Toad,Turtle,Viper,Trout,Hare,Bee,Krill,Dodo,Tuna,Loon,Leech,Python,Wasp,Yak,Snake,Duck,Worm,Yeti runcode_prefixes_es=Cabra,Liebre,Oruga,Casa,Panda,Ciervo,Alce,Toro,Tigre,Rana,Sapo,Cebra,Rata,Selva,Sombra,Teja,Auto,Ronda,Libra,Tauro,Libro,Libre,Huerta,Pan,Ostra,Pez - + ########## VLE Properties ########## @@ -181,7 +180,7 @@ runcode_prefixes_es=Cabra,Liebre,Oruga,Casa,Panda,Ciervo,Alce,Toro,Tigre,Rana,Sa # remember to set maxFileUploadSize >= project_max_total_assets_size # student_max_asset_size: max size for any asset uploaded by student, in bytes. Default: 5MB=5242880 bytes # student_max_total_assets_size: max size for all assets combined uploaded by student, in bytes. Default: 10MB=10485760 bytes -# student_max_work_size: max size of student work (data in one node visit) for nodes in bytes. Default: 500K=512000 bytes +# student_max_work_size: max size of student work (data in one node visit) for nodes in bytes. Default: 500K=512000 bytes # # Note: if you set any of these values above 1MB, you'll also need to set mysql's max_allowed_packet value to allow saving the big data. # See this post: https://groups.google.com/d/topic/wise4-dev/CPS4AZEiquo/discussion diff --git a/src/main/resources/wise_sample_embedded_tomcat.properties b/src/main/resources/wise_sample_embedded_tomcat.properties index 10304366d1..fc6f5e6198 100644 --- a/src/main/resources/wise_sample_embedded_tomcat.properties +++ b/src/main/resources/wise_sample_embedded_tomcat.properties @@ -27,7 +27,6 @@ wise.name=My Local WISE Development Instance defaultLocale=en supportedLocales=en,ar,zh_TW,zh_CN,nl,fr,de,el,he,it,ja,ko,pt,es,th,tr -wiseBaseURL=/wise wiseBaseDir=/path_to_WISE_checkout/src/main/webapp/ curriculum_base_www=/wise/curriculum curriculum_base_dir=/path_to_WISE_checkout/src/main/webapp/curriculum @@ -175,7 +174,7 @@ runcode_prefixes_es=Cabra,Liebre,Oruga,Casa,Panda,Ciervo,Alce,Toro,Tigre,Rana,Sa # remember to set maxFileUploadSize >= project_max_total_assets_size # student_max_asset_size: max size for any asset uploaded by student, in bytes. Default: 5MB=5242880 bytes # student_max_total_assets_size: max size for all assets combined uploaded by student, in bytes. Default: 2MB=2097152 bytes -# student_max_work_size: max size of student work (data in one node visit) for nodes in bytes. Default: 500K=512000 bytes +# student_max_work_size: max size of student work (data in one node visit) for nodes in bytes. Default: 500K=512000 bytes # # Note: if you set any of these values above 1MB, you'll also need to set mysql's max_allowed_packet value to allow saving the big data. # See this post: https://groups.google.com/d/topic/wise4-dev/CPS4AZEiquo/discussion diff --git a/src/main/webapp/portal/admin/run/manageprojectruns.jsp b/src/main/webapp/portal/admin/run/manageprojectruns.jsp index 739d13a3ea..c1abf78261 100644 --- a/src/main/webapp/portal/admin/run/manageprojectruns.jsp +++ b/src/main/webapp/portal/admin/run/manageprojectruns.jsp @@ -3,479 +3,479 @@ - - -" /> - + + + " /> + -" media="screen" rel="stylesheet" type="text/css" /> -" media="screen" rel="stylesheet" type="text/css" /> -" media="screen" rel="stylesheet" type="text/css" /> -" media="screen" rel="stylesheet" type="text/css" /> -" media="screen" rel="stylesheet" type="text/css" /> -" media="screen" rel="stylesheet" type="text/css" /> -" media="screen" rel="stylesheet" type="text/css" /> + " media="screen" rel="stylesheet" type="text/css" /> + " media="screen" rel="stylesheet" type="text/css" /> + " media="screen" rel="stylesheet" type="text/css" /> + " media="screen" rel="stylesheet" type="text/css" /> + " media="screen" rel="stylesheet" type="text/css" /> + " media="screen" rel="stylesheet" type="text/css" /> + " media="screen" rel="stylesheet" type="text/css" /> -" type="text/javascript"> -" type="text/javascript"> -" type="text/javascript"> -" type="text/javascript"> -" type="text/javascript"> + " type="text/javascript"> + " type="text/javascript"> + " type="text/javascript"> + " type="text/javascript"> + " type="text/javascript"> - - + //setup archive and restore run dialogs + $('.archiveRun, .activateRun').on('click',function(){ + var title = $(this).attr('title'); + if($(this).hasClass('archiveRun')){ + var params = $(this).attr('id').replace('archiveRun_',''); + var path = "${contextPath}/teacher/run/manage/archiveRun.html?" + params; + } else if($(this).hasClass('activateRun')){ + var params = $(this).attr('id').replace('activateRun_',''); + var path = "${contextPath}/teacher/run/manage/startRun.html?" + params; + } + var div = $('#archiveRunDialog').html(''); + div.dialog({ + modal: true, + width: '600', + height: '450', + title: title, + position: 'center', + close: function(){ + if(document.getElementById('archiveIfrm').contentWindow['refreshRequired']){ + window.location.reload(); + } + $(this).html(''); + }, + buttons: { + Close: function(){ + $(this).dialog('close'); + } + } + }); + $("#archiveRunDialog > #archiveIfrm").attr('src',path); + }); + + // setup manage students dialog + $('.manageStudents').on('click',function(){ + var title = $(this).attr('title'); + var params = $(this).attr('id').replace('manageStudents_',''); + var path = "${contextPath}/teacher/management/viewmystudents?" + params; + var div = $('#manageStudentsDialog').html(''); + $('body').css('overflow','hidden'); + div.dialog({ + modal: true, + width: $(window).width() - 32, + height: $(window).height() - 32, + title: title, + position: 'center', + beforeClose: function() { + // check for unsaved changes and alert user if necessary + if(document.getElementById('manageStudentsIfrm').contentWindow['unsavedChanges']){ + var answer = confirm("Warning: You currently have unsaved changes to student teams. If you exit now, they will be discarded. To save your changes, choose 'Cancel' and click the 'SAVE CHANGES' button in the upper right corner.\n\nAre you sure you want to exit without saving?") + if(answer){ + return true; + } else { + return false; + }; + } else { + return true; + } + }, + close: function(){ + // refresh page if required (run title or student periods have been modified) + if(document.getElementById('manageStudentsIfrm').contentWindow['refreshRequired']){ + window.location.reload(); + } + $(this).html(''); + $('body').css('overflow','auto'); + }, + buttons: { + Exit: function(){ + $(this).dialog('close'); + } + } + }); + $("#manageStudentsDialog > #manageStudentsIfrm").attr('src',path); + }); + + //Set up view project details click action for each project id link + $('a.projectDetail').on('click',function(){ + var title = $(this).attr('title'); + if($(this).hasClass('projectDetail')){ + var projectId = $(this).attr('id').replace('projectDetail_',''); + } else if($(this).hasClass('projectInfo')){ + var projectId = $(this).attr('id').replace('projectInfo_',''); + } + var path = "${contextPath}/projectInfo?projectId=" + projectId; + var div = $('#projectDetailDialog').html(''); + div.dialog({ + modal: true, + width: '800', + height: '400', + title: title, + position: 'center', + close: function(){ $(this).html(''); }, + buttons: { + Close: function(){ + $(this).dialog('close'); + } + } + }); + $("#projectDetailDialog > #projectIfrm").attr('src',path); + }); + + + + var oTable = $('.runTable').dataTable({ + "sPaginationType": "full_numbers", + "iDisplayLength": 10, + "aLengthMenu": [[10, 25, 100, -1], [10, 25, 100, "All"]], + "bSort": false, + "oLanguage": { + "sInfo": " _START_-_END_ _TOTAL_", + "sInfoEmpty": "", + "sInfoFiltered": "", // (from _MAX_ total) + "sLengthMenu": " _MENU_ ", + "sProcessing": "", + "sZeroRecords": "", + "sInfoPostFix": "", + "sSearch": "", + "sUrl": "", + "oPaginate": { + "sFirst": "", + "sPrevious": "", + "sNext": "", + "sLast": "" + } + }, + "fnDrawCallback": function( oSettings ){ + // automatically scroll to top on page change + var tableID = $(this).attr('id'); + var targetOffset = $('#' + tableID).offset().top - 14; + if ($(window).scrollTop() > targetOffset){ + $('html,body').scrollTop(targetOffset); + } + }, + "sDom":'<"top"lip>rt<"bottom"ip><"clear">' + }); + + // define sort options + var sortParams = { + "items": [ + {"label": "", "column": 3, "direction": "desc" }, + {"label": "", "column": 3, "direction": "asc" }, + {"label": "", "column": 0, "direction": "asc" }, + {"label": "", "column": 0, "direction": "desc" } + ] + }; + + // setup sorting + function setSort(index,sortParams,wrapper) { + if(sortParams.items.length){ + // insert sort options into DOM + var sortHtml = ' '; + $.each(sortParams.items,function(){ + sortHtml += '' + this.label + ''; + }); + sortHtml += ''; + $(wrapper).children('.top').prepend(sortHtml); + + $('#sort_' + index).change(function(){ + $.fn.dataTableExt.iApiIndex = index; + var i = $('option:selected', '#sort_' + index).index(); + oTable.fnSort( [ [sortParams.items[i].column,sortParams.items[i].direction] ] ); + }); + } + }; + + var i; + for(i=0; i", + "sClearSearchLabel": "", + "sFilterLabel": "", + "sSearchLabel": "", + "aSearchOpts": [ + { + "identifier": "keyword", "label": " ", "column": 0, "maxlength": 50 + }, + { + "identifier": "period", "label": " ", "column": 7, "maxlength": 30, + "regexreplace": {"match": "/,\s*/gi", "replacement": " "}, + "instructions": "" + } + ] + }); + + // add sort logic + setSort(i,sortParams,wrapper); + + // reset cloumn widths on run tables (datatables seems to change these) + $('.runHeader').width(215); + $('.studentHeader').width(145); + $('.teacherHeader').width(115); + $('.toolsHeader').width(170); + + oTable.fnSort( [ [7,'desc'] ] ); + } + + // Make top header scroll with page + var $stickyEl = $('.dataTables_wrapper .top'); + if($stickyEl.length>0){ + var elTop = $stickyEl.offset().top, + width = $stickyEl.width(); + $(window).scroll(function() { + var windowTop = $(window).scrollTop(); + if (windowTop > elTop) { + $stickyEl.addClass('sticky'); + $stickyEl.css('width',width); + } else { + $stickyEl.removeClass('sticky'); + $stickyEl.css('width','auto'); + } + }); + } + }); + - - - + + + + + + + + + + - + + + + + + + + run created + run ended + source + ownership + periods + + + + + + + + ${run.name} + + + + + + + " alt="shared project" /> + ${run.owner.userDetails.firstname} ${run.owner.userDetails.lastname} + + + ${run.name}');"> + + - - - - - - - - - - - - - run created - run ended - source - ownership - periods - - - - - - - - ${run.name} - - - - - - - " alt="shared project" /> - ${run.owner.userDetails.firstname} ${run.owner.userDetails.lastname} - - - ${run.name}');"> - - - - - - - - ${run.owner.userDetails.firstname} ${run.owner.userDetails.lastname} - - - - ${run.runcode} - - - - ${run.id} - - - - - - - - - - - - ">${run.project.id} - - - - - ">${run.project.parentProjectId} - - - - - : ${run.name} ( ${run.id})">" /> - - - - - - - - - - - - - ${period.name} - - : ${run.name} ( ${run.id})" id="runId=${run.id}&periodName=${period.name}">${fn:length(period.members)} - - - - : ${run.name} ( ${run.id})" id="runId=${run.id}">" /> - - - + + + + + ${run.owner.userDetails.firstname} ${run.owner.userDetails.lastname} + + + + ${run.runcode} + + + + ${run.id} + + + + + + + + + + + + ">${run.project.id} + + + + + ">${run.project.parentProjectId} + + + + + : ${run.name} ( ${run.id})">" /> + + + + + + + + + + + + + ${period.name} + + : ${run.name} ( ${run.id})" id="runId=${run.id}&periodName=${period.name}">${fn:length(period.members)} + + + + : ${run.name} ( ${run.id})" id="runId=${run.id}">" /> + + + - - ${run.name} ( ${run.id})" id="runId=${run.id}&gradingType=monitor">" /> - - - - " /> - | ">" /> - | ')){window.top.location='${contextPath}/author/authorproject.html?projectId=${run.project.id}';} return true;">" /> - - - - ${run.name} ( ${run.id})">" /> - ${run.name} ( ${run.id})" >" /> - - : ${run.name} ( ${run.id})" id="runId=${run.id}&gradingType=export">" /> - - " /> - " title=" ${run.name} ( ${run.id})">" /> - - - ${run.starttime} - - ${source} - ${ownership} - - ${period.name}, - - - - - - - - - - - <%@ include file="../../footer.jsp"%> + + ${run.name} ( ${run.id})" id="runId=${run.id}&gradingType=monitor">" /> + + + + " /> + | ">" /> + | ')){window.top.location='${contextPath}/author/authorproject.html?projectId=${run.project.id}';} return true;">" /> + + + + ${run.name} ( ${run.id})">" /> + ${run.name} ( ${run.id})" >" /> + + : ${run.name} ( ${run.id})" id="runId=${run.id}&gradingType=export">" /> + + " /> + " title=" ${run.name} ( ${run.id})">" /> + + + ${run.starttime} + + ${source} + ${ownership} + + ${period.name}, + + + + + + + + + + + <%@ include file="../../footer.jsp"%> @@ -485,4 +485,4 @@ - \ No newline at end of file +
List
Long