Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.wise.portal.domain.authentication.MutableUserDetails;
import org.wise.portal.domain.user.User;
import org.wise.portal.service.authentication.UserDetailsService;
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;
Expand All @@ -55,6 +56,9 @@ public class UserInfoController {
@Autowired
private RunService runService;

@Autowired
private ProjectService projectService;

@GetMapping(value = {"/student/account/info", "/teacher/account/info"})
protected String getUserAccountInfo(Authentication auth, @RequestParam String username,
ModelMap modelMap) throws Exception {
Expand All @@ -73,6 +77,7 @@ protected String getUserAccountInfo(Authentication auth, @RequestParam String us
} else {
modelMap.put("isStudent", false);
modelMap.put("runList", runService.getRunListByOwner(user));
modelMap.put("projectList", projectService.getProjectList(user));
return "teacher/account/info";
}
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/i18n/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,12 @@ teacher.teacherinfo.lastLogin=Last Login
teacher.teacherinfo.lastLogin.description=The label for the Last Login field
teacher.teacherinfo.accountEnabled=Account Enabled
teacher.teacherinfo.accountEnabled.description=The label for the Account Enabled field
teacher.teacherinfo.unitList=Unit List
teacher.teacherinfo.unitList.description=The header for the unit list
teacher.teacherinfo.unitId=Unit ID
teacher.teacherinfo.unitId.description=The label for the Unit ID field
teacher.teacherinfo.unitName=Unit Name
teacher.teacherinfo.unitName.description=The label for the Unit Name field
teacher.teacherinfo.closeThisWindow=Close this window
teacher.teacherinfo.closeThisWindow.description=The text for the Close this window link

Expand Down
260 changes: 142 additions & 118 deletions src/main/webapp/portal/teacher/account/info.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,24 @@
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<%@ include file="../../favicon.jsp"%>
<title>Teacher Information</title>

<link href="${contextPath}/<spring:theme code="globalstyles"/>" media="screen" rel="stylesheet" type="text/css" />
<link href="${contextPath}/<spring:theme code="stylesheet"/>" media="screen" rel="stylesheet" type="text/css" />
<link href="${contextPath}/<spring:theme code="jquerystylesheet"/>" media="screen" rel="stylesheet" type="text/css" />
<c:if test="${textDirection == 'rtl' }">
<link href="${contextPath}/<spring:theme code="rtlstylesheet"/>" rel="stylesheet" type="text/css" >
</c:if>

<script type="text/javascript" src="${contextPath}/<spring:theme code="jquerysource"/>"></script>
<script type="text/javascript" src="${contextPath}/<spring:theme code="jqueryuisource"/>"></script>
<script src="${contextPath}/<spring:theme code="generalsource" />" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function() {
$("#tabs").tabs();
});
</script>

<sec:authorize access="hasRole('ROLE_ADMINISTRATOR')">
<script type="text/javascript">
function toggleUserAccountStatus(username, isCurrentlyEnabled) {
Expand Down Expand Up @@ -48,129 +55,146 @@ function toggleUserAccountStatus(username, isCurrentlyEnabled) {

</head>
<body style="background: #FFFFFF;">
<div class="dialogContent">
<div class="sectionHead">
<spring:message code="teacher.teacherinfo.teacherInformation" />
<div class="sectionContent">
<div id="tabs">
<ul>
<li><a href="#infoTab"><spring:message code="teacher.teacherinfo.teacherInformation" /></a></li>
<li><a href="#runsTab"><spring:message code="student.studentinfo.runList" /></a></li>
<li><a href="#unitsTab"><spring:message code="teacher.teacherinfo.unitList" /></a></li>
</ul>
<div id="infoTab">
<table>
<tr>
<th><spring:message code="teacher.teacherinfo.id" /></th>
<td><c:out value="${userInfoMap['ID']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.name" /></th>
<td><c:out value="${userInfoMap['First Name']}" />&nbsp;<c:out
value="${userInfoMap['Last Name']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.username" /></th>
<td><c:out value="${userInfoMap['Username']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.displayName" /></th>
<td><c:out value="${userInfoMap['Display Name']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.emailAddress" /></th>
<td><c:out value="${userInfoMap['Email']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.signupDate" /></th>
<td><fmt:formatDate value="${userInfoMap['Sign Up Date']}"
type="both" dateStyle="short" timeStyle="short" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.city" /></th>
<td><c:out value="${userInfoMap['City']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.state" /></th>
<td><c:out value="${userInfoMap['State']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.country" /></th>
<td><c:out value="${userInfoMap['Country']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.schoolName" /></th>
<td><c:out value="${userInfoMap['School Name']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.schoolLevel" /></th>
<td><span style="text-transform: lowercase;"><c:out
value="${userInfoMap['School Level']}" /></td>
</tr>
<tr>
<th><spring:message
code="teacher.teacherinfo.curriculumSubjects" /></th>
<td><span style="text-transform: lowercase;"><c:out
value="${userInfoMap['Curriculum Subjects']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.registerteacher.language" /></th>
<td><span style="text-transform: lowercase;"><c:out
value="${userInfoMap['Language']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.howDidYouHear" /></th>
<td><span style="text-transform: lowercase;"><c:out
value="${userInfoMap['How did you hear about us']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.numberOfLogins" /></th>
<td><c:out value="${userInfoMap['Number of Logins']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.lastLogin" /></th>
<td><fmt:formatDate value="${userInfoMap['Last Login']}"
type="both" dateStyle="short" timeStyle="short" /></td>
</tr>
<sec:authorize access="hasRole('ROLE_ADMINISTRATOR')">
<tr>
<th><spring:message code="teacher.teacherinfo.accountEnabled" /></th>
<td>
<c:out value="${userInfoMap['Account Enabled']}" />
<button type="button" style="margin-left: 8px;" onclick="toggleUserAccountStatus('${userInfoMap['Username']}', ${userInfoMap['Account Enabled']})">
<c:choose>
<c:when test="${userInfoMap['Account Enabled']}">disable user</c:when>
<c:otherwise>enable user</c:otherwise>
</c:choose>
</button>
</td>
</tr>
</sec:authorize>
</table>
</div>
<div class="dialogSection sectionContent">
<div id="runsTab">
<table>
<c:forEach var="run" items="${runList}">
<tr>
<th><spring:message code="student.studentinfo.runId" /></th>
<td><c:out value="${run.id}"></c:out></td>
</tr>

<table style="margin: 0 auto;">
<tr>
<th><spring:message code="teacher.teacherinfo.id" /></th>
<td><c:out value="${userInfoMap['ID']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.name" /></th>
<td><c:out value="${userInfoMap['First Name']}" />&nbsp;<c:out
value="${userInfoMap['Last Name']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.username" /></th>
<td><c:out value="${userInfoMap['Username']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.displayName" /></th>
<td><c:out value="${userInfoMap['Display Name']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.emailAddress" /></th>
<td><c:out value="${userInfoMap['Email']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.signupDate" /></th>
<td><fmt:formatDate value="${userInfoMap['Sign Up Date']}"
type="both" dateStyle="short" timeStyle="short" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.city" /></th>
<td><c:out value="${userInfoMap['City']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.state" /></th>
<td><c:out value="${userInfoMap['State']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.country" /></th>
<td><c:out value="${userInfoMap['Country']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.schoolName" /></th>
<td><c:out value="${userInfoMap['School Name']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.schoolLevel" /></th>
<td><span style="text-transform: lowercase;"><c:out
value="${userInfoMap['School Level']}" /></td>
</tr>
<tr>
<th><spring:message
code="teacher.teacherinfo.curriculumSubjects" /></th>
<td><span style="text-transform: lowercase;"><c:out
value="${userInfoMap['Curriculum Subjects']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.registerteacher.language" /></th>
<td><span style="text-transform: lowercase;"><c:out
value="${userInfoMap['Language']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.howDidYouHear" /></th>
<td><span style="text-transform: lowercase;"><c:out
value="${userInfoMap['How did you hear about us']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.numberOfLogins" /></th>
<td><c:out value="${userInfoMap['Number of Logins']}" /></td>
</tr>
<tr>
<th><spring:message code="teacher.teacherinfo.lastLogin" /></th>
<td><fmt:formatDate value="${userInfoMap['Last Login']}"
type="both" dateStyle="short" timeStyle="short" /></td>
</tr>
<sec:authorize access="hasRole('ROLE_ADMINISTRATOR')">
<tr>
<th><spring:message code="teacher.teacherinfo.accountEnabled" /></th>
<td>
<c:out value="${userInfoMap['Account Enabled']}" />
<button type="button" style="margin-left: 8px;" onclick="toggleUserAccountStatus('${userInfoMap['Username']}', ${userInfoMap['Account Enabled']})">
<c:choose>
<c:when test="${userInfoMap['Account Enabled']}">disable user</c:when>
<c:otherwise>enable user</c:otherwise>
</c:choose>
</button>
</td>
</tr>
</sec:authorize>
</table>
<br>
<table style="margin: 0 auto;">
<tr>
<th colspan="2"><u><spring:message
code="student.studentinfo.runList" /></u></th>
</tr>
<tr>
<th><spring:message code="student.studentinfo.runName" /></th>
<td><c:out value="${run.name}"></c:out></td>
</tr>

<c:forEach var="run" items="${runList}">
<tr>
<th><spring:message code="student.studentinfo.runId" /></th>
<td><c:out value="${run.id}"></c:out></td>
</tr>
<tr>
<th><spring:message code="student.studentinfo.runStartTime" /></th>
<td><c:out value="${run.starttime}"></c:out></td>
</tr>

<tr>
<th><spring:message code="student.studentinfo.runName" /></th>
<td><c:out value="${run.name}"></c:out></td>
</tr>

<tr>
<th><spring:message code="student.studentinfo.runStartTime" /></th>
<td><c:out value="${run.starttime}"></c:out></td>
</tr>
<tr>
<th colspan="2"><hr></hr></th>
</tr>
</c:forEach>
</table>
</div>
<div id="unitsTab">
<table>
<c:forEach var="project" items="${projectList}">
<tr>
<th><spring:message code="teacher.teacherinfo.unitId" /></th>
<td><a target="_blank" href="${contextPath}/previewproject.html?projectId=${project.id}"><c:out value="${project.id}"></c:out></a></td>
</tr>

<tr>
<th colspan="2"><hr></hr></th>
</tr>
</c:forEach>
</table>
<tr>
<th><spring:message code="teacher.teacherinfo.unitName" /></th>
<td><c:out value="${project.name}"></c:out></td>
</tr>

<tr>
<th colspan="2"><hr></hr></th>
</tr>
</c:forEach>
</table>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.ui.ModelMap;
import org.wise.portal.domain.project.Project;
import org.wise.portal.domain.run.Run;
import org.wise.portal.domain.run.impl.RunImpl;
import org.wise.portal.presentation.web.controllers.APIControllerTest;
Expand Down Expand Up @@ -89,15 +90,22 @@ public void getUserAccountInfo_AdminLooksUpTeacher_ReturnTeacherAccountInfoPage(
studentRuns.add(new RunImpl());
expect(runService.getRunListByOwner(teacher1)).andReturn(studentRuns);
replay(runService);
List<Project> teacherProjects = new ArrayList<>();
teacherProjects.add(project1);
expect(projectService.getProjectList(teacher1)).andReturn(teacherProjects);
replay(projectService);
String view = controller.getUserAccountInfo(adminAuth, TEACHER_USERNAME, modelMap);
assertEquals("teacher/account/info", view);
assertEquals(false, modelMap.get("isStudent"));
HashMap<String, Object> resultUserInfoMap = (HashMap<String, Object>) modelMap.get("userInfoMap");
assertEquals(true, resultUserInfoMap.get("Account Enabled"));
List<Run> resultRunList = (List<Run>) modelMap.get("runList");
assertEquals(1, resultRunList.size());
List<Project> resultProjectList = (List<Project>) modelMap.get("projectList");
assertEquals(1, resultProjectList.size());
verify(userService);
verify(runService);
verify(projectService);
}

@Test
Expand Down
Loading