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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public final class InstructorAttributes extends EntityAttributes<Instructor> {
private String googleId;
private String role;
private String displayedName;
private boolean isArchived;
private boolean isDisplayedToStudents;
private InstructorPrivileges privileges;
private transient String key;
Expand All @@ -41,7 +40,6 @@ private InstructorAttributes(String courseId, String email) {

this.role = Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER;
this.displayedName = Const.DEFAULT_DISPLAY_NAME_FOR_INSTRUCTOR;
this.isArchived = false;
this.isDisplayedToStudents = true;
this.privileges = new InstructorPrivileges(Const.InstructorPermissionRoleNames.INSTRUCTOR_PERMISSION_ROLE_COOWNER);

Expand Down Expand Up @@ -72,7 +70,7 @@ public static InstructorAttributes valueOf(Instructor instructor) {
if (instructor.getDisplayedName() != null) {
instructorAttributes.displayedName = instructor.getDisplayedName();
}
instructorAttributes.isArchived = instructor.getIsArchived();

instructorAttributes.isDisplayedToStudents = instructor.isDisplayedToStudents();

if (instructor.getInstructorPrivilegesAsText() == null) {
Expand Down Expand Up @@ -103,7 +101,6 @@ public InstructorAttributes getCopy() {
instructorAttributes.key = key;
instructorAttributes.role = role;
instructorAttributes.displayedName = displayedName;
instructorAttributes.isArchived = isArchived;
instructorAttributes.isDisplayedToStudents = isDisplayedToStudents;
instructorAttributes.privileges = privileges;
instructorAttributes.createdAt = createdAt;
Expand Down Expand Up @@ -132,14 +129,6 @@ public void setKey(String key) {
this.key = key;
}

public boolean isArchived() {
return isArchived;
}

public void setArchived(boolean archived) {
isArchived = archived;
}

public InstructorPrivileges getPrivileges() {
return privileges;
}
Expand Down Expand Up @@ -185,7 +174,7 @@ public String getRegistrationUrl() {

@Override
public Instructor toEntity() {
return new Instructor(googleId, courseId, isArchived, name, email, role,
return new Instructor(googleId, courseId, name, email, role,
isDisplayedToStudents, displayedName, getInstructorPrivilegesAsText());
}

Expand Down Expand Up @@ -385,7 +374,6 @@ public void update(UpdateOptionsWithGoogleId updateOptions) {

private void updateBasic(UpdateOptions updateOptions) {
updateOptions.nameOption.ifPresent(s -> name = s);
updateOptions.isArchivedOption.ifPresent(s -> isArchived = s);
updateOptions.roleOption.ifPresent(s -> role = s);
updateOptions.isDisplayedToStudentsOption.ifPresent(s -> isDisplayedToStudents = s);
updateOptions.instructorPrivilegesOption.ifPresent(s -> privileges = s);
Expand Down Expand Up @@ -570,7 +558,6 @@ public UpdateOptionsWithGoogleId build() {
private static class UpdateOptions {

UpdateOption<String> nameOption = UpdateOption.empty();
UpdateOption<Boolean> isArchivedOption = UpdateOption.empty();
UpdateOption<String> roleOption = UpdateOption.empty();
UpdateOption<Boolean> isDisplayedToStudentsOption = UpdateOption.empty();
UpdateOption<String> displayedNameOption = UpdateOption.empty();
Expand All @@ -580,7 +567,6 @@ private static class UpdateOptions {
public String toString() {
return "InstructorAttributes.UpdateOptions ["
+ "name = " + nameOption
+ ", isAchieved = " + isArchivedOption
+ ", roleOption = " + roleOption
+ ", isDisplayedToStudents = " + isDisplayedToStudentsOption
+ ", displayedName = " + displayedNameOption
Expand Down Expand Up @@ -637,11 +623,6 @@ public B withIsDisplayedToStudents(boolean isDisplayedToStudents) {
return thisBuilder;
}

public B withIsArchived(boolean isAchieved) {
updateOptions.isArchivedOption = UpdateOption.of(isAchieved);
return thisBuilder;
}

public abstract T build();

}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/teammates/common/util/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ public static class HeaderNames {
*/
public static class CourseStatus {
public static final String ACTIVE = "active";
public static final String ARCHIVED = "archived";
public static final String SOFT_DELETED = "softDeleted";
}

Expand Down Expand Up @@ -348,7 +347,6 @@ public static class ResourceURIs {
public static final String ACCOUNTS = URI_PREFIX + "/accounts";
public static final String RESPONSE_COMMENT = URI_PREFIX + "/responsecomment";
public static final String COURSE = URI_PREFIX + "/course";
public static final String COURSE_ARCHIVE = URI_PREFIX + "/course/archive";
public static final String BIN_COURSE = URI_PREFIX + "/bin/course";
public static final String COURSE_SECTIONS = URI_PREFIX + "/course/sections";
public static final String COURSES = URI_PREFIX + "/courses";
Expand Down
27 changes: 1 addition & 26 deletions src/main/java/teammates/logic/api/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,6 @@ public List<InstructorAttributes> getInstructorsForGoogleId(String googleId) {
return instructorsLogic.getInstructorsForGoogleId(googleId);
}

public List<InstructorAttributes> getInstructorsForGoogleId(String googleId, boolean omitArchived) {

assert googleId != null;

return instructorsLogic.getInstructorsForGoogleId(googleId, omitArchived);
}

/**
* Preconditions: <br>
* * All parameters are non-null.
Expand Down Expand Up @@ -504,24 +497,6 @@ public CourseAttributes updateCourseCascade(CourseAttributes.UpdateOptions updat
return coursesLogic.updateCourseCascade(updateOptions);
}

/**
* Changes the archive status of a course for an instructor.
*
* <br/>Preconditions: <br/>
* * All parameters are non-null.
*
* @param courseId The course of which the archive status is to be changed
* @param archiveStatus The archive status to be set
*/
public void setArchiveStatusOfInstructor(String googleId, String courseId, boolean archiveStatus)
throws InvalidParametersException, EntityDoesNotExistException {

assert googleId != null;
assert courseId != null;

instructorsLogic.setArchiveStatusOfInstructor(googleId, courseId, archiveStatus);
}

/**
* Deletes a course cascade its students, instructors, sessions, responses, deadline extensions and comments.
*
Expand Down Expand Up @@ -989,7 +964,7 @@ public List<FeedbackSessionAttributes> getFeedbackSessionsListForInstructor(
/**
* Returns a {@code List} of feedback sessions in the Recycle Bin for the instructors.
* <br>
* Omits sessions if the corresponding courses are archived or in Recycle Bin
* Omits sessions if the corresponding courses are in Recycle Bin
*/
public List<FeedbackSessionAttributes> getSoftDeletedFeedbackSessionsListForInstructors(
List<InstructorAttributes> instructorList) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/teammates/logic/core/AccountsLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void deleteAccountCascade(String googleId) {

// to prevent orphan course
List<InstructorAttributes> instructorsToDelete =
instructorsLogic.getInstructorsForGoogleId(googleId, false);
instructorsLogic.getInstructorsForGoogleId(googleId);
for (InstructorAttributes instructorToDelete : instructorsToDelete) {
if (instructorsLogic.getInstructorsForCourse(instructorToDelete.getCourseId()).size() <= 1) {
// the instructor is the last instructor in the course
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public List<FeedbackSessionAttributes> getFeedbackSessionsListForInstructor(
/**
* Returns a {@code List} of feedback sessions in the Recycle Bin for the instructors.
* <br>
* Omits sessions if the corresponding courses are archived or in Recycle Bin
* Omits sessions if the corresponding courses are in Recycle Bin
*/
public List<FeedbackSessionAttributes> getSoftDeletedFeedbackSessionsListForInstructors(
List<InstructorAttributes> instructorList) {
Expand Down
28 changes: 3 additions & 25 deletions src/main/java/teammates/logic/core/InstructorsLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,6 @@ public InstructorAttributes createInstructor(InstructorAttributes instructorToAd
return instructorsDb.createEntity(instructorToAdd);
}

/**
* Sets the archive status of an instructor (i.e. whether the instructor
* decides to archive the associated course or not).
*/
public void setArchiveStatusOfInstructor(String googleId, String courseId, boolean archiveStatus)
throws InvalidParametersException, EntityDoesNotExistException {
instructorsDb.updateInstructorByGoogleId(
InstructorAttributes.updateOptionsWithGoogleIdBuilder(courseId, googleId)
.withIsArchived(archiveStatus)
.build()
);
}

/**
* Checks if all the given instructors exist in the given course.
*
Expand Down Expand Up @@ -163,20 +150,11 @@ public List<InstructorAttributes> getInstructorsForCourse(String courseId) {
return instructorReturnList;
}

/**
* Gets all non-archived instructors associated with a googleId.
*/
public List<InstructorAttributes> getInstructorsForGoogleId(String googleId) {
return getInstructorsForGoogleId(googleId, false);
}

/**
* Gets all instructors associated with a googleId.
*
* @param omitArchived whether archived instructors should be omitted or not
*/
public List<InstructorAttributes> getInstructorsForGoogleId(String googleId, boolean omitArchived) {
return instructorsDb.getInstructorsForGoogleId(googleId, omitArchived);
public List<InstructorAttributes> getInstructorsForGoogleId(String googleId) {
return instructorsDb.getInstructorsForGoogleId(googleId);
}

/**
Expand Down Expand Up @@ -332,7 +310,7 @@ public void deleteInstructorCascade(String courseId, String email) {
* deadline extensions and comments.
*/
public void deleteInstructorsForGoogleIdCascade(String googleId) {
List<InstructorAttributes> instructors = instructorsDb.getInstructorsForGoogleId(googleId, false);
List<InstructorAttributes> instructors = instructorsDb.getInstructorsForGoogleId(googleId);

// cascade delete instructors
for (InstructorAttributes instructor : instructors) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/teammates/sqllogic/api/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public FeedbackSession getFeedbackSessionFromRecycleBin(String feedbackSessionNa
/**
* Returns a {@code List} of feedback sessions in the Recycle Bin for the instructors.
* <br>
* Omits sessions if the corresponding courses are archived or in Recycle Bin
* Omits sessions if the corresponding courses are in Recycle Bin
*/
public List<FeedbackSession> getSoftDeletedFeedbackSessionsForInstructors(
List<Instructor> instructorList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public List<FeedbackSession> getFeedbackSessionsForInstructors(
/**
* Returns a {@code List} of feedback sessions in the Recycle Bin for the instructors.
* <br>
* Omits sessions if the corresponding courses are archived or in Recycle Bin
* Omits sessions if the corresponding courses are in Recycle Bin
*/
public List<FeedbackSession> getSoftDeletedFeedbackSessionsForInstructors(
List<Instructor> instructorList) {
Expand Down
23 changes: 2 additions & 21 deletions src/main/java/teammates/storage/api/InstructorsDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ public InstructorAttributes getInstructorForRegistrationKey(String registrationK

/**
* Gets all instructors associated with a googleId.
*
* @param omitArchived whether archived instructors should be omitted or not
*/
public List<InstructorAttributes> getInstructorsForGoogleId(String googleId, boolean omitArchived) {
public List<InstructorAttributes> getInstructorsForGoogleId(String googleId) {
assert googleId != null;

return makeAttributes(getInstructorEntitiesForGoogleId(googleId, omitArchived));
return makeAttributes(getInstructorEntitiesForGoogleId(googleId));
}

/**
Expand Down Expand Up @@ -226,7 +224,6 @@ public InstructorAttributes updateInstructorByGoogleId(InstructorAttributes.Upda
boolean hasSameAttributes =
this.<String>hasSameValue(instructor.getName(), newAttributes.getName())
&& this.<String>hasSameValue(instructor.getEmail(), newAttributes.getEmail())
&& this.<Boolean>hasSameValue(instructor.getIsArchived(), newAttributes.isArchived())
&& this.<String>hasSameValue(instructor.getRole(), newAttributes.getRole())
&& this.<Boolean>hasSameValue(instructor.isDisplayedToStudents(), newAttributes.isDisplayedToStudents())
&& this.<String>hasSameValue(instructor.getDisplayedName(), newAttributes.getDisplayedName())
Expand All @@ -240,7 +237,6 @@ public InstructorAttributes updateInstructorByGoogleId(InstructorAttributes.Upda

instructor.setName(newAttributes.getName());
instructor.setEmail(newAttributes.getEmail());
instructor.setIsArchived(newAttributes.isArchived());
instructor.setRole(newAttributes.getRole());
instructor.setIsDisplayedToStudents(newAttributes.isDisplayedToStudents());
instructor.setDisplayedName(newAttributes.getDisplayedName());
Expand Down Expand Up @@ -281,7 +277,6 @@ public InstructorAttributes updateInstructorByEmail(InstructorAttributes.UpdateO
boolean hasSameAttributes =
this.<String>hasSameValue(instructor.getName(), newAttributes.getName())
&& this.<String>hasSameValue(instructor.getGoogleId(), newAttributes.getGoogleId())
&& this.<Boolean>hasSameValue(instructor.getIsArchived(), newAttributes.isArchived())
&& this.<String>hasSameValue(instructor.getRole(), newAttributes.getRole())
&& this.<Boolean>hasSameValue(instructor.isDisplayedToStudents(), newAttributes.isDisplayedToStudents())
&& this.<String>hasSameValue(instructor.getDisplayedName(), newAttributes.getDisplayedName())
Expand All @@ -294,7 +289,6 @@ public InstructorAttributes updateInstructorByEmail(InstructorAttributes.UpdateO

instructor.setGoogleId(newAttributes.getGoogleId());
instructor.setName(newAttributes.getName());
instructor.setIsArchived(newAttributes.isArchived());
instructor.setRole(newAttributes.getRole());
instructor.setIsDisplayedToStudents(newAttributes.isDisplayedToStudents());
instructor.setDisplayedName(newAttributes.getDisplayedName());
Expand Down Expand Up @@ -401,19 +395,6 @@ private List<Instructor> getInstructorEntitiesForGoogleId(String googleId) {
return getInstructorsForGoogleIdQuery(googleId).list();
}

/**
* Omits instructors with isArchived == omitArchived.
* This means that the corresponding course is archived by the instructor.
*/
private List<Instructor> getInstructorEntitiesForGoogleId(String googleId, boolean omitArchived) {
if (omitArchived) {
return getInstructorsForGoogleIdQuery(googleId)
.filter("isArchived =", false)
.list();
}
return getInstructorEntitiesForGoogleId(googleId);
}

private List<Instructor> getInstructorEntitiesForCourse(String courseId) {
return load().filter("courseId =", courseId).list();
}
Expand Down
Loading
Loading