Skip to content

Commit

Permalink
Merge branch 'release-5.10.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima committed May 26, 2020
2 parents 993d349 + d99e45c commit 9880450
Show file tree
Hide file tree
Showing 44 changed files with 2,990 additions and 2,864 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**/org/wise/portal/domain/authentication/**/*.java|**/org/wise/portal/domain/newsitem/**/*.java|**/org/wise/portal/domain/run/**/*.java|**/org/wise/portal/domain/webservice/**/*.java|**/org/wise/portal/presentation/web/controllers/general/contactwise/*.java|**/org/wise/portal/presentation/web/controllers/teacher/management/**/*.java|**/org/wise/portal/presentation/web/controllers/teacher/project/**/*.java|**/org/wise/portal/presentation/web/controllers/teacher/run/ShareProjectRunControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/RegisterTeacherControllerTest.java|**/org/wise/portal/presentation/web/controllers/IndexControllerTest.java|**/org/wise/portal/presentation/web/controllers/LoginControllerTest.java|**/org/wise/portal/presentation/web/controllers/RegisterStudentControllerTest.java|**/org/wise/portal/presentation/validators/teacher/*.java|**/org/wise/portal/dao/*.java|**/org/wise/portal/dao/authentication/impl/AllTests.java|**/org/wise/portal/dao/authentication/impl/HibernateAclEntryDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateAclSidDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateAclTargetObjectDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateAclTargetObjectIdentityDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateGrantedAuthorityDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateStudentUserDetailsDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateTeacherUserDetailsDaoTest.java|**/org/wise/portal/dao/group/**/*.java|**/org/wise/portal/dao/premadecomment/**/*.java" kind="src" output="target/test-classes" path="src/test/java">
<classpathentry excluding="**/org/wise/portal/domain/authentication/**/*.java|**/org/wise/portal/domain/newsitem/**/*.java|**/org/wise/portal/domain/run/**/*.java|**/org/wise/portal/domain/webservice/**/*.java|**/org/wise/portal/presentation/web/controllers/general/contactwise/*.java|**/org/wise/portal/presentation/web/controllers/teacher/management/BatchStudentChangePasswordControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeStudentPasswordControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeStudentPeriodControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeWorkgroupControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/management/StudentListControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/management/UpdateMyAccountInfoControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/management/ViewMyStudentsControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/project/**/*.java|**/org/wise/portal/presentation/web/controllers/teacher/run/ShareProjectRunControllerTest.java|**/org/wise/portal/presentation/web/controllers/teacher/RegisterTeacherControllerTest.java|**/org/wise/portal/presentation/web/controllers/IndexControllerTest.java|**/org/wise/portal/presentation/web/controllers/LoginControllerTest.java|**/org/wise/portal/presentation/web/controllers/RegisterStudentControllerTest.java|**/org/wise/portal/presentation/validators/teacher/*.java|**/org/wise/portal/dao/*.java|**/org/wise/portal/dao/authentication/impl/AllTests.java|**/org/wise/portal/dao/authentication/impl/HibernateAclEntryDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateAclSidDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateAclTargetObjectDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateAclTargetObjectIdentityDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateGrantedAuthorityDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateStudentUserDetailsDaoTest.java|**/org/wise/portal/dao/authentication/impl/HibernateTeacherUserDetailsDaoTest.java|**/org/wise/portal/dao/group/**/*.java|**/org/wise/portal/dao/premadecomment/**/*.java" kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wise",
"version": "5.10.0",
"version": "5.10.1",
"description": "Web-based Inquiry Science Environment",
"main": "app.js",
"browserslist": [
Expand Down
18 changes: 15 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<artifactId>wise</artifactId>
<packaging>war</packaging>
<name>Web-based Inquiry Science Environment</name>
<version>5.10.0</version>
<version>5.10.1</version>
<url>http://wise5.org</url>
<licenses>
<license>
Expand Down Expand Up @@ -151,7 +151,13 @@
<exclude>**/org/wise/portal/domain/run/**/*.java</exclude>
<exclude>**/org/wise/portal/domain/webservice/**/*.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/general/contactwise/*.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/**/*.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/BatchStudentChangePasswordControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeStudentPasswordControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeStudentPeriodControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeWorkgroupControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/StudentListControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/UpdateMyAccountInfoControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/ViewMyStudentsControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/project/**/*.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/run/ShareProjectRunControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/RegisterTeacherControllerTest.java</exclude>
Expand Down Expand Up @@ -191,7 +197,13 @@
<exclude>**/org/wise/portal/domain/run/**/*.java</exclude>
<exclude>**/org/wise/portal/domain/webservice/**/*.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/general/contactwise/*.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/**/*.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/BatchStudentChangePasswordControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeStudentPasswordControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeStudentPeriodControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/ChangeWorkgroupControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/StudentListControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/UpdateMyAccountInfoControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/management/ViewMyStudentsControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/project/**/*.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/run/ShareProjectRunControllerTest.java</exclude>
<exclude>**/org/wise/portal/presentation/web/controllers/teacher/RegisterTeacherControllerTest.java</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import lombok.Setter;
import org.wise.portal.domain.run.Run;
import org.wise.portal.domain.user.User;
import org.wise.portal.domain.workgroup.Workgroup;

/**
* @author Patrick Lawler
Expand All @@ -41,9 +42,11 @@ public class ChangePeriodParameters implements Serializable {

private User student;

private Workgroup workgroup;

private Run run;

private String projectcode;
private String currentPeriod;

private String projectcodeTo;
private String newPeriod;
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public void validate(Object params, Errors errors) {
return;
}

ValidationUtils.rejectIfEmptyOrWhitespace(errors, "projectcode",
"error.changeperiod.projectcode");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "currentPeriod",
"error.changeperiod.currentPeriod");
if (errors.getErrorCount() != 0) {
return;
}

ValidationUtils.rejectIfEmptyOrWhitespace(errors, "projectcodeTo",
"error.changeperiod.projectcode-To");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "newPeriod",
"error.changeperiod.newPeriod");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ protected ModelAndView handleRequestInternal(HttpServletRequest request,
ModelAndView wise5AuthoringView = new ModelAndView(
new RedirectView("../teacher/edit/unit/" + projectIdStr));
return wise5AuthoringView;
} else if (project.getWiseVersion().equals(4)) {
ModelAndView wise4AuthoringView = new ModelAndView(
new RedirectView("/legacy/author/authorproject.html?projectId=" + projectIdStr));
return wise4AuthoringView;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@
package org.wise.portal.presentation.web.controllers.teacher.management;

import java.text.DateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -35,12 +43,22 @@
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.acls.domain.BasePermission;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;
import org.wise.portal.dao.ObjectNotFoundException;
import org.wise.portal.domain.PeriodNotFoundException;
import org.wise.portal.domain.RunHasEndedException;
import org.wise.portal.domain.StudentUserAlreadyAssociatedWithRunException;
import org.wise.portal.domain.authentication.MutableUserDetails;
import org.wise.portal.domain.group.Group;
import org.wise.portal.domain.impl.ChangePeriodParameters;
Expand All @@ -62,14 +80,15 @@
import org.wise.portal.service.workgroup.WorkgroupService;

/**
* Controller for managing students in the run, like displaying students,
* exporting student names, and updating workgroup memberships
* Controller for managing students in the run, like displaying students, exporting student names,
* and updating workgroup memberships
*
* @author Patrick Lawler
* @author Hiroki Terashima
*/
@Controller
@SessionAttributes("changePeriodParameters")
@RequestMapping("/teacher/management")
public class ManageStudentsController {

@Autowired
Expand Down Expand Up @@ -101,7 +120,7 @@ public class ManageStudentsController {
* @return modelAndView containing information needed to view students
* @throws Exception
*/
@RequestMapping("/teacher/management/viewmystudents")
@GetMapping("/viewmystudents")
protected ModelAndView viewMyStudents(@RequestParam("runId") Long runId,
HttpServletRequest servletRequest) throws Exception {
User user = ControllerUtil.getSignedInUser();
Expand Down Expand Up @@ -129,14 +148,15 @@ protected ModelAndView viewMyStudents(@RequestParam("runId") Long runId,
grouplessStudents.removeAll(workgroup.getMembers());
try {
// don't include workgroups with no members
if (workgroup.getMembers().size() > 0
&& !workgroup.isTeacherWorkgroup()
if (workgroup.getMembers().size() > 0 && !workgroup.isTeacherWorkgroup()
&& workgroup.getPeriod().getId().equals(period.getId())) {
periodworkgroups.add(workgroup);
}
} catch (NullPointerException npe) {
// if a workgroup is not in a period, make a list of them and let teacher put them in a period...
// this should not be the case if the code works correctly and associates workgroups with periods when workgroups are created.
// if a workgroup is not in a period, make a list of them and let teacher put them in a
// period...
// this should not be the case if the code works correctly and associates workgroups
// with periods when workgroups are created.
workgroupsWithoutPeriod += workgroup.getId().toString() + ",";
}
}
Expand Down Expand Up @@ -168,48 +188,66 @@ protected ModelAndView viewMyStudents(@RequestParam("runId") Long runId,
}

private boolean userCanViewRun(User user, Run run) {
return user.isAdmin() ||
user.getUserDetails().hasGrantedAuthority(UserDetailsService.RESEARCHER_ROLE) ||
aclService.hasPermission(run, BasePermission.ADMINISTRATION, user) ||
aclService.hasPermission(run, BasePermission.READ, user);
return user.isAdmin()
|| user.getUserDetails().hasGrantedAuthority(UserDetailsService.RESEARCHER_ROLE)
|| aclService.hasPermission(run, BasePermission.ADMINISTRATION, user)
|| aclService.hasPermission(run, BasePermission.READ, user);
}

@GetMapping("/teacher/management/changestudentperiod")
public String showChangePeriodForm(ModelMap model,
@RequestParam("userId") Long userId,
@RequestParam("runId") Long runId,
@RequestParam("projectCode") String projectCode) throws Exception {
@GetMapping("/changestudentperiod")
public String showChangePeriodForm(ModelMap model, @RequestParam("userId") Long userId,
@RequestParam("runId") Long runId, @RequestParam("currentPeriod") String currentPeriod)
throws Exception {
ChangePeriodParameters params = new ChangePeriodParameters();
params.setStudent(userService.retrieveById(userId));
params.setRun(runService.retrieveById(runId));
params.setProjectcode(projectCode);
params.setCurrentPeriod(currentPeriod);
model.addAttribute("changePeriodParameters", params);
return "teacher/management/changestudentperiod";
}

@PostMapping("/teacher/management/changestudentperiod")
@PostMapping("/changestudentperiod")
protected String changeStudentPeriod(
@ModelAttribute("changePeriodParameters") ChangePeriodParameters params,
BindingResult bindingResult) {
BindingResult bindingResult, Authentication authentication) throws ObjectNotFoundException,
PeriodNotFoundException, StudentUserAlreadyAssociatedWithRunException, RunHasEndedException {
changePeriodParametersValidator.validate(params, bindingResult);
if (bindingResult.hasErrors()) {
Run run = params.getRun();
if (bindingResult.hasErrors() || !runService.hasWritePermission(authentication, run)) {
return "errors/friendlyError";
} else {
studentService.removeStudentFromRun(params.getStudent(), params.getRun());
studentService.addStudentToRun(params.getStudent(),
new Projectcode(params.getRun().getRuncode(), params.getNewPeriod()));
return "teacher/management/changestudentperiodsuccess";
}
}

@GetMapping("/change-workgroup-period/{workgroupId}")
protected String showChangeWorkgroupPeriodForm(ModelMap model, @PathVariable Long workgroupId)
throws ObjectNotFoundException {
ChangePeriodParameters params = new ChangePeriodParameters();
Workgroup workgroup = workgroupService.retrieveById(workgroupId);
params.setWorkgroup(workgroup);
params.setRun(workgroup.getRun());
params.setCurrentPeriod(workgroup.getPeriod().getName());
model.addAttribute("changePeriodParameters", params);
return "teacher/management/changeworkgroupperiod";
}

@PostMapping("/change-workgroup-period/{workgroupId}")
String changeWorkgroupPeriod(
@ModelAttribute("changePeriodParameters") ChangePeriodParameters params,
@PathVariable Long workgroupId, Authentication authentication)
throws PeriodNotFoundException, ObjectNotFoundException {
Run run = params.getRun();
if (!runService.hasWritePermission(authentication, run)) {
return "errors/accessdenied";
} else {
User user = ControllerUtil.getSignedInUser();
if (runService.hasRunPermission(params.getRun(), user, BasePermission.WRITE) ||
runService.hasRunPermission(params.getRun(), user, BasePermission.ADMINISTRATION)) {
try {
if (!params.getProjectcodeTo().equals(params.getProjectcode())) {
studentService.removeStudentFromRun(params.getStudent(), params.getRun());
studentService.addStudentToRun(params.getStudent(),
new Projectcode(params.getRun().getRuncode(), params.getProjectcodeTo()));
}
} catch (Exception e) {
}
return "teacher/management/changestudentperiodsuccess";
} else {
return "errors/accessdenied";
}
Workgroup workgroup = workgroupService.retrieveById(workgroupId);
Group newPeriod = run.getPeriodByName(params.getNewPeriod());
workgroupService.changePeriod(workgroup, newPeriod);
return "teacher/management/changestudentperiodsuccess";
}
}

Expand All @@ -219,7 +257,7 @@ protected String changeStudentPeriod(
* @return modelAndView containing information needed to get student list
* @throws Exception
*/
@RequestMapping("/teacher/management/studentlist")
@GetMapping("/studentlist")
protected ModelAndView getStudentList(@RequestParam("runId") Long runId) throws Exception {
Run run = runService.retrieveById(runId);
if (userCanViewRun(ControllerUtil.getSignedInUser(), run)) {
Expand All @@ -245,7 +283,7 @@ protected ModelAndView getStudentList(@RequestParam("runId") Long runId) throws
* @param response response to write the export into
* @throws Exception
*/
@RequestMapping("/teacher/management/studentListExport")
@GetMapping("/studentListExport")
protected void exportStudentList(@RequestParam("runId") Long runId,
HttpServletResponse response) throws Exception {
Run run = runService.retrieveById(runId);
Expand Down Expand Up @@ -394,7 +432,7 @@ protected void exportStudentList(@RequestParam("runId") Long runId,
* @param response
* @throws Exception
*/
@RequestMapping(method = RequestMethod.POST, value = "/teacher/management/submitworkgroupchanges")
@PostMapping("/submitworkgroupchanges")
protected void handleWorkgroupChanges(HttpServletRequest request,
HttpServletResponse response) throws Exception {
String periodId = request.getParameter("periodId");
Expand Down
Loading

0 comments on commit 9880450

Please sign in to comment.