Skip to content

Commit

Permalink
feat(Show Group Work): Allow teacher to retrieve peer group work (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan authored Mar 5, 2023
1 parent 09c02ac commit 08ba857
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.security.core.Authentication;
import org.wise.portal.dao.ObjectNotFoundException;
import org.wise.portal.domain.peergroup.PeerGroup;
import org.wise.portal.domain.run.Run;
import org.wise.portal.domain.user.User;
import org.wise.portal.service.vle.wise5.StudentWorkService;

Expand All @@ -17,4 +18,9 @@ protected boolean isUserInPeerGroup(Authentication auth, PeerGroup peerGroup)
User user = userService.retrieveUserByUsername(auth.getName());
return peerGroup.isMember(user);
}

protected boolean isUserTeacherOfPeerGroup(Authentication auth, PeerGroup peerGroup) {
Run run = peerGroup.getPeerGrouping().getRun();
return isTeacherOfRun(auth, run);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.wise.vle.domain.work.StudentWork;

@RestController
@Secured("ROLE_STUDENT")
@Secured({ "ROLE_STUDENT", "ROLE_TEACHER" })
@RequestMapping("/api/classmate/peer-group-work")
public class PeerGroupWorkController extends AbstractPeerGroupWorkController {

Expand All @@ -31,7 +31,7 @@ public List<StudentWork> getPeerGroupWork(Authentication auth,
@PathVariable String showPeerGroupWorkComponentId, @PathVariable String showWorkNodeId,
@PathVariable String showWorkComponentId)
throws ObjectNotFoundException, JSONException, IOException {
if (isUserInPeerGroup(auth, peerGroup)) {
if (isUserInPeerGroup(auth, peerGroup) || isUserTeacherOfPeerGroup(auth, peerGroup)) {
Run run = peerGroup.getPeerGrouping().getRun();
if (isValidShowPeerGroupWorkComponent(run, showPeerGroupWorkNodeId,
showPeerGroupWorkComponentId, showWorkNodeId, showWorkComponentId)) {
Expand Down

0 comments on commit 08ba857

Please sign in to comment.