Skip to content

Commit

Permalink
[#9255] Migrate part of instructor feedback sessions page to Angular (#…
Browse files Browse the repository at this point in the history
…9345)

* add API to get a list of feedback sessions of current user

* add API to get courses of the current user

* add API to create a feedback session

delete copy action as it can be achieved by session/question GET/POST APIs

* add API to restore feedback session in the recycle bin

* add API to delete a feedback session

* modify get session response rate API to enable instructor to access

* add API to publish/unpublish session

* add/modify frontend components

* add API to remind students for result/submission

* add API to get instructor privilege

* abstract out the magic feedback session name max length

* fix bug in submission status tooltip

* fix typo in status message

* move template questions/template sessions to separate JSON file
  • Loading branch information
xpdavid authored and wkurniawan07 committed Jan 24, 2019
1 parent 090401c commit de975cf
Show file tree
Hide file tree
Showing 123 changed files with 4,424 additions and 852 deletions.
8 changes: 8 additions & 0 deletions src/main/java/teammates/common/util/Const.java
Expand Up @@ -618,6 +618,8 @@ public static class GenderTypes {

public static class ParamsNames {

public static final String IS_IN_RECYCLE_BIN = "isinrecyclebin";

public static final String IS_USING_AJAX = "isusingAjax";
public static final String IS_STUDENT_REJOINING = "isstudentrejoining";
public static final String IS_INSTRUCTOR_REJOINING = "isinstructorrejoining";
Expand Down Expand Up @@ -965,13 +967,19 @@ public static class ResourceURIs {
public static final String ACCOUNTS_RESET = "/accounts/reset";
public static final String ACCOUNTS_DOWNGRADE = "/accounts/downgrade";
public static final String COURSE = "/course";
public static final String COURSES = "/courses";
public static final String INSTRUCTORS = "/instructors";
public static final String INSTRUCTOR = "/instructor";
public static final String INSTRUCTOR_PRIVILEGE = "/instructor/privilege";
public static final String STUDENTS = "/students";
public static final String STUDENT = "/student";
public static final String SESSIONS_ADMIN = "/sessions/admin";
public static final String SESSIONS_STATS = "/sessions/stats";
public static final String SESSION = "/session";
public static final String SESSION_PUBLISH = "/session/publish";
public static final String SESSION_REMIND_SUBMISSION = "/session/remind/submission";
public static final String SESSION_REMIND_RESULT = "/session/remind/result";
public static final String SESSIONS = "/sessions";
public static final String BIN_SESSION = "/bin/session";
public static final String QUESTIONS = "/questions";
public static final String QUESTION = "/question";
Expand Down
1 change: 0 additions & 1 deletion src/main/java/teammates/ui/controller/ActionFactory.java
Expand Up @@ -50,7 +50,6 @@ public class ActionFactory {
map(INSTRUCTOR_EDIT_INSTRUCTOR_FEEDBACK_SAVE, InstructorEditInstructorFeedbackSaveAction.class);
map(INSTRUCTOR_FEEDBACK_SESSIONS_PAGE, InstructorFeedbackSessionsPageAction.class);
map(INSTRUCTOR_FEEDBACK_ADD, InstructorFeedbackAddAction.class);
map(INSTRUCTOR_FEEDBACK_COPY, InstructorFeedbackCopyAction.class);
map(INSTRUCTOR_FEEDBACK_EDIT_COPY_PAGE, InstructorFeedbackEditCopyPageAction.class);
map(INSTRUCTOR_FEEDBACK_EDIT_COPY, InstructorFeedbackEditCopyAction.class);
map(INSTRUCTOR_FEEDBACK_REMIND, InstructorFeedbackRemindAction.class);
Expand Down

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/java/teammates/ui/newcontroller/ActionFactory.java
Expand Up @@ -41,15 +41,25 @@ public class ActionFactory {
map(ResourceURIs.ACCOUNTS_DOWNGRADE, PUT, DowngradeAccountAction.class);
map(ResourceURIs.ACCOUNTS_RESET, PUT, ResetAccountAction.class);
map(ResourceURIs.COURSE, GET, GetCourseAction.class);
map(ResourceURIs.COURSES, GET, GetCoursesAction.class);
map(ResourceURIs.INSTRUCTORS, DELETE, DeleteInstructorAction.class);
map(ResourceURIs.INSTRUCTOR, GET, GetInstructorAction.class);
map(ResourceURIs.INSTRUCTOR_PRIVILEGE, GET, GetInstructorPrivilegeAction.class);
map(ResourceURIs.STUDENTS, DELETE, DeleteStudentAction.class);
map(ResourceURIs.STUDENT, GET, GetStudentAction.class);
map(ResourceURIs.SESSIONS_ADMIN, GET, GetOngoingSessionsAction.class);
map(ResourceURIs.SESSIONS_STATS, GET, GetSessionResponseStatsAction.class);
map(ResourceURIs.SESSION, GET, GetFeedbackSessionAction.class);
map(ResourceURIs.SESSION, PUT, SaveFeedbackSessionAction.class);
map(ResourceURIs.SESSION, POST, CreateFeedbackSessionAction.class);
map(ResourceURIs.SESSION, DELETE, DeleteFeedbackSessionAction.class);
map(ResourceURIs.SESSION_PUBLISH, POST, PublishFeedbackSessionAction.class);
map(ResourceURIs.SESSION_PUBLISH, DELETE, UnpublishFeedbackSessionAction.class);
map(ResourceURIs.SESSION_REMIND_SUBMISSION, POST, RemindFeedbackSessionSubmissionAction.class);
map(ResourceURIs.SESSION_REMIND_RESULT, POST, RemindFeedbackSessionResultAction.class);
map(ResourceURIs.SESSIONS, GET, GetFeedbackSessionsAction.class);
map(ResourceURIs.BIN_SESSION, PUT, BinFeedbackSessionAction.class);
map(ResourceURIs.BIN_SESSION, DELETE, RestoreFeedbackSessionAction.class);
map(ResourceURIs.QUESTIONS, GET, GetFeedbackQuestionsAction.class);
map(ResourceURIs.QUESTION, POST, CreateFeedbackQuestionAction.class);
map(ResourceURIs.QUESTION, PUT, SaveFeedbackQuestionAction.class);
Expand Down
Expand Up @@ -40,7 +40,8 @@ public ActionResult execute() {
return new JsonResult(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR);
}

return new JsonResult("Moved to the recycle bin", HttpStatus.SC_OK);
FeedbackSessionAttributes recycleBinFs = logic.getFeedbackSessionFromRecycleBin(feedbackSessionName, courseId);
return new JsonResult(new FeedbackSessionInfo.FeedbackSessionResponse(recycleBinFs));
}

}
18 changes: 18 additions & 0 deletions src/main/java/teammates/ui/newcontroller/CourseInfo.java
@@ -1,5 +1,8 @@
package teammates.ui.newcontroller;

import java.util.List;
import java.util.stream.Collectors;

import teammates.common.datatransfer.attributes.CourseAttributes;

/**
Expand Down Expand Up @@ -33,4 +36,19 @@ public String getTimeZone() {
return timeZone;
}
}

/**
* Response of a list of courses.
*/
public static class CoursesResponse extends ActionResult.ActionOutput {
private final List<CourseResponse> courses;

public CoursesResponse(List<CourseAttributes> courseAttributesList) {
courses = courseAttributesList.stream().map(CourseResponse::new).collect(Collectors.toList());
}

public List<CourseResponse> getCourses() {
return courses;
}
}
}
@@ -0,0 +1,72 @@
package teammates.ui.newcontroller;

import java.time.Instant;

import teammates.common.datatransfer.attributes.CourseAttributes;
import teammates.common.datatransfer.attributes.FeedbackSessionAttributes;
import teammates.common.datatransfer.attributes.InstructorAttributes;
import teammates.common.exception.EntityAlreadyExistsException;
import teammates.common.exception.InvalidHttpRequestBodyException;
import teammates.common.exception.InvalidParametersException;
import teammates.common.util.Const;
import teammates.common.util.SanitizationHelper;

/**
* Create a feedback session.
*/
public class CreateFeedbackSessionAction extends Action {

@Override
protected AuthType getMinAuthLevel() {
return AuthType.LOGGED_IN;
}

@Override
public void checkSpecificAccessControl() {
String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);

InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, userInfo.getId());
CourseAttributes course = logic.getCourse(courseId);

gateKeeper.verifyAccessible(instructor, course, Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
}

@Override
public ActionResult execute() {
String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);

InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, userInfo.getId());
CourseAttributes course = logic.getCourse(courseId);

FeedbackSessionInfo.FeedbackSessionCreateRequest createRequest =
getAndValidateRequestBody(FeedbackSessionInfo.FeedbackSessionCreateRequest.class);

String feedbackSessionName = SanitizationHelper.sanitizeTitle(createRequest.getFeedbackSessionName());

FeedbackSessionAttributes fs =
FeedbackSessionAttributes
.builder(feedbackSessionName, course.getId(), instructor.getEmail())
.withTimeZone(course.getTimeZone())
.withInstructions(createRequest.getInstructions())
.withStartTime(createRequest.getSubmissionStartTime())
.withEndTime(createRequest.getSubmissionEndTime())
.withGracePeriodMinutes(createRequest.getGracePeriod())
.withSessionVisibleFromTime(createRequest.getSessionVisibleFromTime())
.withResultsVisibleFromTime(createRequest.getResultsVisibleFromTime())
.withOpeningEmailEnabled(true)
.withClosingEmailEnabled(createRequest.isClosingEmailEnabled())
.withPublishedEmailEnabled(createRequest.isPublishedEmailEnabled())
.withCreatedTime(Instant.now())
.build();

try {
logic.createFeedbackSession(fs);
} catch (EntityAlreadyExistsException | InvalidParametersException e) {
throw new InvalidHttpRequestBodyException(e.getMessage(), e);
}

fs = logic.getFeedbackSession(fs.getFeedbackSessionName(), fs.getCourseId());
return new JsonResult(new FeedbackSessionInfo.FeedbackSessionResponse(fs));
}

}
@@ -0,0 +1,37 @@
package teammates.ui.newcontroller;

import teammates.common.datatransfer.attributes.FeedbackSessionAttributes;
import teammates.common.util.Const;

/**
* Delete a feedback session.
*/
public class DeleteFeedbackSessionAction extends Action {

@Override
protected AuthType getMinAuthLevel() {
return AuthType.LOGGED_IN;
}

@Override
public void checkSpecificAccessControl() {
String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
FeedbackSessionAttributes feedbackSession = logic.getFeedbackSessionFromRecycleBin(feedbackSessionName, courseId);

gateKeeper.verifyAccessible(logic.getInstructorForGoogleId(courseId, userInfo.getId()),
feedbackSession,
Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_SESSION);
}

@Override
public ActionResult execute() {
String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID);
String feedbackSessionName = getNonNullRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);

logic.deleteFeedbackSession(feedbackSessionName, courseId);

return new JsonResult("The feedback session is deleted.");
}

}

0 comments on commit de975cf

Please sign in to comment.