diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index bdfa1dffac4..a79e1ec46b5 100755 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -44,7 +44,7 @@ If you are certain that you are reporting a new issue, [open a new issue](https: We welcome anyone manually testing our product and reporting bugs or suggestions for enhancements in the issue tracker. If you want to undertake such a role without actually contributing code, [get an instructor account from TEAMMATES](https://teammatesv4.appspot.com/web/front/request). -Remember to mention the purpose of your request under "Any other comments/queries". +Remember to mention the purpose of your request under "Any other comments/queries". *Note that we may need to assign a different institute from your request in order to prevent fraudulent usages.* ### Submitting a pull request diff --git a/src/client/java/teammates/client/scripts/statistics/CourseToInstituteCache.java b/src/client/java/teammates/client/scripts/statistics/CourseToInstituteCache.java deleted file mode 100644 index 51e19ff47ed..00000000000 --- a/src/client/java/teammates/client/scripts/statistics/CourseToInstituteCache.java +++ /dev/null @@ -1,74 +0,0 @@ -package teammates.client.scripts.statistics; - -import static com.googlecode.objectify.ObjectifyService.ofy; - -import java.util.List; -import java.util.Map; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.googlecode.objectify.Key; - -import teammates.common.util.StringHelper; -import teammates.storage.entity.Account; -import teammates.storage.entity.Instructor; - -/** - * An in-memory cache service that provides {@code courseId} to institute name mapping. - */ -public class CourseToInstituteCache { - - private static final String UNKNOWN_INSTITUTE = "Unknown Institute"; - - private LoadingCache cache; - - public CourseToInstituteCache() { - cache = CacheBuilder.newBuilder() - .maximumSize(2000000) // will approximately occupy 100MB memory space - .build(new CacheLoader<>() { - @Override - public String load(String courseId) { - List instructors = - ofy().load().type(Instructor.class).filter("courseId =", courseId).list(); - - for (Instructor instructor : instructors) { - if (StringHelper.isEmpty(instructor.getGoogleId())) { - continue; - } - - Account account = ofy().load().key(Key.create(Account.class, instructor.getGoogleId())).now(); - if (account != null && !StringHelper.isEmpty(account.getInstitute())) { - return account.getInstitute(); - } - } - - return UNKNOWN_INSTITUTE; - } - }); - } - - /** - * Populates the cache with existing courseId to institute mapping. - */ - public void populate(String courseId, String institute) { - cache.put(courseId, institute); - } - - /** - * Gets the a map that represents the mapping between courseId and institute. - */ - public Map asMap() { - return cache.asMap(); - } - - /** - * Gets the institute name associated with the course identified by {@code courseId}. - * - *

If the mapping cannot be found in the cache, several database queries are issued to find the mapping. - */ - public String get(String courseId) { - return cache.getUnchecked(courseId); - } - -} diff --git a/src/client/java/teammates/client/scripts/statistics/FileStore.java b/src/client/java/teammates/client/scripts/statistics/FileStore.java index 1652fd2fe1e..1077712795b 100644 --- a/src/client/java/teammates/client/scripts/statistics/FileStore.java +++ b/src/client/java/teammates/client/scripts/statistics/FileStore.java @@ -47,7 +47,6 @@ public class FileStore { new File(BASE_URI).mkdir(); } - private static final String COURSE_TO_INSTITUTE_CACHE_FILEPATH = BASE_URI + "CourseToInstituteCache.encrypted"; private static final String INSTITUTES_STATS_FILEPATH = BASE_URI + "InstitutesStats.encrypted"; private static final String INSTITUTES_STATS_METADATA_FILEPATH = BASE_URI + "InstitutesStatsMetadata.json"; @@ -55,40 +54,6 @@ private FileStore() { // utility class } - /** - * Gets the cache service. - * - *

If the cache is persisted to the disk, decrypts and parses it to warm up the cache. - */ - public static CourseToInstituteCache getCourseToInstituteCacheFromFileIfPossible() throws Exception { - // parse courseToInstituteCacheFile - File courseToInstituteCacheFile = new File(COURSE_TO_INSTITUTE_CACHE_FILEPATH); - CourseToInstituteCache courseToInstituteCache = new CourseToInstituteCache(); - if (courseToInstituteCacheFile.isFile()) { - courseToInstituteCache = parseEncryptedJsonFile(COURSE_TO_INSTITUTE_CACHE_FILEPATH, - jsonReader -> { - CourseToInstituteCache cache = new CourseToInstituteCache(); - jsonReader.beginObject(); - while (jsonReader.hasNext()) { - cache.populate(jsonReader.nextName(), jsonReader.nextString()); - } - jsonReader.endObject(); - return cache; - }); - } - - return courseToInstituteCache; - } - - /** - * Encrypts and persists the cache to a file in disk. - */ - public static void saveCourseToInstituteCacheToFile(CourseToInstituteCache courseToInstituteCache) - throws Exception { - saveEncryptedJsonToFile(COURSE_TO_INSTITUTE_CACHE_FILEPATH, courseToInstituteCache.asMap(), - new TypeToken>(){}.getType()); - } - /** * Decrypts and parses the statistics bundle that is saved in the disk. */ diff --git a/src/client/java/teammates/client/scripts/statistics/StatisticsPerInstitute.java b/src/client/java/teammates/client/scripts/statistics/StatisticsPerInstitute.java index 6db82c5ff52..b335d786b02 100644 --- a/src/client/java/teammates/client/scripts/statistics/StatisticsPerInstitute.java +++ b/src/client/java/teammates/client/scripts/statistics/StatisticsPerInstitute.java @@ -2,25 +2,28 @@ import java.time.Duration; import java.time.Instant; +import java.util.HashMap; +import java.util.Map; import com.googlecode.objectify.cmd.Query; import teammates.client.connector.DatastoreClient; import teammates.client.util.LoopHelper; -import teammates.storage.entity.Account; +import teammates.common.util.Const; +import teammates.storage.entity.Course; import teammates.storage.entity.CourseStudent; +import teammates.storage.entity.Instructor; /** * Script that calculates the number of unique students and instructors per institute. */ public class StatisticsPerInstitute extends DatastoreClient { - private StatisticsBundle bundle; - private CourseToInstituteCache courseToInstituteCache; + private final StatisticsBundle bundle; + private final Map courseToInstituteCache = new HashMap<>(); StatisticsPerInstitute() throws Exception { bundle = FileStore.getStatisticsBundleFromFileIfPossible(); - courseToInstituteCache = FileStore.getCourseToInstituteCacheFromFileIfPossible(); } public static void main(String[] args) throws Exception { @@ -28,6 +31,11 @@ public static void main(String[] args) throws Exception { statistics.doOperationRemotely(); } + private String getCourseInstitute(String courseId) { + Course course = ofy().load().type(Course.class).id(courseId).now(); + return course == null || course.getInstitute() == null ? Const.UNKNOWN_INSTITUTION : course.getInstitute(); + } + @Override protected void doOperation() { Instant now = Instant.now(); @@ -46,8 +54,8 @@ protected void doOperation() { ofy().load().type(CourseStudent.class) .filter("createdAt >", queryEntitiesFrom) .filter("createdAt <=", queryEntitiesTo); - Query accountQuery = - ofy().load().type(Account.class) + Query instructorQuery = + ofy().load().type(Instructor.class) .filter("createdAt >", queryEntitiesFrom) .filter("createdAt <=", queryEntitiesTo); @@ -56,20 +64,20 @@ protected void doOperation() { "Counting institutions stats by scanning student entities..."); Iterable students = CursorIterator.iterate(studentQuery); for (CourseStudent student : students) { - String instituteOfTheStudent = courseToInstituteCache.get(student.getCourseId()); + String instituteOfTheStudent = courseToInstituteCache.computeIfAbsent(student.getCourseId(), + k -> getCourseInstitute(student.getCourseId())); bundle.addStudentEmailToInstitute(instituteOfTheStudent, student.getEmail()); loopHelper.recordLoop(); } // generate institute stats by scanning account (instructor) entities loopHelper = new LoopHelper(100, - "Counting institutions stats by scanning account (instructor) entities..."); - Iterable accounts = CursorIterator.iterate(accountQuery); - for (Account account : accounts) { - if (!account.isInstructor()) { - continue; - } - bundle.addInstructorEmailToInstitute(account.getInstitute(), account.getEmail()); + "Counting institutions stats by scanning instructor entities..."); + Iterable instructors = CursorIterator.iterate(instructorQuery); + for (Instructor instructor : instructors) { + String instituteOfTheInstructor = courseToInstituteCache.computeIfAbsent(instructor.getCourseId(), + k -> getCourseInstitute(instructor.getCourseId())); + bundle.addInstructorEmailToInstitute(instituteOfTheInstructor, instructor.getEmail()); loopHelper.recordLoop(); } @@ -122,7 +130,6 @@ private void saveCheckpointOfData(Instant queryEntitiesFrom, Instant queryEntiti try { bundle.setStatsSince(queryEntitiesTo); FileStore.saveStatisticsBundleToFile(bundle); - FileStore.saveCourseToInstituteCacheToFile(courseToInstituteCache); } catch (Exception e) { System.out.println("===== Error saving checkpoint when counting stats from %s to %s =====%n"); e.printStackTrace(); diff --git a/src/e2e/java/teammates/e2e/cases/AdminAccountsPageE2ETest.java b/src/e2e/java/teammates/e2e/cases/AdminAccountsPageE2ETest.java index 69beb4a3b56..b8c78244ab7 100644 --- a/src/e2e/java/teammates/e2e/cases/AdminAccountsPageE2ETest.java +++ b/src/e2e/java/teammates/e2e/cases/AdminAccountsPageE2ETest.java @@ -55,25 +55,6 @@ public void testAll() { accountsPage.verifyStatusMessage("Student is successfully deleted from course \"" + courseId + "\""); verifyAbsentInDatabase(student); - ______TS("action: downgrade instructor account"); - - InstructorAttributes instructor2 = testData.instructors.get("AAccounts.instr2-AAccounts.CS2104"); - InstructorAttributes instructor3 = testData.instructors.get("AAccounts.instr2-AAccounts.CS1101"); - verifyPresentInDatabase(instructor2); - verifyPresentInDatabase(instructor3); - - accountsPage.clickDowngradeAccount(); - accountsPage.verifyStatusMessage("Instructor account is successfully downgraded to student."); - accountsPage.waitForPageToLoad(); - - account = getAccount(googleId); - assertFalse(account.isInstructor()); - accountsPage.verifyAccountDetails(account); - - // instructor entities should also be deleted - verifyAbsentInDatabase(instructor2); - verifyAbsentInDatabase(instructor3); - ______TS("action: delete account entirely"); StudentAttributes student2 = testData.students.get("AAccounts.instr2-student-CS2104"); diff --git a/src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java b/src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java index 2063d17e244..a10cc951ae4 100644 --- a/src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java +++ b/src/e2e/java/teammates/e2e/cases/AdminSearchPageE2ETest.java @@ -4,8 +4,8 @@ import org.testng.annotations.Test; -import teammates.common.datatransfer.attributes.AccountAttributes; import teammates.common.datatransfer.attributes.AccountRequestAttributes; +import teammates.common.datatransfer.attributes.CourseAttributes; import teammates.common.datatransfer.attributes.FeedbackSessionAttributes; import teammates.common.datatransfer.attributes.InstructorAttributes; import teammates.common.datatransfer.attributes.StudentAttributes; @@ -40,10 +40,9 @@ public void testAll() { AppUrl url = createFrontendUrl(Const.WebPageURIs.ADMIN_SEARCH_PAGE); AdminSearchPage searchPage = loginAdminToPage(url, AdminSearchPage.class); + CourseAttributes course = testData.courses.get("typicalCourse1"); StudentAttributes student = testData.students.get("student1InCourse1"); - AccountAttributes studentAccount = testData.accounts.get("student1InCourse1"); InstructorAttributes instructor = testData.instructors.get("instructor1OfCourse1"); - AccountAttributes instructorAccount = testData.accounts.get("instructor1OfCourse1"); AccountRequestAttributes accountRequest = testData.accountRequests.get("instructor1OfCourse1"); ______TS("Typical case: Search student email"); @@ -54,7 +53,7 @@ public void testAll() { String studentManageAccountLink = getExpectedStudentManageAccountLink(student); String studentHomePageLink = getExpectedStudentHomePageLink(student); int numExpandedRows = getExpectedNumExpandedRows(student); - searchPage.verifyStudentRowContent(student, studentAccount, studentDetails, studentManageAccountLink, + searchPage.verifyStudentRowContent(student, course, studentDetails, studentManageAccountLink, studentHomePageLink); searchPage.verifyStudentExpandedLinks(student, numExpandedRows); @@ -63,7 +62,7 @@ public void testAll() { student.setGoogleId(null); studentManageAccountLink = getExpectedStudentManageAccountLink(student); studentHomePageLink = getExpectedStudentHomePageLink(student); - searchPage.verifyStudentRowContent(student, studentAccount, studentDetails, studentManageAccountLink, + searchPage.verifyStudentRowContent(student, course, studentDetails, studentManageAccountLink, studentHomePageLink); ______TS("Typical case: Regenerate registration key for a course student"); @@ -81,7 +80,7 @@ public void testAll() { searchPage.clickSearchButton(); String instructorManageAccountLink = getExpectedInstructorManageAccountLink(instructor); String instructorHomePageLink = getExpectedInstructorHomePageLink(instructor); - searchPage.verifyInstructorRowContent(instructor, instructorAccount, instructorManageAccountLink, + searchPage.verifyInstructorRowContent(instructor, course, instructorManageAccountLink, instructorHomePageLink); searchPage.verifyInstructorExpandedLinks(instructor); @@ -90,7 +89,7 @@ public void testAll() { instructor.setGoogleId(null); instructorManageAccountLink = getExpectedInstructorManageAccountLink(instructor); instructorHomePageLink = getExpectedInstructorHomePageLink(instructor); - searchPage.verifyInstructorRowContent(instructor, instructorAccount, instructorManageAccountLink, + searchPage.verifyInstructorRowContent(instructor, course, instructorManageAccountLink, instructorHomePageLink); ______TS("Typical case: Regenerate registration key for an instructor"); @@ -114,9 +113,9 @@ public void testAll() { searchContent = "Course1"; searchPage.inputSearchContent(searchContent); searchPage.clickSearchButton(); - searchPage.verifyStudentRowContent(student, studentAccount, studentDetails, studentManageAccountLink, + searchPage.verifyStudentRowContent(student, course, studentDetails, studentManageAccountLink, studentHomePageLink); - searchPage.verifyInstructorRowContent(instructor, instructorAccount, instructorManageAccountLink, + searchPage.verifyInstructorRowContent(instructor, course, instructorManageAccountLink, instructorHomePageLink); searchPage.verifyAccountRequestRowContent(accountRequest); diff --git a/src/e2e/java/teammates/e2e/cases/FeedbackResultsPageE2ETest.java b/src/e2e/java/teammates/e2e/cases/FeedbackResultsPageE2ETest.java index 058483de11b..4594fb85ba9 100644 --- a/src/e2e/java/teammates/e2e/cases/FeedbackResultsPageE2ETest.java +++ b/src/e2e/java/teammates/e2e/cases/FeedbackResultsPageE2ETest.java @@ -9,6 +9,7 @@ import org.testng.annotations.Test; import teammates.common.datatransfer.FeedbackParticipantType; +import teammates.common.datatransfer.attributes.CourseAttributes; import teammates.common.datatransfer.attributes.FeedbackQuestionAttributes; import teammates.common.datatransfer.attributes.FeedbackResponseAttributes; import teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes; @@ -25,6 +26,7 @@ */ public class FeedbackResultsPageE2ETest extends BaseE2ETestCase { private FeedbackResultsPage resultsPage; + private CourseAttributes course; private FeedbackSessionAttributes openSession; private List questions = new ArrayList<>(); @@ -33,6 +35,7 @@ protected void prepareTestData() { testData = loadDataBundle("/FeedbackResultsPageE2ETest.json"); removeAndRestoreDataBundle(testData); + course = testData.courses.get("FRes.CS2104"); openSession = testData.feedbackSessions.get("Open Session"); for (int i = 1; i <= testData.feedbackQuestions.size(); i++) { questions.add(testData.feedbackQuestions.get("qn" + i)); @@ -52,7 +55,7 @@ public void testAll() { .withRegistrationKey(getKeyForStudent(unregistered)); resultsPage = getNewPageInstance(url, FeedbackResultsPage.class); - resultsPage.verifyFeedbackSessionDetails(openSession); + resultsPage.verifyFeedbackSessionDetails(openSession, course); ______TS("unregistered student: questions with responses loaded"); verifyLoadedQuestions(unregistered); @@ -64,7 +67,7 @@ public void testAll() { .withSessionName(openSession.getFeedbackSessionName()); resultsPage = loginToPage(url, FeedbackResultsPage.class, student.getGoogleId()); - resultsPage.verifyFeedbackSessionDetails(openSession); + resultsPage.verifyFeedbackSessionDetails(openSession, course); ______TS("registered student: questions with responses loaded"); verifyLoadedQuestions(student); @@ -105,7 +108,7 @@ public void testAll() { .withSessionName(openSession.getFeedbackSessionName()); resultsPage = loginToPage(url, FeedbackResultsPage.class, instructor.getGoogleId()); - resultsPage.verifyFeedbackSessionDetails(openSession); + resultsPage.verifyFeedbackSessionDetails(openSession, course); ______TS("registered instructor: questions with responses loaded"); verifyLoadedQuestions(instructor); diff --git a/src/e2e/java/teammates/e2e/cases/FeedbackSubmitPageE2ETest.java b/src/e2e/java/teammates/e2e/cases/FeedbackSubmitPageE2ETest.java index 210df897436..64f3217fd64 100644 --- a/src/e2e/java/teammates/e2e/cases/FeedbackSubmitPageE2ETest.java +++ b/src/e2e/java/teammates/e2e/cases/FeedbackSubmitPageE2ETest.java @@ -7,6 +7,7 @@ import org.testng.annotations.Test; +import teammates.common.datatransfer.attributes.CourseAttributes; import teammates.common.datatransfer.attributes.FeedbackQuestionAttributes; import teammates.common.datatransfer.attributes.FeedbackResponseAttributes; import teammates.common.datatransfer.attributes.FeedbackResponseCommentAttributes; @@ -25,7 +26,7 @@ public class FeedbackSubmitPageE2ETest extends BaseE2ETestCase { private StudentAttributes student; private InstructorAttributes instructor; - + private CourseAttributes course; private FeedbackSessionAttributes openSession; private FeedbackSessionAttributes closedSession; private FeedbackSessionAttributes gracePeriodSession; @@ -39,6 +40,7 @@ protected void prepareTestData() { removeAndRestoreDataBundle(testData); instructor = testData.instructors.get("FSubmit.instr"); + course = testData.courses.get("FSubmit.CS2104"); openSession = testData.feedbackSessions.get("Open Session"); closedSession = testData.feedbackSessions.get("Closed Session"); gracePeriodSession = testData.feedbackSessions.get("Grace Period Session"); @@ -53,7 +55,7 @@ public void testAll() { FeedbackSubmitPage submitPage = loginToPage(url, FeedbackSubmitPage.class, instructor.getGoogleId()); ______TS("verify loaded session data"); - submitPage.verifyFeedbackSessionDetails(openSession); + submitPage.verifyFeedbackSessionDetails(openSession, course); ______TS("questions with giver type instructor"); submitPage.verifyNumQuestions(1); @@ -153,7 +155,7 @@ public void testAll() { .withParam("previewas", instructor.getEmail()); submitPage = loginToPage(url, FeedbackSubmitPage.class, instructor.getGoogleId()); - submitPage.verifyFeedbackSessionDetails(openSession); + submitPage.verifyFeedbackSessionDetails(openSession, course); submitPage.verifyNumQuestions(1); submitPage.verifyQuestionDetails(1, testData.feedbackQuestions.get("qn5InSession1")); submitPage.verifyCannotSubmit(); @@ -165,7 +167,7 @@ public void testAll() { .withParam("previewas", student.getEmail()); submitPage = getNewPageInstance(url, FeedbackSubmitPage.class); - submitPage.verifyFeedbackSessionDetails(openSession); + submitPage.verifyFeedbackSessionDetails(openSession, course); submitPage.verifyNumQuestions(4); submitPage.verifyQuestionDetails(1, testData.feedbackQuestions.get("qn1InSession1")); submitPage.verifyQuestionDetails(2, testData.feedbackQuestions.get("qn2InSession1")); @@ -181,7 +183,7 @@ public void testAll() { .withParam("moderatedquestionId", questionId); submitPage = getNewPageInstance(url, FeedbackSubmitPage.class); - submitPage.verifyFeedbackSessionDetails(gracePeriodSession); + submitPage.verifyFeedbackSessionDetails(gracePeriodSession, course); // One out of two questions in grace period session should not be visible submitPage.verifyNumQuestions(1); submitPage.verifyQuestionDetails(1, question); diff --git a/src/e2e/java/teammates/e2e/pageobjects/AdminAccountsPage.java b/src/e2e/java/teammates/e2e/pageobjects/AdminAccountsPage.java index e9091d9ced0..2a6035dab30 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/AdminAccountsPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/AdminAccountsPage.java @@ -25,21 +25,12 @@ public class AdminAccountsPage extends AppPage { @FindBy(id = "account-email") private WebElement accountEmail; - @FindBy(id = "account-institute") - private WebElement accountInstitute; - - @FindBy(id = "account-is-instructor") - private WebElement accountIsInstructor; - @FindBy(id = "instructor-table") private WebElement instructorTable; @FindBy(id = "student-table") private WebElement studentTable; - @FindBy(id = "btn-downgrade-account") - private WebElement downgradeAccountButton; - @FindBy(id = "btn-delete-account") private WebElement deleteAccountButton; @@ -56,8 +47,6 @@ public void verifyAccountDetails(AccountAttributes account) { assertEquals(account.getGoogleId(), accountId.getText()); assertEquals(account.getName(), accountName.getText()); assertEquals(account.getEmail(), accountEmail.getText()); - assertEquals(account.getInstitute(), accountInstitute.getText()); - assertEquals(account.isInstructor(), Boolean.parseBoolean(accountIsInstructor.getText())); } public void clickRemoveInstructorFromCourse(String courseId) { @@ -68,7 +57,7 @@ public void clickRemoveInstructorFromCourse(String courseId) { for (WebElement instructorRow : instructorRows) { List cells = instructorRow.findElements(By.tagName("td")); if (cells.get(0).getText().startsWith("[" + courseId + "]")) { - deleteButton = cells.get(1).findElement(By.className("btn-danger")); + deleteButton = cells.get(2).findElement(By.className("btn-danger")); } } @@ -87,7 +76,7 @@ public void clickRemoveStudentFromCourse(String courseId) { for (WebElement studentRow : studentRows) { List cells = studentRow.findElements(By.tagName("td")); if (cells.get(0).getText().startsWith("[" + courseId + "]")) { - deleteButton = cells.get(1).findElement(By.className("btn-danger")); + deleteButton = cells.get(2).findElement(By.className("btn-danger")); } } @@ -98,11 +87,6 @@ public void clickRemoveStudentFromCourse(String courseId) { waitForPageToLoad(true); } - public void clickDowngradeAccount() { - click(downgradeAccountButton); - waitForPageToLoad(true); - } - public void clickDeleteAccount() { click(deleteAccountButton); waitForPageToLoad(true); diff --git a/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java b/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java index 6c68fe47848..649fcd42d8b 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/AdminSearchPage.java @@ -11,8 +11,8 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; -import teammates.common.datatransfer.attributes.AccountAttributes; import teammates.common.datatransfer.attributes.AccountRequestAttributes; +import teammates.common.datatransfer.attributes.CourseAttributes; import teammates.common.datatransfer.attributes.InstructorAttributes; import teammates.common.datatransfer.attributes.StudentAttributes; import teammates.common.util.Const; @@ -337,7 +337,7 @@ private String getExpandedRowInputValue(WebElement row, String rowHeader) { } } - public void verifyStudentRowContent(StudentAttributes student, AccountAttributes account, + public void verifyStudentRowContent(StudentAttributes student, CourseAttributes course, String expectedDetails, String expectedManageAccountLink, String expectedHomePageLink) { WebElement studentRow = getStudentRow(student); @@ -351,7 +351,7 @@ public void verifyStudentRowContent(StudentAttributes student, AccountAttributes String expectedName = student.getName(); String expectedGoogleId = StringHelper.convertToEmptyStringIfNull(student.getGoogleId()); - String expectedInstitute = StringHelper.convertToEmptyStringIfNull(account.getInstitute()); + String expectedInstitute = StringHelper.convertToEmptyStringIfNull(course.getInstitute()); String expectedComment = StringHelper.convertToEmptyStringIfNull(student.getComments()); assertEquals(expectedDetails, actualDetails); @@ -377,7 +377,7 @@ public void verifyStudentExpandedLinks(StudentAttributes student, int expectedNu assertEquals(expectedNumExpandedRows, actualNumExpandedRows); } - public void verifyInstructorRowContent(InstructorAttributes instructor, AccountAttributes account, + public void verifyInstructorRowContent(InstructorAttributes instructor, CourseAttributes course, String expectedManageAccountLink, String expectedHomePageLink) { WebElement instructorRow = getInstructorRow(instructor); String actualCourseId = getInstructorCourseId(instructorRow); @@ -390,7 +390,7 @@ public void verifyInstructorRowContent(InstructorAttributes instructor, AccountA String expectedCourseId = instructor.getCourseId(); String expectedName = instructor.getName(); String expectedGoogleId = StringHelper.convertToEmptyStringIfNull(instructor.getGoogleId()); - String expectedInstitute = StringHelper.convertToEmptyStringIfNull(account.getInstitute()); + String expectedInstitute = StringHelper.convertToEmptyStringIfNull(course.getInstitute()); assertEquals(expectedCourseId, actualCourseId); assertEquals(expectedName, actualName); diff --git a/src/e2e/java/teammates/e2e/pageobjects/FeedbackResultsPage.java b/src/e2e/java/teammates/e2e/pageobjects/FeedbackResultsPage.java index 72c1b366d09..265c1787d82 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/FeedbackResultsPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/FeedbackResultsPage.java @@ -17,6 +17,7 @@ import org.openqa.selenium.support.FindBy; import teammates.common.datatransfer.FeedbackParticipantType; +import teammates.common.datatransfer.attributes.CourseAttributes; import teammates.common.datatransfer.attributes.FeedbackQuestionAttributes; import teammates.common.datatransfer.attributes.FeedbackResponseAttributes; import teammates.common.datatransfer.attributes.FeedbackSessionAttributes; @@ -43,6 +44,12 @@ public class FeedbackResultsPage extends AppPage { @FindBy(id = "course-id") private WebElement courseId; + @FindBy(id = "course-name") + private WebElement courseName; + + @FindBy(id = "course-institute") + private WebElement courseInstitute; + @FindBy(id = "session-name") private WebElement sessionName; @@ -61,8 +68,10 @@ protected boolean containsExpectedPageContents() { return getPageTitle().contains("Feedback Session Results"); } - public void verifyFeedbackSessionDetails(FeedbackSessionAttributes feedbackSession) { + public void verifyFeedbackSessionDetails(FeedbackSessionAttributes feedbackSession, CourseAttributes course) { assertEquals(getCourseId(), feedbackSession.getCourseId()); + assertEquals(getCourseName(), course.getName()); + assertEquals(getCourseInstitute(), course.getInstitute()); assertEquals(getFeedbackSessionName(), feedbackSession.getFeedbackSessionName()); assertDateEquals(getOpeningTime(), feedbackSession.getStartTime(), feedbackSession.getTimeZone()); assertDateEquals(getClosingTime(), feedbackSession.getEndTime(), feedbackSession.getTimeZone()); @@ -268,6 +277,14 @@ private String getCourseId() { return courseId.getText(); } + private String getCourseName() { + return courseName.getText(); + } + + private String getCourseInstitute() { + return courseInstitute.getText(); + } + private String getFeedbackSessionName() { return sessionName.getText(); } diff --git a/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java b/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java index e44b4aba0c6..a88c74e23e4 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/FeedbackSubmitPage.java @@ -14,6 +14,7 @@ import org.openqa.selenium.WebElement; import teammates.common.datatransfer.FeedbackParticipantType; +import teammates.common.datatransfer.attributes.CourseAttributes; import teammates.common.datatransfer.attributes.FeedbackQuestionAttributes; import teammates.common.datatransfer.attributes.FeedbackResponseAttributes; import teammates.common.datatransfer.attributes.FeedbackSessionAttributes; @@ -54,8 +55,10 @@ protected boolean containsExpectedPageContents() { return getPageTitle().contains("Submit Feedback"); } - public void verifyFeedbackSessionDetails(FeedbackSessionAttributes feedbackSession) { + public void verifyFeedbackSessionDetails(FeedbackSessionAttributes feedbackSession, CourseAttributes course) { assertEquals(getCourseId(), feedbackSession.getCourseId()); + assertEquals(getCourseName(), course.getName()); + assertEquals(getCourseInstitute(), course.getInstitute()); assertEquals(getFeedbackSessionName(), feedbackSession.getFeedbackSessionName()); assertDateEquals(getOpeningTime(), feedbackSession.getStartTime(), feedbackSession.getTimeZone()); assertDateEquals(getClosingTime(), feedbackSession.getEndTime(), feedbackSession.getTimeZone()); @@ -533,6 +536,14 @@ private String getCourseId() { return browser.driver.findElement(By.id("course-id")).getText(); } + private String getCourseName() { + return browser.driver.findElement(By.id("course-name")).getText(); + } + + private String getCourseInstitute() { + return browser.driver.findElement(By.id("course-institute")).getText(); + } + private String getFeedbackSessionName() { return browser.driver.findElement(By.id("fs-name")).getText(); } diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseDetailsPage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseDetailsPage.java index fc886638cc9..81476d1a0c3 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseDetailsPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseDetailsPage.java @@ -27,6 +27,9 @@ public class InstructorCourseDetailsPage extends AppPage { @FindBy(id = "course-name") private WebElement courseNameField; + @FindBy(id = "course-institute") + private WebElement courseInstituteField; + @FindBy(id = "num-sections") private WebElement numSectionsField; @@ -52,6 +55,7 @@ public void verifyCourseDetails(CourseAttributes course, InstructorAttributes[] int numSections, int numTeams, int numStudents) { assertEquals(course.getId(), courseIdField.getText()); assertEquals(course.getName(), courseNameField.getText()); + assertEquals(course.getInstitute(), courseInstituteField.getText()); assertEquals(Integer.toString(numSections), numSectionsField.getText()); assertEquals(Integer.toString(numTeams), numTeamsField.getText()); assertEquals(Integer.toString(numStudents), numStudentsField.getText()); diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseEditPage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseEditPage.java index 94a0b831d22..ad0bb81551d 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseEditPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorCourseEditPage.java @@ -53,6 +53,9 @@ public class InstructorCourseEditPage extends AppPage { @FindBy(id = "course-name") private WebElement courseNameTextBox; + @FindBy(id = "course-institute") + private WebElement courseInstituteTextBox; + @FindBy(id = "time-zone") private WebElement timeZoneDropDown; @@ -80,6 +83,7 @@ protected boolean containsExpectedPageContents() { public void verifyCourseDetails(CourseAttributes course) { assertEquals(course.getId(), getCourseId()); assertEquals(course.getName(), getCourseName()); + assertEquals(course.getInstitute(), getCourseInstitute()); assertEquals(course.getTimeZone(), getTimeZone()); } @@ -340,6 +344,10 @@ public String getCourseName() { return courseNameTextBox.getAttribute("value"); } + public String getCourseInstitute() { + return courseInstituteTextBox.getAttribute("value"); + } + public String getTimeZone() { return timeZoneDropDown.getAttribute("value"); } diff --git a/src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java b/src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java index 7edce1e343d..d4e5c1d32cf 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/InstructorCoursesPage.java @@ -33,6 +33,9 @@ public class InstructorCoursesPage extends AppPage { @FindBy(id = "new-course-name") private WebElement courseNameTextBox; + @FindBy(id = "new-course-institute") + private WebElement courseInstituteDropdown; + @FindBy(id = "new-time-zone") private WebElement timeZoneDropdown; @@ -134,6 +137,7 @@ public void addCourse(CourseAttributes newCourse) { fillTextBox(courseIdTextBox, newCourse.getId()); fillTextBox(courseNameTextBox, newCourse.getName()); + selectCourseInstitute(newCourse.getInstitute()); selectNewTimeZone(newCourse.getTimeZone()); click(submitButton); @@ -287,6 +291,11 @@ private WebElement getDeleteAllButton() { return browser.driver.findElement(By.id("btn-delete-all")); } + private void selectCourseInstitute(String institute) { + Select dropdown = new Select(courseInstituteDropdown); + dropdown.selectByValue(institute); + } + private void selectNewTimeZone(String timeZone) { Select dropdown = new Select(timeZoneDropdown); dropdown.selectByValue(timeZone); diff --git a/src/e2e/java/teammates/e2e/pageobjects/StudentCourseDetailsPage.java b/src/e2e/java/teammates/e2e/pageobjects/StudentCourseDetailsPage.java index 8f90ba98cce..801272c1af6 100644 --- a/src/e2e/java/teammates/e2e/pageobjects/StudentCourseDetailsPage.java +++ b/src/e2e/java/teammates/e2e/pageobjects/StudentCourseDetailsPage.java @@ -28,6 +28,9 @@ public class StudentCourseDetailsPage extends AppPage { @FindBy(id = "course-id") private WebElement courseIdField; + @FindBy(id = "course-institute") + private WebElement courseInstituteField; + @FindBy(id = "instructors") private WebElement instructorsList; @@ -55,6 +58,7 @@ protected boolean containsExpectedPageContents() { public void verifyCourseDetails(CourseAttributes courseDetails) { assertEquals(courseDetails.getName(), courseNameField.getText()); assertEquals(courseDetails.getId(), courseIdField.getText()); + assertEquals(courseDetails.getInstitute(), courseInstituteField.getText()); } public void verifyInstructorsDetails(InstructorAttributes[] instructorDetails) { diff --git a/src/e2e/resources/data/AdminAccountsPageE2ETest.json b/src/e2e/resources/data/AdminAccountsPageE2ETest.json index afbb878f49c..f6d1e885f84 100644 --- a/src/e2e/resources/data/AdminAccountsPageE2ETest.json +++ b/src/e2e/resources/data/AdminAccountsPageE2ETest.json @@ -3,9 +3,7 @@ "AAccounts.instr2": { "googleId": "tm.e2e.AAccounts.instr2", "name": "Teammates Instr2", - "isInstructor": true, - "email": "AAccounts.instr2@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "AAccounts.instr2@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/AdminHomePageE2ETest.json b/src/e2e/resources/data/AdminHomePageE2ETest.json index 3805d093e81..096891c9ab7 100644 --- a/src/e2e/resources/data/AdminHomePageE2ETest.json +++ b/src/e2e/resources/data/AdminHomePageE2ETest.json @@ -3,9 +3,7 @@ "AHome.instructor1OfCourse1": { "googleId": "tm.e2e.AHome.inst1", "name": "Teammates Instr1", - "isInstructor": true, - "email": "AHome.instr1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "AHome.instr1@gmail.tmt" } }, "accountRequests": { diff --git a/src/e2e/resources/data/AdminSearchPageE2ETest.json b/src/e2e/resources/data/AdminSearchPageE2ETest.json index 7ba82406f1a..0ea97c11aba 100644 --- a/src/e2e/resources/data/AdminSearchPageE2ETest.json +++ b/src/e2e/resources/data/AdminSearchPageE2ETest.json @@ -3,23 +3,17 @@ "instructor1OfCourse1": { "googleId": "tm.e2e.ASearch.instr1", "name": "Instructor1 of Course1", - "isInstructor": true, - "email": "ASearch.instructor1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ASearch.instructor1@gmail.tmt" }, "instructor2OfCourse1": { "googleId": "tm.e2e.ASearch.instr2", "name": "Instructor2 of Course1", - "isInstructor": true, - "email": "ASearch.instructor2@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ASearch.instructor2@gmail.tmt" }, "student1InCourse1": { "googleId": "tm.e2e.ASearch.student1", "name": "Student1 in course1", - "isInstructor": false, - "email": "ASearch.student1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ASearch.student1@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/AdminSessionsPageE2ETest.json b/src/e2e/resources/data/AdminSessionsPageE2ETest.json index c1c47d3692f..4fed18fd2aa 100644 --- a/src/e2e/resources/data/AdminSessionsPageE2ETest.json +++ b/src/e2e/resources/data/AdminSessionsPageE2ETest.json @@ -3,9 +3,7 @@ "instructor1OfCourse1": { "googleId": "tm.e2e.ASess.instr1", "name": "Instructor1 of Course1", - "isInstructor": true, - "email": "ASess.instructor1@gmail.tmt", - "institute": "TEAMMATES Institute 1" + "email": "ASess.instructor1@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/AutomatedSessionRemindersE2ETest.json b/src/e2e/resources/data/AutomatedSessionRemindersE2ETest.json index b875c626941..9cd3ac21c6e 100644 --- a/src/e2e/resources/data/AutomatedSessionRemindersE2ETest.json +++ b/src/e2e/resources/data/AutomatedSessionRemindersE2ETest.json @@ -3,9 +3,7 @@ "instructorWithEvals": { "googleId": "tm.e2e.AutSesRem.instructor", "name": "Test Ins for Aut Sessions Reminder", - "isInstructor": true, - "email": "AutSesRem.instructor@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "AutSesRem.instructor@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackConstSumOptionQuestionE2ETest.json b/src/e2e/resources/data/FeedbackConstSumOptionQuestionE2ETest.json index 4576656ae99..8a16ed909dd 100644 --- a/src/e2e/resources/data/FeedbackConstSumOptionQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackConstSumOptionQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FCSumOptQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackConstSumRecipientQuestionE2ETest.json b/src/e2e/resources/data/FeedbackConstSumRecipientQuestionE2ETest.json index ebc097c6dec..9d4d0d87e80 100644 --- a/src/e2e/resources/data/FeedbackConstSumRecipientQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackConstSumRecipientQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FCSumRcptQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackContributionQuestionE2ETest.json b/src/e2e/resources/data/FeedbackContributionQuestionE2ETest.json index 6d1a1b3f9fb..506a068b983 100644 --- a/src/e2e/resources/data/FeedbackContributionQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackContributionQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FContrQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackMcqQuestionE2ETest.json b/src/e2e/resources/data/FeedbackMcqQuestionE2ETest.json index 9294225adaa..d3130370a41 100644 --- a/src/e2e/resources/data/FeedbackMcqQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackMcqQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FMcqQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackMsqQuestionE2ETest.json b/src/e2e/resources/data/FeedbackMsqQuestionE2ETest.json index 1ac3f8eda2d..a3623b3c6a7 100644 --- a/src/e2e/resources/data/FeedbackMsqQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackMsqQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FMsqQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackNumScaleQuestionE2ETest.json b/src/e2e/resources/data/FeedbackNumScaleQuestionE2ETest.json index 4570964f7f6..7038ce85393 100644 --- a/src/e2e/resources/data/FeedbackNumScaleQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackNumScaleQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FNumScaleQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackRankOptionQuestionE2ETest.json b/src/e2e/resources/data/FeedbackRankOptionQuestionE2ETest.json index bf156fd8e14..b867b6f37ec 100644 --- a/src/e2e/resources/data/FeedbackRankOptionQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackRankOptionQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FRankOptQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackRankRecipientQuestionE2ETest.json b/src/e2e/resources/data/FeedbackRankRecipientQuestionE2ETest.json index c825e50650f..928682bfa28 100644 --- a/src/e2e/resources/data/FeedbackRankRecipientQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackRankRecipientQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FRankRcptQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackResultsPageE2ETest.json b/src/e2e/resources/data/FeedbackResultsPageE2ETest.json index c908067870d..510c5c7c667 100644 --- a/src/e2e/resources/data/FeedbackResultsPageE2ETest.json +++ b/src/e2e/resources/data/FeedbackResultsPageE2ETest.json @@ -3,44 +3,32 @@ "FRes.instr": { "googleId": "tm.e2e.FRes.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "FRes.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FRes.instr@gmail.tmt" }, "FRes.alice.b": { "googleId": "tm.e2e.FRes.alice.b", "name": "Alice B.", - "isInstructor": false, - "email": "FRes.alice.b@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FRes.alice.b@gmail.tmt" }, "FRes.benny.c": { "googleId": "tm.e2e.FRes.benny.c", "name": "Benny C.", - "isInstructor": false, - "email": "FRes.benny.c@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FRes.benny.c@gmail.tmt" }, "FRes.charlie.d": { "googleId": "tm.e2e.FRes.charlie.d", "name": "Charlie D.", - "isInstructor": false, - "email": "FRes.charlie.d@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FRes.charlie.d@gmail.tmt" }, "FRes.danny.e": { "googleId": "tm.e2e.FRes.danny.e", "name": "Danny E.", - "isInstructor": false, - "email": "FRes.danny.e@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FRes.danny.e@gmail.tmt" }, "FRes.emily.f": { "googleId": "tm.e2e.FRes.emily.f", "name": "Emily F.", - "isInstructor": false, - "email": "FRes.emily.f@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FRes.emily.f@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackRubricQuestionE2ETest.json b/src/e2e/resources/data/FeedbackRubricQuestionE2ETest.json index 444eeb8e0d4..1c86acd3157 100644 --- a/src/e2e/resources/data/FeedbackRubricQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackRubricQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FRubricQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackSubmitPageE2ETest.json b/src/e2e/resources/data/FeedbackSubmitPageE2ETest.json index dcf5e66d60c..bc19d5f0c7e 100644 --- a/src/e2e/resources/data/FeedbackSubmitPageE2ETest.json +++ b/src/e2e/resources/data/FeedbackSubmitPageE2ETest.json @@ -3,44 +3,32 @@ "FSubmit.instr": { "googleId": "tm.e2e.FSubmit.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "FSubmit.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSubmit.instr@gmail.tmt" }, "FSubmit.instr2": { "googleId": "tm.e2e.FSubmit.instr2", "name": "Teammates Test2", - "isInstructor": true, - "email": "FSubmit.instr2@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSubmit.instr2@gmail.tmt" }, "FSubmit.alice.b": { "googleId": "tm.e2e.FSubmit.alice.b", "name": "Alice B.", - "isInstructor": false, - "email": "FSubmit.alice.b@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSubmit.alice.b@gmail.tmt" }, "FSubmit.charlie.d": { "googleId": "tm.e2e.FSubmit.charlie.d", "name": "Charlie D.", - "isInstructor": false, - "email": "FSubmit.charlie.d@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSubmit.charlie.d@gmail.tmt" }, "FSubmit.danny.e": { "googleId": "tm.e2e.FSubmit.danny.e", "name": "Danny E.", - "isInstructor": false, - "email": "FSubmit.danny.e@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSubmit.danny.e@gmail.tmt" }, "FSubmit.emily.f": { "googleId": "tm.e2e.FSubmit.emily.f", "name": "Emily F.", - "isInstructor": false, - "email": "FSubmit.emily.f@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSubmit.emily.f@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/FeedbackTextQuestionE2ETest.json b/src/e2e/resources/data/FeedbackTextQuestionE2ETest.json index 09fb664964c..4c8fded9a17 100644 --- a/src/e2e/resources/data/FeedbackTextQuestionE2ETest.json +++ b/src/e2e/resources/data/FeedbackTextQuestionE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.FTextQn.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorAuditLogsPageE2ETest.json b/src/e2e/resources/data/InstructorAuditLogsPageE2ETest.json index 8d52c89700e..cfc532d404e 100644 --- a/src/e2e/resources/data/InstructorAuditLogsPageE2ETest.json +++ b/src/e2e/resources/data/InstructorAuditLogsPageE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.IAuditLogs.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorCourseDetailsPageE2ETest.json b/src/e2e/resources/data/InstructorCourseDetailsPageE2ETest.json index cd9056565f7..bc35fd7d22f 100644 --- a/src/e2e/resources/data/InstructorCourseDetailsPageE2ETest.json +++ b/src/e2e/resources/data/InstructorCourseDetailsPageE2ETest.json @@ -3,30 +3,22 @@ "ICDet.instr": { "googleId": "tm.e2e.ICDet.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "ICDet.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ICDet.instr@gmail.tmt" }, "ICDet.instr2": { "googleId": "tm.e2e.ICDet.instr2", "name": "Teammates Test 2", - "isInstructor": true, - "email": "ICDet.instr2@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ICDet.instr2@gmail.tmt" }, "Alice": { "googleId": "tm.e2e.ICDet.alice.b", "name": "Alice Betsy", - "isInstructor": false, - "email": "alice.b.tmms@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "alice.b.tmms@gmail.tmt" }, "Danny": { "googleId": "tm.e2e.ICDet.danny.e", "name": "Charlie Davis", - "isInstructor": false, - "email": "danny.e.tmms@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "danny.e.tmms@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorCourseEditPageE2ETest.json b/src/e2e/resources/data/InstructorCourseEditPageE2ETest.json index 6a758df8cb1..e392c48a96e 100644 --- a/src/e2e/resources/data/InstructorCourseEditPageE2ETest.json +++ b/src/e2e/resources/data/InstructorCourseEditPageE2ETest.json @@ -3,16 +3,12 @@ "ICEdit.coowner": { "googleId": "tm.e2e.ICEdit.coowner", "name": "Teammates Test", - "isInstructor": true, - "email": "ICEdit.coowner@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ICEdit.coowner@gmail.tmt" }, "ICEdit.observer": { "googleId": "tm.e2e.ICEdit.observer", "name": "Teammates Instructor", - "isInstructor": true, - "email": "ICEdit.observer@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ICEdit.observer@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorCourseEnrollPageE2ETest.json b/src/e2e/resources/data/InstructorCourseEnrollPageE2ETest.json index cd1d0847b65..eeff763abd2 100644 --- a/src/e2e/resources/data/InstructorCourseEnrollPageE2ETest.json +++ b/src/e2e/resources/data/InstructorCourseEnrollPageE2ETest.json @@ -3,9 +3,7 @@ "ICEnroll.teammates.test": { "googleId": "tm.e2e.ICEnroll.teammates.test", "name": "Teammates Test", - "isInstructor": true, - "email": "teammates.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "teammates.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorCourseJoinConfirmationPageE2ETest.json b/src/e2e/resources/data/InstructorCourseJoinConfirmationPageE2ETest.json index bb025ecf35a..db832468245 100644 --- a/src/e2e/resources/data/InstructorCourseJoinConfirmationPageE2ETest.json +++ b/src/e2e/resources/data/InstructorCourseJoinConfirmationPageE2ETest.json @@ -3,9 +3,7 @@ "ICJoinConf.instr": { "googleId": "tm.e2e.ICJoinConf.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "ICJoinConf.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ICJoinConf.instr@gmail.tmt" } }, "accountRequests": { diff --git a/src/e2e/resources/data/InstructorCourseStudentDetailsEditPageE2ETest.json b/src/e2e/resources/data/InstructorCourseStudentDetailsEditPageE2ETest.json index fd1b412be40..01467f21b6b 100644 --- a/src/e2e/resources/data/InstructorCourseStudentDetailsEditPageE2ETest.json +++ b/src/e2e/resources/data/InstructorCourseStudentDetailsEditPageE2ETest.json @@ -3,9 +3,7 @@ "ICSDetEdit.instr": { "googleId": "tm.e2e.ICSDetEdit.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "ICSDetEdit.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ICSDetEdit.instr@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorCourseStudentDetailsPageE2ETest.json b/src/e2e/resources/data/InstructorCourseStudentDetailsPageE2ETest.json index 89e5c6e5433..0bb477dd29e 100644 --- a/src/e2e/resources/data/InstructorCourseStudentDetailsPageE2ETest.json +++ b/src/e2e/resources/data/InstructorCourseStudentDetailsPageE2ETest.json @@ -3,9 +3,7 @@ "ICSDet.instr": { "googleId": "tm.e2e.ICSDet.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "ICSDet.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ICSDet.instr@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorCoursesPageE2ETest.json b/src/e2e/resources/data/InstructorCoursesPageE2ETest.json index da8cc1f142c..e51bec22822 100644 --- a/src/e2e/resources/data/InstructorCoursesPageE2ETest.json +++ b/src/e2e/resources/data/InstructorCoursesPageE2ETest.json @@ -3,9 +3,7 @@ "instructor": { "googleId": "tm.e2e.ICs.instructor", "name": "Teammates Demo Instr", - "isInstructor": true, - "email": "ICs.instructor@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ICs.instructor@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorFeedbackEditPageE2ETest.json b/src/e2e/resources/data/InstructorFeedbackEditPageE2ETest.json index 287274e860d..147a2d41ced 100644 --- a/src/e2e/resources/data/InstructorFeedbackEditPageE2ETest.json +++ b/src/e2e/resources/data/InstructorFeedbackEditPageE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.IFEdit.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorFeedbackReportPageE2ETest.json b/src/e2e/resources/data/InstructorFeedbackReportPageE2ETest.json index b04e4367c06..cd179770b28 100644 --- a/src/e2e/resources/data/InstructorFeedbackReportPageE2ETest.json +++ b/src/e2e/resources/data/InstructorFeedbackReportPageE2ETest.json @@ -3,30 +3,22 @@ "tm.e2e.IFRep.instr": { "googleId": "tm.e2e.IFRep.instr", "name": "Teammates Test 1", - "isInstructor": true, - "email": "IFRep.instr1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "IFRep.instr1@gmail.tmt" }, "tm.e2e.IFRep.alice.b": { "googleId": "tm.e2e.IFRep.alice.b", "name": "Alice B.", - "isInstructor": false, - "email": "IFRep.alice.b@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "IFRep.alice.b@gmail.tmt" }, "tm.e2e.IFRep.benny.c": { "googleId": "tm.e2e.IFRep.benny.c", "name": "Benny C.", - "isInstructor": false, - "email": "IFRep.benny.c@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "IFRep.benny.c@gmail.tmt" }, "tm.e2e.IFRep.charlie.d": { "googleId": "tm.e2e.IFRep.charlie.d", "name": "Charlie D.", - "isInstructor": false, - "email": "IFRep.charlie.d@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "IFRep.charlie.d@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorFeedbackSessionsPageE2ETest.json b/src/e2e/resources/data/InstructorFeedbackSessionsPageE2ETest.json index cc4b22e3aab..735ed67a13b 100644 --- a/src/e2e/resources/data/InstructorFeedbackSessionsPageE2ETest.json +++ b/src/e2e/resources/data/InstructorFeedbackSessionsPageE2ETest.json @@ -3,9 +3,7 @@ "instructorWithSessions": { "googleId": "tm.e2e.IFSess.instructor", "name": "Teammates Test", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorHomePageE2ETest.json b/src/e2e/resources/data/InstructorHomePageE2ETest.json index a242bf41fad..c61ecc9f115 100644 --- a/src/e2e/resources/data/InstructorHomePageE2ETest.json +++ b/src/e2e/resources/data/InstructorHomePageE2ETest.json @@ -3,9 +3,7 @@ "IHome.instr": { "googleId": "tm.e2e.IHome.instructor.tmms", "name": "Teammates Test", - "isInstructor": true, - "email": "IHome.instructor.tmms@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "IHome.instructor.tmms@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorSearchPageE2ETest.json b/src/e2e/resources/data/InstructorSearchPageE2ETest.json index 0ce0def9430..94bb149417a 100644 --- a/src/e2e/resources/data/InstructorSearchPageE2ETest.json +++ b/src/e2e/resources/data/InstructorSearchPageE2ETest.json @@ -3,37 +3,27 @@ "instructor1OfCourse1": { "googleId": "tm.e2e.ISearch.instr1", "name": "Instructor 1 of Course 1", - "isInstructor": true, - "email": "ISearch.instr1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ISearch.instr1@gmail.tmt" }, "student1InCourse1": { "googleId": "tm.e2e.ISearch.student1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "ISearch.student1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ISearch.student1@gmail.tmt" }, "student2InCourse1": { "googleId": "tm.e2e.ISearch.student2", "name": "Student in two courses", - "isInstructor": false, - "email": "ISearch.student2@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ISearch.student2@gmail.tmt" }, "student2.2InCourse1": { "googleId": "tm.e2e.ISearch.student2.2", "name": "Student in two courses", - "isInstructor": false, - "email": "ISearch.student2@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ISearch.student2@gmail.tmt" }, "student3InCourse1": { "googleId": "tm.e2e.ISearch.student3", "name": "Student 3 in course 1", - "isInstructor": false, - "email": "ISearch.student3@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ISearch.student3@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorStudentListPageE2ETest.json b/src/e2e/resources/data/InstructorStudentListPageE2ETest.json index b9f77e22b01..bc45064cb4a 100644 --- a/src/e2e/resources/data/InstructorStudentListPageE2ETest.json +++ b/src/e2e/resources/data/InstructorStudentListPageE2ETest.json @@ -3,16 +3,12 @@ "instructorOfCourse1": { "googleId": "tm.e2e.ISList.instr1", "name": "Instructor of Course 1", - "isInstructor": true, - "email": "ISList.instr1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "ISList.instr1@gmail.tmt" }, "Student3Course3": { "googleId": "tm.e2e.ISList.charlie.tmms", "name": "Charlie D", - "isInstructor": false, - "email": "ISList.charlie.tmms@gmail.tmt", - "institute": "TEAMMATES Test Institute 5" + "email": "ISList.charlie.tmms@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/InstructorStudentRecordsPageE2ETest.json b/src/e2e/resources/data/InstructorStudentRecordsPageE2ETest.json index d9ea516cdc5..91126b9ae1e 100644 --- a/src/e2e/resources/data/InstructorStudentRecordsPageE2ETest.json +++ b/src/e2e/resources/data/InstructorStudentRecordsPageE2ETest.json @@ -3,16 +3,12 @@ "teammates.test": { "googleId": "tm.e2e.ISRecords.teammates.test", "name": "Teammates Test", - "isInstructor": true, - "email": "teammates.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "teammates.test@gmail.tmt" }, "benny.c.tmms@ISR.CS2104": { "googleId": "tm.e2e.ISRecords.benny.c.tmms", "name": "Benny Charlés", - "isInstructor": false, - "email": "benny.c.tmms@gmail.tmt", - "institute": "TEAMMATES Test Institute 5" + "email": "benny.c.tmms@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/StudentCourseDetailsPageE2ETest.json b/src/e2e/resources/data/StudentCourseDetailsPageE2ETest.json index 42f56f79e6c..f58fb2f6d06 100644 --- a/src/e2e/resources/data/StudentCourseDetailsPageE2ETest.json +++ b/src/e2e/resources/data/StudentCourseDetailsPageE2ETest.json @@ -3,9 +3,7 @@ "SCDet.instr": { "googleId": "tm.e2e.SCDet.instr", "name": "Instructor", - "isInstructor": true, - "email": "tmms.test@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "tmms.test@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/StudentCourseJoinConfirmationPageE2ETest.json b/src/e2e/resources/data/StudentCourseJoinConfirmationPageE2ETest.json index 5502896ea26..ef85015f583 100644 --- a/src/e2e/resources/data/StudentCourseJoinConfirmationPageE2ETest.json +++ b/src/e2e/resources/data/StudentCourseJoinConfirmationPageE2ETest.json @@ -3,16 +3,12 @@ "SCJoinConf.instr": { "googleId": "tm.e2e.SCJoinConf.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "SCJoinConf.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "SCJoinConf.instr@gmail.tmt" }, "alice.tmms": { "googleId": "tm.e2e.SCJoinConf.alice", "name": "Alice B", - "isInstructor": false, - "email": "SCJoinConf.alice@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "SCJoinConf.alice@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/StudentHomePageE2ETest.json b/src/e2e/resources/data/StudentHomePageE2ETest.json index 5f53da53019..825ef098e08 100644 --- a/src/e2e/resources/data/StudentHomePageE2ETest.json +++ b/src/e2e/resources/data/StudentHomePageE2ETest.json @@ -3,16 +3,12 @@ "SHome.instr": { "googleId": "tm.e2e.SHome.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "SHome.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "SHome.instr@gmail.tmt" }, "SHome.student": { "googleId": "tm.e2e.SHome.student", "name": "Alice B", - "isInstructor": false, - "email": "SHome.student@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "SHome.student@gmail.tmt" } }, "courses": { diff --git a/src/e2e/resources/data/StudentProfilePageE2ETest.json b/src/e2e/resources/data/StudentProfilePageE2ETest.json index a77f8f47458..944881323d7 100644 --- a/src/e2e/resources/data/StudentProfilePageE2ETest.json +++ b/src/e2e/resources/data/StudentProfilePageE2ETest.json @@ -3,9 +3,7 @@ "studentWithExistingProfile": { "googleId": "tm.e2e.SProf.student", "name": "Benny C", - "isInstructor": false, - "email": "SProf.student@gmail.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "SProf.student@gmail.tmt" } }, "courses": { diff --git a/src/lnp/java/teammates/lnp/cases/FeedbackSessionSubmitLNPTest.java b/src/lnp/java/teammates/lnp/cases/FeedbackSessionSubmitLNPTest.java index f0e0c3fb986..7745a6050bb 100644 --- a/src/lnp/java/teammates/lnp/cases/FeedbackSessionSubmitLNPTest.java +++ b/src/lnp/java/teammates/lnp/cases/FeedbackSessionSubmitLNPTest.java @@ -66,8 +66,6 @@ protected Map generateAccounts() { accounts.put(STUDENT_NAME + i, AccountAttributes.builder(STUDENT_NAME + i + ".tmms") .withEmail(STUDENT_EMAIL + i + "@gmail.tmt") .withName(STUDENT_NAME + i) - .withIsInstructor(false) - .withInstitute("TEAMMATES Test Institute 2") .build() ); } diff --git a/src/lnp/java/teammates/lnp/cases/FeedbackSessionViewLNPTest.java b/src/lnp/java/teammates/lnp/cases/FeedbackSessionViewLNPTest.java index 22a948041bd..4462cfef553 100644 --- a/src/lnp/java/teammates/lnp/cases/FeedbackSessionViewLNPTest.java +++ b/src/lnp/java/teammates/lnp/cases/FeedbackSessionViewLNPTest.java @@ -61,8 +61,6 @@ protected Map generateAccounts() { accounts.put(STUDENT_NAME + i, AccountAttributes.builder(STUDENT_NAME + i + ".tmms") .withEmail(STUDENT_EMAIL + i + "@gmail.tmt") .withName(STUDENT_NAME + i) - .withIsInstructor(false) - .withInstitute("TEAMMATES Test Institute 2") .build() ); } diff --git a/src/lnp/java/teammates/lnp/cases/InstructorSessionResultLNPTest.java b/src/lnp/java/teammates/lnp/cases/InstructorSessionResultLNPTest.java index 2d6688bceae..abf846a6d8a 100644 --- a/src/lnp/java/teammates/lnp/cases/InstructorSessionResultLNPTest.java +++ b/src/lnp/java/teammates/lnp/cases/InstructorSessionResultLNPTest.java @@ -63,8 +63,6 @@ protected Map generateAccounts() { accounts.put(STUDENT_NAME + i, AccountAttributes.builder(STUDENT_NAME + i + ".tmms") .withEmail(STUDENT_EMAIL + i + "@gmail.tmt") .withName(STUDENT_NAME + i) - .withIsInstructor(false) - .withInstitute("TEAMMATES Test Institute 2") .build() ); } diff --git a/src/lnp/java/teammates/lnp/cases/StudentProfileLNPTest.java b/src/lnp/java/teammates/lnp/cases/StudentProfileLNPTest.java index db9adb35f5c..3812a03c739 100644 --- a/src/lnp/java/teammates/lnp/cases/StudentProfileLNPTest.java +++ b/src/lnp/java/teammates/lnp/cases/StudentProfileLNPTest.java @@ -50,8 +50,6 @@ protected Map generateAccounts() { accounts.put(STUDENT_NAME + i, AccountAttributes.builder(STUDENT_NAME + i + ".tmms") .withEmail(STUDENT_EMAIL + i + "@gmail.tmt") .withName(STUDENT_NAME + i) - .withIsInstructor(false) - .withInstitute("TEAMMATES Test Institute 1") .build() ); } diff --git a/src/main/java/teammates/common/datatransfer/attributes/AccountAttributes.java b/src/main/java/teammates/common/datatransfer/attributes/AccountAttributes.java index cdd76c4e529..3b066f9f43b 100644 --- a/src/main/java/teammates/common/datatransfer/attributes/AccountAttributes.java +++ b/src/main/java/teammates/common/datatransfer/attributes/AccountAttributes.java @@ -10,6 +10,8 @@ import teammates.common.util.SanitizationHelper; import teammates.storage.entity.Account; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * The data transfer object for {@link Account} entities. */ @@ -17,9 +19,7 @@ public class AccountAttributes extends EntityAttributes { private String googleId; private String name; - private boolean isInstructor; private String email; - private String institute; private Instant createdAt; private AccountAttributes(String googleId) { @@ -33,9 +33,7 @@ public static AccountAttributes valueOf(Account a) { AccountAttributes accountAttributes = new AccountAttributes(a.getGoogleId()); accountAttributes.name = a.getName(); - accountAttributes.isInstructor = a.isInstructor(); accountAttributes.email = a.getEmail(); - accountAttributes.institute = a.getInstitute(); accountAttributes.createdAt = a.getCreatedAt(); return accountAttributes; @@ -55,22 +53,12 @@ public AccountAttributes getCopy() { AccountAttributes accountAttributes = new AccountAttributes(this.googleId); accountAttributes.name = this.name; - accountAttributes.isInstructor = this.isInstructor; accountAttributes.email = this.email; - accountAttributes.institute = this.institute; accountAttributes.createdAt = this.createdAt; return accountAttributes; } - public boolean isInstructor() { - return isInstructor; - } - - public void setInstructor(boolean instructor) { - isInstructor = instructor; - } - public String getGoogleId() { return googleId; } @@ -95,14 +83,6 @@ public void setEmail(String email) { this.email = email; } - public String getInstitute() { - return institute; - } - - public void setInstitute(String institute) { - this.institute = institute; - } - public Instant getCreatedAt() { return createdAt; } @@ -121,16 +101,14 @@ public List getInvalidityInfo() { addNonEmptyError(FieldValidator.getInvalidityInfoForEmail(email), errors); - addNonEmptyError(FieldValidator.getInvalidityInfoForInstituteName(institute), errors); - - // No validation for isInstructor and createdAt fields. + // No validation necessary for createdAt field. return errors; } @Override public Account toEntity() { - return new Account(googleId, name, isInstructor, email, institute); + return new Account(googleId, name, email); } @Override @@ -140,10 +118,7 @@ public String toString() { @Override public int hashCode() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(this.email).append(this.name) - .append(this.institute).append(this.googleId); - return stringBuilder.toString().hashCode(); + return (this.email + this.name + this.googleId).hashCode(); } @Override @@ -156,7 +131,6 @@ public boolean equals(Object other) { AccountAttributes otherAccount = (AccountAttributes) other; return Objects.equals(this.email, otherAccount.email) && Objects.equals(this.name, otherAccount.name) - && Objects.equals(this.institute, otherAccount.institute) && Objects.equals(this.googleId, otherAccount.googleId); } else { return false; @@ -168,14 +142,13 @@ public void sanitizeForSaving() { this.googleId = SanitizationHelper.sanitizeGoogleId(googleId); this.name = SanitizationHelper.sanitizeName(name); this.email = SanitizationHelper.sanitizeEmail(email); - this.institute = SanitizationHelper.sanitizeTitle(institute); } /** * Updates with {@link UpdateOptions}. */ public void update(UpdateOptions updateOptions) { - updateOptions.isInstructorOption.ifPresent(s -> isInstructor = s); + // currently, account does not have any updatable field } /** @@ -213,13 +186,6 @@ public Builder withEmail(String email) { return this; } - public Builder withInstitute(String institute) { - assert institute != null; - - accountAttributes.institute = institute; - return this; - } - @Override public AccountAttributes build() { accountAttributes.update(updateOptions); @@ -234,8 +200,6 @@ public AccountAttributes build() { public static class UpdateOptions { private String googleId; - private UpdateOption isInstructorOption = UpdateOption.empty(); - private UpdateOptions(String googleId) { assert googleId != null; @@ -250,7 +214,6 @@ public String getGoogleId() { public String toString() { return "AccountAttributes.UpdateOptions [" + "googleId = " + googleId - + ", isInstructor = " + isInstructorOption + "]"; } @@ -282,17 +245,13 @@ public UpdateOptions build() { private abstract static class BasicBuilder> { UpdateOptions updateOptions; + @SuppressFBWarnings("URF_UNREAD_FIELD") B thisBuilder; BasicBuilder(UpdateOptions updateOptions) { this.updateOptions = updateOptions; } - public B withIsInstructor(boolean isInstructor) { - updateOptions.isInstructorOption = UpdateOption.of(isInstructor); - return thisBuilder; - } - public abstract T build(); } diff --git a/src/main/java/teammates/common/util/Const.java b/src/main/java/teammates/common/util/Const.java index 0e02878494e..68a388fec71 100644 --- a/src/main/java/teammates/common/util/Const.java +++ b/src/main/java/teammates/common/util/Const.java @@ -312,7 +312,6 @@ public static class ResourceURIs { public static final String AUTH_REGKEY = URI_PREFIX + "/auth/regkey"; public static final String ACCOUNT = URI_PREFIX + "/account"; public static final String ACCOUNT_RESET = URI_PREFIX + "/account/reset"; - public static final String ACCOUNT_DOWNGRADE = URI_PREFIX + "/account/downgrade"; public static final String ACCOUNT_REQUEST = URI_PREFIX + "/account/request"; public static final String ACCOUNT_REQUEST_RESET = ACCOUNT_REQUEST + "/reset"; public static final String ACCOUNTS = URI_PREFIX + "/accounts"; diff --git a/src/main/java/teammates/logic/api/Logic.java b/src/main/java/teammates/logic/api/Logic.java index 289b9d31b4c..3d44da550eb 100644 --- a/src/main/java/teammates/logic/api/Logic.java +++ b/src/main/java/teammates/logic/api/Logic.java @@ -399,20 +399,6 @@ public InstructorAttributes joinCourseForInstructor(String regkey, String google return accountsLogic.joinCourseForInstructor(regkey, googleId); } - /** - * Downgrades an instructor account to student account. - * - *

Cascade deletes all instructors associated with the account. - * - *
Preconditions:
- * * All parameters are non-null. - */ - public void downgradeInstructorToStudentCascade(String googleId) throws EntityDoesNotExistException { - assert googleId != null; - - accountsLogic.downgradeInstructorToStudentCascade(googleId); - } - /** * Deletes an instructor cascade its associated feedback responses, deadline extensions and comments. * diff --git a/src/main/java/teammates/logic/api/UserProvision.java b/src/main/java/teammates/logic/api/UserProvision.java index c20258d4828..d213a54a1a5 100644 --- a/src/main/java/teammates/logic/api/UserProvision.java +++ b/src/main/java/teammates/logic/api/UserProvision.java @@ -3,7 +3,7 @@ import teammates.common.datatransfer.UserInfo; import teammates.common.datatransfer.UserInfoCookie; import teammates.common.util.Config; -import teammates.logic.core.AccountsLogic; +import teammates.logic.core.InstructorsLogic; import teammates.logic.core.StudentsLogic; /** @@ -13,7 +13,7 @@ public class UserProvision { private static final UserProvision instance = new UserProvision(); - private final AccountsLogic accountsLogic = AccountsLogic.inst(); + private final InstructorsLogic instructorsLogic = InstructorsLogic.inst(); private final StudentsLogic studentsLogic = StudentsLogic.inst(); UserProvision() { @@ -36,7 +36,7 @@ public UserInfo getCurrentUser(UserInfoCookie uic) { String userId = user.id; user.isAdmin = Config.APP_ADMINS.contains(userId); - user.isInstructor = accountsLogic.isAccountAnInstructor(userId); + user.isInstructor = instructorsLogic.isInstructorInAnyCourse(userId); user.isStudent = studentsLogic.isStudentInAnyCourse(userId); user.isMaintainer = Config.APP_MAINTAINERS.contains(user.getId()); return user; @@ -56,7 +56,7 @@ UserInfo getCurrentLoggedInUser(UserInfoCookie uic) { public UserInfo getMasqueradeUser(String googleId) { UserInfo userInfo = new UserInfo(googleId); userInfo.isAdmin = false; - userInfo.isInstructor = accountsLogic.isAccountAnInstructor(googleId); + userInfo.isInstructor = instructorsLogic.isInstructorInAnyCourse(googleId); userInfo.isStudent = studentsLogic.isStudentInAnyCourse(googleId); userInfo.isMaintainer = Config.APP_MAINTAINERS.contains(googleId); return userInfo; diff --git a/src/main/java/teammates/logic/core/AccountsLogic.java b/src/main/java/teammates/logic/core/AccountsLogic.java index d4183c4888d..eaa1e0da3c3 100644 --- a/src/main/java/teammates/logic/core/AccountsLogic.java +++ b/src/main/java/teammates/logic/core/AccountsLogic.java @@ -69,14 +69,6 @@ public List getAccountsForEmail(String email) { return accountsDb.getAccountsForEmail(email); } - /** - * Returns true if the given account exists and is an instructor. - */ - public boolean isAccountAnInstructor(String googleId) { - AccountAttributes a = accountsDb.getAccount(googleId); - return a != null && a.isInstructor(); - } - /** * Joins the user as a student. */ @@ -124,21 +116,16 @@ public InstructorAttributes joinCourseForInstructor(String key, String googleId) } AccountAttributes account = accountsDb.getAccount(googleId); - String instituteToSave = coursesLogic.getCourseInstitute(instructor.getCourseId()); if (account == null) { try { createAccount(AccountAttributes.builder(googleId) .withName(instructor.getName()) .withEmail(instructor.getEmail()) - .withInstitute(instituteToSave) - .withIsInstructor(true) .build()); } catch (EntityAlreadyExistsException e) { assert false : "Account already exists."; } - } else { - makeAccountInstructor(googleId); } // Update the googleId of the student entity for the instructor which was created from sample data. @@ -165,7 +152,7 @@ private InstructorAttributes validateInstructorJoinRequest(String registrationKe if (instructorForKey.isRegistered()) { if (instructorForKey.getGoogleId().equals(googleId)) { AccountAttributes existingAccount = accountsDb.getAccount(googleId); - if (existingAccount != null && existingAccount.isInstructor()) { + if (existingAccount != null) { throw new EntityAlreadyExistsException("Instructor has already joined course"); } } else { @@ -208,37 +195,6 @@ private StudentAttributes validateStudentJoinRequest(String registrationKey, Str return studentRole; } - /** - * Downgrades an instructor account to student account. - * - *

Cascade deletes all instructors associated with the account. - */ - public void downgradeInstructorToStudentCascade(String googleId) throws EntityDoesNotExistException { - instructorsLogic.deleteInstructorsForGoogleIdCascade(googleId); - - try { - accountsDb.updateAccount( - AccountAttributes.updateOptionsBuilder(googleId) - .withIsInstructor(false) - .build() - ); - } catch (InvalidParametersException e) { - assert false : "Invalid account data detected unexpectedly " - + "while removing instruction privileges from account " + googleId + ": " + e.getMessage(); - } - } - - /** - * Makes an account as an instructor account. - */ - void makeAccountInstructor(String googleId) throws InvalidParametersException, EntityDoesNotExistException { - accountsDb.updateAccount( - AccountAttributes.updateOptionsBuilder(googleId) - .withIsInstructor(true) - .build() - ); - } - /** * Deletes both instructor and student privileges, as well as the account and associated student profile. * @@ -277,8 +233,6 @@ private void createStudentAccount(StudentAttributes student) AccountAttributes account = AccountAttributes.builder(student.getGoogleId()) .withEmail(student.getEmail()) .withName(student.getName()) - .withIsInstructor(false) - .withInstitute(coursesLogic.getCourseInstitute(student.getCourse())) .build(); accountsDb.createEntity(account); diff --git a/src/main/java/teammates/logic/core/CoursesLogic.java b/src/main/java/teammates/logic/core/CoursesLogic.java index b351a4e2c9c..b679609ca35 100644 --- a/src/main/java/teammates/logic/core/CoursesLogic.java +++ b/src/main/java/teammates/logic/core/CoursesLogic.java @@ -102,8 +102,6 @@ public void createCourseAndInstructor(String instructorGoogleId, CourseAttribute AccountAttributes courseCreator = accountsLogic.getAccount(instructorGoogleId); assert courseCreator != null : "Trying to create a course for a non-existent instructor :" + instructorGoogleId; - assert courseCreator.isInstructor() - : "Trying to create a course for a person who doesn't have instructor privileges :" + instructorGoogleId; CourseAttributes createdCourse = createCourse(courseToCreate); diff --git a/src/main/java/teammates/logic/core/DataBundleLogic.java b/src/main/java/teammates/logic/core/DataBundleLogic.java index de4fcc75885..afeb3584b3d 100644 --- a/src/main/java/teammates/logic/core/DataBundleLogic.java +++ b/src/main/java/teammates/logic/core/DataBundleLogic.java @@ -348,8 +348,6 @@ private AccountAttributes makeAccount(InstructorAttributes instructor) { return AccountAttributes.builder(instructor.getGoogleId()) .withName(instructor.getName()) .withEmail(instructor.getEmail()) - .withInstitute("TEAMMATES Test Institute 1") - .withIsInstructor(true) .build(); } @@ -357,8 +355,6 @@ private AccountAttributes makeAccount(StudentAttributes student) { return AccountAttributes.builder(student.getGoogleId()) .withName(student.getName()) .withEmail(student.getEmail()) - .withInstitute("TEAMMATES Test Institute 1") - .withIsInstructor(false) .build(); } diff --git a/src/main/java/teammates/logic/core/InstructorsLogic.java b/src/main/java/teammates/logic/core/InstructorsLogic.java index 3d668ce6e51..0af7387f933 100644 --- a/src/main/java/teammates/logic/core/InstructorsLogic.java +++ b/src/main/java/teammates/logic/core/InstructorsLogic.java @@ -419,6 +419,13 @@ public InstructorAttributes regenerateInstructorRegistrationKey(String courseId, return instructorsDb.regenerateEntityKey(originalInstructor); } + /** + * Returns true if the user associated with the googleId is an instructor in any course in the system. + */ + public boolean isInstructorInAnyCourse(String googleId) { + return instructorsDb.hasInstructorsForGoogleId(googleId); + } + /** * Gets the number of instructors created within a specified time range. */ diff --git a/src/main/java/teammates/logic/core/StudentsLogic.java b/src/main/java/teammates/logic/core/StudentsLogic.java index 95af9f9d109..c14ace7857e 100644 --- a/src/main/java/teammates/logic/core/StudentsLogic.java +++ b/src/main/java/teammates/logic/core/StudentsLogic.java @@ -184,7 +184,7 @@ public void verifyAllStudentsExistInCourse(String courseId, Collection s * Returns true if the user associated with the googleId is a student in any course in the system. */ public boolean isStudentInAnyCourse(String googleId) { - return !getStudentsForGoogleId(googleId).isEmpty(); + return studentsDb.hasStudentsForGoogleId(googleId); } /** diff --git a/src/main/java/teammates/storage/api/AccountsDb.java b/src/main/java/teammates/storage/api/AccountsDb.java index 61ecc01d255..559f6d71ef2 100644 --- a/src/main/java/teammates/storage/api/AccountsDb.java +++ b/src/main/java/teammates/storage/api/AccountsDb.java @@ -74,15 +74,13 @@ public AccountAttributes updateAccount(AccountAttributes.UpdateOptions updateOpt throw new InvalidParametersException(newAttributes.getInvalidityInfo()); } - // update only if change - boolean hasSameAttributes = this.hasSameValue(account.isInstructor(), newAttributes.isInstructor()); + // currently, account does not have any updatable field + boolean hasSameAttributes = true; if (hasSameAttributes) { log.info(String.format(OPTIMIZED_SAVING_POLICY_APPLIED, Account.class.getSimpleName(), updateOptions)); return newAttributes; } - account.setIsInstructor(newAttributes.isInstructor()); - saveEntity(account); return makeAttributes(account); diff --git a/src/main/java/teammates/storage/api/InstructorsDb.java b/src/main/java/teammates/storage/api/InstructorsDb.java index 5e64b17786e..ce021f52d4e 100644 --- a/src/main/java/teammates/storage/api/InstructorsDb.java +++ b/src/main/java/teammates/storage/api/InstructorsDb.java @@ -12,6 +12,7 @@ import com.googlecode.objectify.Key; import com.googlecode.objectify.cmd.LoadType; +import com.googlecode.objectify.cmd.Query; import teammates.common.datatransfer.AttributesDeletionQuery; import teammates.common.datatransfer.attributes.InstructorAttributes; @@ -346,9 +347,8 @@ public void deleteInstructors(AttributesDeletionQuery query) { } private Instructor getInstructorEntityForGoogleId(String courseId, String googleId) { - return load() + return getInstructorsForGoogleIdQuery(googleId) .filter("courseId =", courseId) - .filter("googleId =", googleId) .first().now(); } @@ -386,8 +386,19 @@ private Instructor getInstructorEntityForRegistrationKey(String key) { return instructorList.get(0); } + /** + * Returns true if there are any instructor entities associated with the googleId. + */ + public boolean hasInstructorsForGoogleId(String googleId) { + return !getInstructorsForGoogleIdQuery(googleId).keys().list().isEmpty(); + } + + private Query getInstructorsForGoogleIdQuery(String googleId) { + return load().filter("googleId =", googleId); + } + private List getInstructorEntitiesForGoogleId(String googleId) { - return load().filter("googleId =", googleId).list(); + return getInstructorsForGoogleIdQuery(googleId).list(); } /** @@ -396,8 +407,7 @@ private List getInstructorEntitiesForGoogleId(String googleId) { */ private List getInstructorEntitiesForGoogleId(String googleId, boolean omitArchived) { if (omitArchived) { - return load() - .filter("googleId =", googleId) + return getInstructorsForGoogleIdQuery(googleId) .filter("isArchived =", false) .list(); } diff --git a/src/main/java/teammates/storage/api/StudentsDb.java b/src/main/java/teammates/storage/api/StudentsDb.java index b0b31b80584..3a757f15f03 100644 --- a/src/main/java/teammates/storage/api/StudentsDb.java +++ b/src/main/java/teammates/storage/api/StudentsDb.java @@ -393,6 +393,13 @@ private List getCourseStudentEntitiesForCourse(String courseId, i return getCourseStudentsForCourseQuery(courseId, batchSize).list(); } + /** + * Returns true if there are any student entities associated with the googleId. + */ + public boolean hasStudentsForGoogleId(String googleId) { + return !getCourseStudentsForGoogleIdQuery(googleId).keys().list().isEmpty(); + } + private Query getCourseStudentsForGoogleIdQuery(String googleId) { return load().filter("googleId =", googleId); } diff --git a/src/main/java/teammates/storage/entity/Account.java b/src/main/java/teammates/storage/entity/Account.java index fa11f68d921..d004fd819f1 100644 --- a/src/main/java/teammates/storage/entity/Account.java +++ b/src/main/java/teammates/storage/entity/Account.java @@ -19,12 +19,8 @@ public class Account extends BaseEntity { private String name; - private boolean isInstructor; - private String email; - private String institute; - @Translate(InstantTranslatorFactory.class) private Instant createdAt; @@ -36,24 +32,14 @@ private Account() { /** * Instantiates a new account. * - * @param googleId - * the Google ID of the user. - * @param name - * The name of the user. - * @param isInstructor - * Does this account has instructor privileges? - * @param email - * The official email of the user. - * @param institute - * The university/school/institute e.g., "Abrons State University, Alaska" + * @param googleId the Google ID of the user. + * @param name The name of the user. + * @param email The official email of the user. */ - public Account(String googleId, String name, boolean isInstructor, - String email, String institute) { + public Account(String googleId, String name, String email) { this.setGoogleId(googleId); this.setName(name); - this.setIsInstructor(isInstructor); this.setEmail(email); - this.setInstitute(institute); this.setCreatedAt(Instant.now()); } @@ -73,14 +59,6 @@ public void setName(String name) { this.name = name; } - public boolean isInstructor() { - return isInstructor; - } - - public void setIsInstructor(boolean accountIsInstructor) { - this.isInstructor = accountIsInstructor; - } - public String getEmail() { return email; } @@ -89,14 +67,6 @@ public void setEmail(String email) { this.email = email; } - public String getInstitute() { - return institute; - } - - public void setInstitute(String institute) { - this.institute = institute; - } - public Instant getCreatedAt() { return createdAt; } diff --git a/src/main/java/teammates/ui/constants/ResourceEndpoints.java b/src/main/java/teammates/ui/constants/ResourceEndpoints.java index 8631a3dd0f5..9cc58c3259d 100644 --- a/src/main/java/teammates/ui/constants/ResourceEndpoints.java +++ b/src/main/java/teammates/ui/constants/ResourceEndpoints.java @@ -14,7 +14,6 @@ public enum ResourceEndpoints { AUTH_REGKEY(ResourceURIs.AUTH_REGKEY), ACCOUNT(ResourceURIs.ACCOUNT), ACCOUNT_RESET(ResourceURIs.ACCOUNT_RESET), - ACCOUNT_DOWNGRADE(ResourceURIs.ACCOUNT_DOWNGRADE), ACCOUNT_REQUEST(ResourceURIs.ACCOUNT_REQUEST), ACCOUNT_REQUEST_RESET(ResourceURIs.ACCOUNT_REQUEST_RESET), ACCOUNTS(ResourceURIs.ACCOUNTS), diff --git a/src/main/java/teammates/ui/output/AccountData.java b/src/main/java/teammates/ui/output/AccountData.java index 17700bd83b9..a954fcdcd9e 100644 --- a/src/main/java/teammates/ui/output/AccountData.java +++ b/src/main/java/teammates/ui/output/AccountData.java @@ -9,22 +9,12 @@ public class AccountData extends ApiOutput { private final String googleId; private final String name; - private final boolean isInstructor; private final String email; - private final String institute; - private final long createdAtTimeStamp; public AccountData(AccountAttributes accountInfo) { this.googleId = accountInfo.getGoogleId(); this.name = accountInfo.getName(); - this.isInstructor = accountInfo.isInstructor(); this.email = accountInfo.getEmail(); - this.institute = accountInfo.getInstitute(); - this.createdAtTimeStamp = accountInfo.getCreatedAt().toEpochMilli(); - } - - public String getInstitute() { - return institute; } public String getEmail() { @@ -35,15 +25,8 @@ public String getGoogleId() { return googleId; } - public long getCreatedAtTimeStamp() { - return createdAtTimeStamp; - } - public String getName() { return name; } - public boolean isInstructor() { - return this.isInstructor; - } } diff --git a/src/main/java/teammates/ui/output/AuthInfo.java b/src/main/java/teammates/ui/output/AuthInfo.java index 26f2f45cff9..696b2bbed63 100644 --- a/src/main/java/teammates/ui/output/AuthInfo.java +++ b/src/main/java/teammates/ui/output/AuthInfo.java @@ -19,8 +19,6 @@ public class AuthInfo extends ApiOutput { private final String maintainerLoginUrl; @Nullable private final UserInfo user; - @Nullable - private final String institute; private final boolean masquerade; public AuthInfo(String studentLoginUrl, String instructorLoginUrl, String adminLoginUrl, String maintainerLoginUrl) { @@ -29,17 +27,15 @@ public AuthInfo(String studentLoginUrl, String instructorLoginUrl, String adminL this.adminLoginUrl = adminLoginUrl; this.maintainerLoginUrl = maintainerLoginUrl; this.user = null; - this.institute = null; this.masquerade = false; } - public AuthInfo(UserInfo user, String institute, boolean masquerade) { + public AuthInfo(UserInfo user, boolean masquerade) { this.studentLoginUrl = null; this.instructorLoginUrl = null; this.adminLoginUrl = null; this.maintainerLoginUrl = null; this.user = user; - this.institute = institute; this.masquerade = masquerade; } @@ -63,10 +59,6 @@ public UserInfo getUser() { return user; } - public String getInstitute() { - return institute; - } - public boolean isMasquerade() { return masquerade; } diff --git a/src/main/java/teammates/ui/webapi/Action.java b/src/main/java/teammates/ui/webapi/Action.java index c25eac5a8eb..d7ce35d0779 100644 --- a/src/main/java/teammates/ui/webapi/Action.java +++ b/src/main/java/teammates/ui/webapi/Action.java @@ -274,6 +274,24 @@ Optional getUnregisteredInstructor() { return Optional.empty(); } + InstructorAttributes getPossiblyUnregisteredInstructor(String courseId) { + return getUnregisteredInstructor().orElseGet(() -> { + if (userInfo == null) { + return null; + } + return logic.getInstructorForGoogleId(courseId, userInfo.getId()); + }); + } + + StudentAttributes getPossiblyUnregisteredStudent(String courseId) { + return getUnregisteredStudent().orElseGet(() -> { + if (userInfo == null) { + return null; + } + return logic.getStudentForGoogleId(courseId, userInfo.getId()); + }); + } + InstructorPermissionSet constructInstructorPrivileges(InstructorAttributes instructor, String feedbackSessionName) { InstructorPermissionSet privilege = instructor.getPrivileges().getCourseLevelPrivileges(); if (feedbackSessionName != null) { diff --git a/src/main/java/teammates/ui/webapi/ActionFactory.java b/src/main/java/teammates/ui/webapi/ActionFactory.java index 88e32cd5567..42dfe849caa 100644 --- a/src/main/java/teammates/ui/webapi/ActionFactory.java +++ b/src/main/java/teammates/ui/webapi/ActionFactory.java @@ -44,7 +44,6 @@ public final class ActionFactory { map(ResourceURIs.ACCOUNT, GET, GetAccountAction.class); map(ResourceURIs.ACCOUNT, POST, CreateAccountAction.class); map(ResourceURIs.ACCOUNT, DELETE, DeleteAccountAction.class); - map(ResourceURIs.ACCOUNT_DOWNGRADE, PUT, DowngradeAccountAction.class); map(ResourceURIs.ACCOUNT_RESET, PUT, ResetAccountAction.class); map(ResourceURIs.ACCOUNT_REQUEST, GET, GetAccountRequestAction.class); map(ResourceURIs.ACCOUNT_REQUEST, POST, CreateAccountRequestAction.class); diff --git a/src/main/java/teammates/ui/webapi/BasicFeedbackSubmissionAction.java b/src/main/java/teammates/ui/webapi/BasicFeedbackSubmissionAction.java index 704d27e4be4..f406260a63d 100644 --- a/src/main/java/teammates/ui/webapi/BasicFeedbackSubmissionAction.java +++ b/src/main/java/teammates/ui/webapi/BasicFeedbackSubmissionAction.java @@ -51,12 +51,7 @@ StudentAttributes getStudentOfCourseFromRequest(String courseId) { } else if (!StringHelper.isEmpty(previewAsPerson)) { return logic.getStudentForEmail(courseId, previewAsPerson); } else { - return getUnregisteredStudent().orElseGet(() -> { - if (userInfo == null) { - return null; - } - return logic.getStudentForGoogleId(courseId, userInfo.getId()); - }); + return getPossiblyUnregisteredStudent(courseId); } } @@ -109,12 +104,7 @@ InstructorAttributes getInstructorOfCourseFromRequest(String courseId) { } else if (!StringHelper.isEmpty(previewAsPerson)) { return logic.getInstructorForEmail(courseId, previewAsPerson); } else { - return getUnregisteredInstructor().orElseGet(() -> { - if (userInfo == null) { - return null; - } - return logic.getInstructorForGoogleId(courseId, userInfo.getId()); - }); + return getPossiblyUnregisteredInstructor(courseId); } } diff --git a/src/main/java/teammates/ui/webapi/CreateCourseAction.java b/src/main/java/teammates/ui/webapi/CreateCourseAction.java index f754ebf8aff..c651f04d73b 100644 --- a/src/main/java/teammates/ui/webapi/CreateCourseAction.java +++ b/src/main/java/teammates/ui/webapi/CreateCourseAction.java @@ -1,13 +1,14 @@ package teammates.ui.webapi; -import teammates.common.datatransfer.attributes.AccountAttributes; +import java.util.List; +import java.util.Objects; + import teammates.common.datatransfer.attributes.CourseAttributes; import teammates.common.datatransfer.attributes.InstructorAttributes; import teammates.common.exception.EntityAlreadyExistsException; import teammates.common.exception.InvalidParametersException; import teammates.common.util.Const; import teammates.common.util.FieldValidator; -import teammates.common.util.StringHelper; import teammates.ui.output.CourseData; import teammates.ui.request.CourseCreateRequest; import teammates.ui.request.InvalidHttpRequestBodyException; @@ -27,6 +28,20 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { if (!userInfo.isInstructor) { throw new UnauthorizedAccessException("Instructor privilege is required to access this resource."); } + + String institute = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_INSTITUTION); + + List existingInstructors = logic.getInstructorsForGoogleId(userInfo.getId()); + boolean canCreateCourse = existingInstructors + .stream() + .filter(InstructorAttributes::hasCoownerPrivileges) + .map(instructor -> logic.getCourse(instructor.getCourseId())) + .filter(Objects::nonNull) + .anyMatch(course -> institute.equals(course.getInstitute())); + if (!canCreateCourse) { + throw new UnauthorizedAccessException("You are not allowed to create a course under this institute. " + + "If you wish to do so, please request for an account under the institute.", true); + } } @Override @@ -42,12 +57,7 @@ public JsonResult execute() throws InvalidHttpRequestBodyException, InvalidOpera String newCourseId = courseCreateRequest.getCourseId(); String newCourseName = courseCreateRequest.getCourseName(); - - String institute = Const.UNKNOWN_INSTITUTION; - AccountAttributes account = logic.getAccount(userInfo.getId()); - if (account != null && !StringHelper.isEmpty(account.getInstitute())) { - institute = account.getInstitute(); - } + String institute = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_INSTITUTION); CourseAttributes courseAttributes = CourseAttributes.builder(newCourseId) diff --git a/src/main/java/teammates/ui/webapi/DowngradeAccountAction.java b/src/main/java/teammates/ui/webapi/DowngradeAccountAction.java deleted file mode 100644 index c916a9f8a60..00000000000 --- a/src/main/java/teammates/ui/webapi/DowngradeAccountAction.java +++ /dev/null @@ -1,24 +0,0 @@ -package teammates.ui.webapi; - -import teammates.common.exception.EntityDoesNotExistException; -import teammates.common.util.Const; - -/** - * Action: downgrades an instructor account to student account. - */ -class DowngradeAccountAction extends AdminOnlyAction { - - @Override - public JsonResult execute() { - String instructorId = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_ID); - - try { - logic.downgradeInstructorToStudentCascade(instructorId); - } catch (EntityDoesNotExistException e) { - throw new EntityNotFoundException(e); - } - - return new JsonResult("Instructor account is successfully downgraded to student."); - } - -} diff --git a/src/main/java/teammates/ui/webapi/GetAuthInfoAction.java b/src/main/java/teammates/ui/webapi/GetAuthInfoAction.java index 63536b1e5c3..ed2aaa444ea 100644 --- a/src/main/java/teammates/ui/webapi/GetAuthInfoAction.java +++ b/src/main/java/teammates/ui/webapi/GetAuthInfoAction.java @@ -5,7 +5,6 @@ import javax.servlet.http.Cookie; -import teammates.common.datatransfer.attributes.AccountAttributes; import teammates.common.util.Const; import teammates.common.util.HttpRequestHelper; import teammates.common.util.StringHelper; @@ -54,10 +53,7 @@ public JsonResult execute() { ); } } else { - String googleId = userInfo.getId(); - AccountAttributes accountInfo = logic.getAccount(googleId); - String institute = accountInfo == null ? null : accountInfo.getInstitute(); - output = new AuthInfo(userInfo, institute, authType == AuthType.MASQUERADE); + output = new AuthInfo(userInfo, authType == AuthType.MASQUERADE); } String csrfToken = StringHelper.encrypt(req.getSession().getId()); diff --git a/src/main/java/teammates/ui/webapi/GetCourseAction.java b/src/main/java/teammates/ui/webapi/GetCourseAction.java index b938b730823..10ab50618bc 100644 --- a/src/main/java/teammates/ui/webapi/GetCourseAction.java +++ b/src/main/java/teammates/ui/webapi/GetCourseAction.java @@ -13,28 +13,26 @@ class GetCourseAction extends Action { @Override AuthType getMinAuthLevel() { - return AuthType.LOGGED_IN; + return AuthType.PUBLIC; } @Override void checkSpecificAccessControl() throws UnauthorizedAccessException { - if (userInfo.isAdmin) { + if (userInfo != null && userInfo.isAdmin) { return; } String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); String entityType = getNonNullRequestParamValue(Const.ParamsNames.ENTITY_TYPE); + CourseAttributes course = logic.getCourse(courseId); - if (userInfo.isInstructor && Const.EntityType.INSTRUCTOR.equals(entityType)) { - gateKeeper.verifyAccessible( - logic.getInstructorForGoogleId(courseId, userInfo.getId()), - logic.getCourse(courseId)); + if (Const.EntityType.INSTRUCTOR.equals(entityType)) { + gateKeeper.verifyAccessible(getPossiblyUnregisteredInstructor(courseId), course); return; } - if (userInfo.isStudent && Const.EntityType.STUDENT.equals(entityType)) { - CourseAttributes course = logic.getCourse(courseId); - gateKeeper.verifyAccessible(logic.getStudentForGoogleId(courseId, userInfo.getId()), course); + if (Const.EntityType.STUDENT.equals(entityType)) { + gateKeeper.verifyAccessible(getPossiblyUnregisteredStudent(courseId), course); return; } @@ -49,13 +47,15 @@ public JsonResult execute() { throw new EntityNotFoundException("No course with id: " + courseId); } CourseData output = new CourseData(courseAttributes); - String entityType = getNonNullRequestParamValue(Const.ParamsNames.ENTITY_TYPE); + String entityType = getRequestParamValue(Const.ParamsNames.ENTITY_TYPE); if (Const.EntityType.INSTRUCTOR.equals(entityType)) { - InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, userInfo.getId()); + InstructorAttributes instructor = getPossiblyUnregisteredInstructor(courseId); if (instructor != null) { InstructorPermissionSet privilege = constructInstructorPrivileges(instructor, null); output.setPrivileges(privilege); } + } else if (Const.EntityType.STUDENT.equals(entityType)) { + output.hideInformationForStudent(); } return new JsonResult(output); } diff --git a/src/main/java/teammates/ui/webapi/GetSessionResultsAction.java b/src/main/java/teammates/ui/webapi/GetSessionResultsAction.java index 7f0ac5e9c8e..a84d06d0d31 100644 --- a/src/main/java/teammates/ui/webapi/GetSessionResultsAction.java +++ b/src/main/java/teammates/ui/webapi/GetSessionResultsAction.java @@ -32,14 +32,14 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { gateKeeper.verifyAccessible(instructor, fs); break; case INSTRUCTOR_RESULT: - instructor = getInstructor(courseId); + instructor = getPossiblyUnregisteredInstructor(courseId); gateKeeper.verifyAccessible(instructor, fs); if (!fs.isPublished()) { throw new UnauthorizedAccessException("This feedback session is not yet published.", true); } break; case STUDENT_RESULT: - StudentAttributes student = getStudent(courseId); + StudentAttributes student = getPossiblyUnregisteredStudent(courseId); gateKeeper.verifyAccessible(student, fs); if (!fs.isPublished()) { throw new UnauthorizedAccessException("This feedback session is not yet published.", true); @@ -53,24 +53,6 @@ void checkSpecificAccessControl() throws UnauthorizedAccessException { } } - private InstructorAttributes getInstructor(String courseId) { - return getUnregisteredInstructor().orElseGet(() -> { - if (userInfo == null) { - return null; - } - return logic.getInstructorForGoogleId(courseId, userInfo.getId()); - }); - } - - private StudentAttributes getStudent(String courseId) { - return getUnregisteredStudent().orElseGet(() -> { - if (userInfo == null) { - return null; - } - return logic.getStudentForGoogleId(courseId, userInfo.getId()); - }); - } - @Override public JsonResult execute() { String courseId = getNonNullRequestParamValue(Const.ParamsNames.COURSE_ID); @@ -94,7 +76,7 @@ public JsonResult execute() { return new JsonResult(SessionResultsData.initForInstructor(bundle)); case INSTRUCTOR_RESULT: // Section name filter is not applicable here - instructor = getInstructor(courseId); + instructor = getPossiblyUnregisteredInstructor(courseId); bundle = logic.getSessionResultsForUser(feedbackSessionName, courseId, instructor.getEmail(), true, questionId); @@ -107,7 +89,7 @@ public JsonResult execute() { return new JsonResult(SessionResultsData.initForStudent(bundle, student)); case STUDENT_RESULT: // Section name filter is not applicable here - student = getStudent(courseId); + student = getPossiblyUnregisteredStudent(courseId); bundle = logic.getSessionResultsForUser(feedbackSessionName, courseId, student.getEmail(), false, questionId); diff --git a/src/main/java/teammates/ui/webapi/GetStudentAction.java b/src/main/java/teammates/ui/webapi/GetStudentAction.java index 979280c1e58..be40c5de2ec 100644 --- a/src/main/java/teammates/ui/webapi/GetStudentAction.java +++ b/src/main/java/teammates/ui/webapi/GetStudentAction.java @@ -61,13 +61,7 @@ public JsonResult execute() { String studentEmail = getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL); if (studentEmail == null) { - student = getUnregisteredStudent().orElseGet(() -> { - if (userInfo == null) { - return null; - } - - return logic.getStudentForGoogleId(courseId, userInfo.id); - }); + student = getPossiblyUnregisteredStudent(courseId); } else { student = logic.getStudentForEmail(courseId, studentEmail); } diff --git a/src/test/java/teammates/common/datatransfer/attributes/AccountAttributesTest.java b/src/test/java/teammates/common/datatransfer/attributes/AccountAttributesTest.java index c5f48ff66b9..838a070ab6b 100644 --- a/src/test/java/teammates/common/datatransfer/attributes/AccountAttributesTest.java +++ b/src/test/java/teammates/common/datatransfer/attributes/AccountAttributesTest.java @@ -5,7 +5,6 @@ import teammates.common.util.FieldValidator; import teammates.common.util.SanitizationHelper; import teammates.common.util.StringHelper; -import teammates.common.util.StringHelperExtension; import teammates.storage.entity.Account; /** @@ -34,12 +33,7 @@ public void testGetInvalidStateInfo() throws Exception { + getPopulatedErrorMessage( FieldValidator.EMAIL_ERROR_MESSAGE, "invalid@email@com", FieldValidator.EMAIL_FIELD_NAME, FieldValidator.REASON_INCORRECT_FORMAT, - FieldValidator.EMAIL_MAX_LENGTH) + System.lineSeparator() - + getPopulatedErrorMessage( - FieldValidator.SIZE_CAPPED_NON_EMPTY_STRING_ERROR_MESSAGE, - "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - FieldValidator.INSTITUTE_NAME_FIELD_NAME, FieldValidator.REASON_TOO_LONG, - FieldValidator.INSTITUTE_NAME_MAX_LENGTH); + FieldValidator.EMAIL_MAX_LENGTH); assertFalse("all valid values", account.isValid()); assertEquals("all valid values", expectedError, StringHelper.toString(account.getInvalidityInfo())); @@ -50,15 +44,13 @@ public void testGetInvalidStateInfo() throws Exception { public void testToEntity() { AccountAttributes account = createValidAccountAttributesObject(); Account expectedAccount = new Account(account.getGoogleId(), account.getName(), - account.isInstructor(), account.getEmail(), account.getInstitute()); + account.getEmail()); Account actualAccount = account.toEntity(); assertEquals(expectedAccount.getGoogleId(), actualAccount.getGoogleId()); assertEquals(expectedAccount.getName(), actualAccount.getName()); assertEquals(expectedAccount.getEmail(), actualAccount.getEmail()); - assertEquals(expectedAccount.getInstitute(), actualAccount.getInstitute()); - assertEquals(expectedAccount.isInstructor(), actualAccount.isInstructor()); } @Test @@ -81,7 +73,6 @@ public void testSanitizeForSaving() { assertEquals(SanitizationHelper.sanitizeGoogleId(expectedAccount.getGoogleId()), actualAccount.getGoogleId()); assertEquals(SanitizationHelper.sanitizeName(expectedAccount.getName()), actualAccount.getName()); assertEquals(SanitizationHelper.sanitizeEmail(expectedAccount.getEmail()), actualAccount.getEmail()); - assertEquals(SanitizationHelper.sanitizeTitle(expectedAccount.getInstitute()), actualAccount.getInstitute()); } @Test @@ -92,8 +83,6 @@ public void testBuilder_buildNothing_shouldUseDefaultValues() { assertNull(observedAccountAttributes.getCreatedAt()); assertNull(observedAccountAttributes.getEmail()); - assertNull(observedAccountAttributes.getInstitute()); - assertFalse(observedAccountAttributes.isInstructor()); assertNull(observedAccountAttributes.getName()); } @@ -102,20 +91,15 @@ public void testBuilder_withTypicalData_shouldBuildCorrectAttributes() { String expectedGoogleId = "dummyGoogleId"; String expectedEmail = "email@example.com"; String expectedName = "dummyName"; - String expectedInstitute = "dummyInstitute"; AccountAttributes observedAccountAttributes = AccountAttributes.builder(expectedGoogleId) .withEmail(expectedEmail) .withName(expectedName) - .withInstitute(expectedInstitute) - .withIsInstructor(true) .build(); assertEquals(expectedGoogleId, observedAccountAttributes.getGoogleId()); assertEquals(expectedEmail, observedAccountAttributes.getEmail()); assertNull(observedAccountAttributes.getCreatedAt()); - assertEquals(expectedInstitute, observedAccountAttributes.getInstitute()); - assertTrue(observedAccountAttributes.isInstructor()); assertEquals(expectedName, observedAccountAttributes.getName()); } @@ -140,26 +124,17 @@ public void testBuilder_withNullArguments_shouldThrowException() { .withEmail(null) .build(); }); - - assertThrows(AssertionError.class, () -> { - AccountAttributes - .builder("id") - .withInstitute(null) - .build(); - }); } @Test public void testValueOf() { - Account genericAccount = new Account("id", "Joe", true, "joe@example.com", "Teammates Institute"); + Account genericAccount = new Account("id", "Joe", "joe@example.com"); AccountAttributes observedAccountAttributes = AccountAttributes.valueOf(genericAccount); assertEquals(genericAccount.getGoogleId(), observedAccountAttributes.getGoogleId()); assertEquals(genericAccount.getName(), observedAccountAttributes.getName()); - assertEquals(genericAccount.isInstructor(), observedAccountAttributes.isInstructor()); assertEquals(genericAccount.getEmail(), observedAccountAttributes.getEmail()); - assertEquals(genericAccount.getInstitute(), observedAccountAttributes.getInstitute()); assertEquals(genericAccount.getCreatedAt(), observedAccountAttributes.getCreatedAt()); } @@ -170,11 +145,9 @@ public void testGetCopy_typicalData_createsCopyCorrectly() { AccountAttributes copy = account.getCopy(); assertNotSame(account, copy); - assertFalse(account.isInstructor()); assertEquals(account.getGoogleId(), copy.getGoogleId()); assertEquals(account.getName(), copy.getName()); - assertEquals(account.getInstitute(), copy.getInstitute()); assertEquals(account.getEmail(), copy.getEmail()); } @@ -185,32 +158,13 @@ public void testGetCopy_allFieldsNull_createsCopyCorrectly() { AccountAttributes copy = account.getCopy(); assertNotSame(account, copy); - assertFalse(account.isInstructor()); assertEquals("id", copy.getGoogleId()); assertNull("name should be null", copy.getName()); - assertNull("institute should be null", copy.getInstitute()); assertNull("email should be null", copy.getEmail()); assertNull("email should be null", copy.getCreatedAt()); } - @Test - public void testUpdateOptions_withTypicalUpdateOptions_shouldUpdateAttributeCorrectly() { - AccountAttributes.UpdateOptions updateOptions = - AccountAttributes.updateOptionsBuilder("testGoogleId") - .withIsInstructor(true) - .build(); - - assertEquals("testGoogleId", updateOptions.getGoogleId()); - - AccountAttributes accountAttributes = - AccountAttributes.builder("testGoogleId").withIsInstructor(false).build(); - - accountAttributes.update(updateOptions); - - assertTrue(accountAttributes.isInstructor()); - } - @Test public void testEquals() { AccountAttributes account = createValidAccountAttributesObject(); @@ -228,8 +182,6 @@ public void testEquals() { AccountAttributes accountDifferent = AccountAttributes.builder("another") .withName("Another Name") .withEmail("Another Email") - .withInstitute("Another Institute") - .withIsInstructor(false) .build(); assertFalse(account.equals(accountDifferent)); @@ -254,8 +206,6 @@ public void testHashCode() { AccountAttributes accountDifferent = AccountAttributes.builder("another") .withName("Another Name") .withEmail("Another Email") - .withInstitute("Another Institute") - .withIsInstructor(false) .build(); assertFalse(account.hashCode() == accountDifferent.hashCode()); @@ -271,15 +221,11 @@ private AccountAttributes createInvalidAccountAttributesObject() { String googleId = "invalid google id"; String name = ""; //invalid name - boolean isInstructor = false; String email = "invalid@email@com"; - String institute = StringHelperExtension.generateStringOfLength(FieldValidator.INSTITUTE_NAME_MAX_LENGTH + 1); return AccountAttributes.builder(googleId) .withName(name) .withEmail(email) - .withInstitute(institute) - .withIsInstructor(isInstructor) .build(); } @@ -287,24 +233,18 @@ private AccountAttributes createValidAccountAttributesObject() { String googleId = "valid.google.id"; String name = "valid name"; - boolean isInstructor = false; String email = "valid@email.com"; - String institute = "valid institute name"; return AccountAttributes.builder(googleId) .withName(name) .withEmail(email) - .withInstitute(institute) - .withIsInstructor(isInstructor) .build(); } private AccountAttributes createAccountAttributesToSanitize() { return AccountAttributes.builder(" google'Id@gmail.com\t") .withName("'n \t\t a me'\n\n") - .withInstitute("Some\t \\ institute \n/") .withEmail(" @gmail.com\n") - .withIsInstructor(true) .build(); } diff --git a/src/test/java/teammates/logic/core/AccountsLogicTest.java b/src/test/java/teammates/logic/core/AccountsLogicTest.java index 9bd3cf9d42c..1f541299509 100644 --- a/src/test/java/teammates/logic/core/AccountsLogicTest.java +++ b/src/test/java/teammates/logic/core/AccountsLogicTest.java @@ -52,8 +52,6 @@ public void testCreateAccount() throws Exception { AccountAttributes accountToCreate = AccountAttributes.builder("id") .withName("name") .withEmail("test@email.com") - .withInstitute("dev") - .withIsInstructor(true) .build(); accountsLogic.createAccount(accountToCreate); @@ -66,8 +64,6 @@ public void testCreateAccount() throws Exception { accountToCreate = AccountAttributes.builder("") .withName("name") .withEmail("test@email.com") - .withInstitute("dev") - .withIsInstructor(true) .build(); AccountAttributes[] finalAccount = new AccountAttributes[] { accountToCreate }; assertThrows(InvalidParametersException.class, () -> accountsLogic.createAccount(finalAccount[0])); @@ -85,8 +81,6 @@ public void testGetAccountsForEmail() throws Exception { AccountAttributes firstAccount = AccountAttributes.builder("first.googleId") .withName("name") .withEmail("test@email.com") - .withInstitute("dev") - .withIsInstructor(true) .build(); accountsDb.createEntity(firstAccount); @@ -98,15 +92,11 @@ public void testGetAccountsForEmail() throws Exception { AccountAttributes secondAccount = AccountAttributes.builder("second.googleId") .withName("name") .withEmail("test@email.com") - .withInstitute("dev") - .withIsInstructor(true) .build(); accountsDb.createEntity(secondAccount); AccountAttributes thirdAccount = AccountAttributes.builder("third.googleId") .withName("name") .withEmail("test@email.com") - .withInstitute("dev") - .withIsInstructor(false) .build(); accountsDb.createEntity(thirdAccount); @@ -121,39 +111,6 @@ public void testGetAccountsForEmail() throws Exception { accountsDb.deleteAccount(thirdAccount.getGoogleId()); } - @Test - public void testAccountFunctions() throws Exception { - - ______TS("test isAccountAnInstructor"); - - assertTrue(accountsLogic.isAccountAnInstructor("idOfInstructor1OfCourse1")); - - assertFalse(accountsLogic.isAccountAnInstructor("student1InCourse1")); - assertFalse(accountsLogic.isAccountAnInstructor("id-does-not-exist")); - - ______TS("test downgradeInstructorToStudentCascade"); - - accountsLogic.downgradeInstructorToStudentCascade("idOfInstructor2OfCourse1"); - assertFalse(accountsLogic.isAccountAnInstructor("idOfInstructor2OfCourse1")); - - accountsLogic.downgradeInstructorToStudentCascade("student1InCourse1"); - assertFalse(accountsLogic.isAccountAnInstructor("student1InCourse1")); - - assertThrows(EntityDoesNotExistException.class, () -> { - accountsLogic.downgradeInstructorToStudentCascade("id-does-not-exist"); - }); - - ______TS("test makeAccountInstructor"); - - accountsLogic.makeAccountInstructor("student2InCourse1"); - assertTrue(accountsLogic.isAccountAnInstructor("student2InCourse1")); - accountsLogic.downgradeInstructorToStudentCascade("student2InCourse1"); - - assertThrows(EntityDoesNotExistException.class, () -> { - accountsLogic.makeAccountInstructor("id-does-not-exist"); - }); - } - @Test public void testJoinCourseForStudent() throws Exception { @@ -211,8 +168,6 @@ public void testJoinCourseForStudent() throws Exception { AccountAttributes accountData = AccountAttributes.builder(correctStudentId) .withName("nameABC") .withEmail("real@gmail.com") - .withInstitute("TEAMMATES Test Institute 1") - .withIsInstructor(true) .build(); accountsLogic.createAccount(accountData); @@ -263,32 +218,8 @@ public void testJoinCourseForStudent() throws Exception { accountData.setGoogleId(correctStudentId); accountData.setEmail(originalEmail); accountData.setName("name"); - accountData.setInstructor(false); verifyPresentInDatabase(accountData); - ______TS("success: join course as student does not revoke instructor status"); - - // promote account to instructor - accountsLogic.makeAccountInstructor(correctStudentId); - - // make the student 'unregistered' again - studentData.setGoogleId(""); - studentsLogic.updateStudentCascade( - StudentAttributes.updateOptionsBuilder(studentData.getCourse(), studentData.getEmail()) - .withGoogleId(studentData.getGoogleId()) - .build() - ); - assertEquals("", - studentsLogic.getStudentForEmail(studentData.getCourse(), studentData.getEmail()).getGoogleId()); - - // rejoin - accountsLogic.joinCourseForStudent(key, correctStudentId); - assertEquals(correctStudentId, - studentsLogic.getStudentForEmail(studentData.getCourse(), studentData.getEmail()).getGoogleId()); - - // check if still instructor - assertTrue(accountsLogic.isAccountAnInstructor(correctStudentId)); - accountsLogic.deleteAccountCascade(correctStudentId); accountsLogic.deleteAccountCascade(existingId); } @@ -346,14 +277,11 @@ public void testJoinCourseForInstructor() throws Exception { instructorsLogic.createInstructor(newIns); key[0] = getKeyForInstructor(instructor.getCourseId(), nonInstrAccount.getEmail()); - assertFalse(accountsLogic.getAccount(nonInstrAccount.getGoogleId()).isInstructor()); accountsLogic.joinCourseForInstructor(key[0], nonInstrAccount.getGoogleId()); joinedInstructor = instructorsLogic.getInstructorForEmail(instructor.getCourseId(), nonInstrAccount.getEmail()); assertEquals(nonInstrAccount.getGoogleId(), joinedInstructor.getGoogleId()); - assertTrue(accountsLogic.getAccount(nonInstrAccount.getGoogleId()).isInstructor()); - assertTrue(accountsLogic.isAccountAnInstructor(nonInstrAccount.getGoogleId())); ______TS("success: instructor join and assigned institute when some instructors have not joined course"); @@ -380,10 +308,6 @@ public void testJoinCourseForInstructor() throws Exception { joinedInstructor = instructorsLogic.getInstructorForEmail(instructor.getCourseId(), nonInstrAccount.getEmail()); assertEquals(nonInstrAccount.getGoogleId(), joinedInstructor.getGoogleId()); - assertTrue(accountsLogic.isAccountAnInstructor(nonInstrAccount.getGoogleId())); - - AccountAttributes instructorAccount = accountsLogic.getAccount(nonInstrAccount.getGoogleId()); - assertEquals("TEAMMATES Test Institute 1", instructorAccount.getInstitute()); accountsLogic.deleteAccountCascade(nonInstrAccount.getGoogleId()); diff --git a/src/test/java/teammates/logic/core/CoursesLogicTest.java b/src/test/java/teammates/logic/core/CoursesLogicTest.java index 631244ac576..bb844054e50 100644 --- a/src/test/java/teammates/logic/core/CoursesLogicTest.java +++ b/src/test/java/teammates/logic/core/CoursesLogicTest.java @@ -237,8 +237,6 @@ private void testGetTeamsForCourse() throws Exception { accountsLogic.createAccount(AccountAttributes.builder("instructor1") .withName("Instructor 1") .withEmail("instructor@email.tmt") - .withInstitute("TEAMMATES Test Institute 1") - .withIsInstructor(true) .build()); coursesLogic.createCourseAndInstructor("instructor1", CourseAttributes.builder("course1") @@ -341,9 +339,8 @@ private void testCreateCourseAndInstructor() throws Exception { /* Explanation: SUT has 5 paths. They are, * path 1 - exit because the account doesn't' exist. - * path 2 - exit because the account exists but doesn't have instructor privileges. - * path 3 - exit because course creation failed. - * path 4 - exit because instructor creation failed. + * path 2 - exit because course creation failed. + * path 3/4 - exit because instructor creation failed. * path 5 - success. * Accordingly, we have 5 test cases. */ @@ -374,30 +371,13 @@ private void testCreateCourseAndInstructor() throws Exception { verifyAbsentInDatabase(c); verifyAbsentInDatabase(i); - ______TS("fails: account doesn't have instructor privileges"); + ______TS("fails: error during course creation"); AccountAttributes a = AccountAttributes.builder(i.getGoogleId()) .withName(i.getName()) - .withIsInstructor(false) .withEmail(i.getEmail()) - .withInstitute("TEAMMATES Test Institute 5") .build(); - accountsLogic.createAccount(a); - ae = assertThrows(AssertionError.class, - () -> coursesLogic.createCourseAndInstructor(i.getGoogleId(), - CourseAttributes.builder(c.getId()) - .withName(c.getName()) - .withTimezone(c.getTimeZone()) - .withInstitute(c.getInstitute()) - .build())); - AssertHelper.assertContains("doesn't have instructor privileges", ae.getMessage()); - verifyAbsentInDatabase(c); - verifyAbsentInDatabase(i); - - ______TS("fails: error during course creation"); - - accountsLogic.makeAccountInstructor(a.getGoogleId()); CourseAttributes invalidCourse = CourseAttributes .builder("invalid id") diff --git a/src/test/java/teammates/logic/core/FeedbackQuestionsLogicTest.java b/src/test/java/teammates/logic/core/FeedbackQuestionsLogicTest.java index 789d45c3872..895507a9225 100644 --- a/src/test/java/teammates/logic/core/FeedbackQuestionsLogicTest.java +++ b/src/test/java/teammates/logic/core/FeedbackQuestionsLogicTest.java @@ -32,7 +32,6 @@ */ public class FeedbackQuestionsLogicTest extends BaseLogicTest { - private final AccountsLogic accountsLogic = AccountsLogic.inst(); private final FeedbackQuestionsLogic fqLogic = FeedbackQuestionsLogic.inst(); private final FeedbackResponsesLogic frLogic = FeedbackResponsesLogic.inst(); private final FeedbackResponseCommentsLogic frcLogic = FeedbackResponseCommentsLogic.inst(); @@ -173,7 +172,6 @@ public void testGetRecipientsOfQuestion() throws Exception { ______TS("special case: response to other team, instructor is also student"); question = getQuestionFromDatabase("team.feedback"); studentGiver = dataBundle.students.get("student1InCourse1"); - accountsLogic.makeAccountInstructor(studentGiver.getGoogleId()); courseRoster = new CourseRoster( studentsLogic.getStudentsForCourse(studentGiver.getCourse()), instructorsLogic.getInstructorsForCourse(studentGiver.getCourse())); @@ -186,7 +184,6 @@ public void testGetRecipientsOfQuestion() throws Exception { ______TS("to nobody (general feedback)"); question = getQuestionFromDatabase("qn3InSession1InCourse1"); studentGiver = dataBundle.students.get("student1InCourse1"); - accountsLogic.makeAccountInstructor(studentGiver.getGoogleId()); courseRoster = new CourseRoster( studentsLogic.getStudentsForCourse(studentGiver.getCourse()), instructorsLogic.getInstructorsForCourse(studentGiver.getCourse())); @@ -201,7 +198,6 @@ public void testGetRecipientsOfQuestion() throws Exception { ______TS("to self"); question = getQuestionFromDatabase("qn1InSession1InCourse1"); studentGiver = dataBundle.students.get("student1InCourse1"); - accountsLogic.makeAccountInstructor(studentGiver.getGoogleId()); courseRoster = new CourseRoster( studentsLogic.getStudentsForCourse(studentGiver.getCourse()), instructorsLogic.getInstructorsForCourse(studentGiver.getCourse())); diff --git a/src/test/java/teammates/storage/api/AccountsDbTest.java b/src/test/java/teammates/storage/api/AccountsDbTest.java index 1c0ca6f6593..c50b77ee892 100644 --- a/src/test/java/teammates/storage/api/AccountsDbTest.java +++ b/src/test/java/teammates/storage/api/AccountsDbTest.java @@ -22,7 +22,7 @@ public class AccountsDbTest extends BaseTestCaseWithLocalDatabaseAccess { @Test public void testGetAccount() throws Exception { - AccountAttributes a = createNewAccount("valid.googleId", false); + AccountAttributes a = createNewAccount("valid.googleId"); ______TS("typical success case without"); AccountAttributes retrieved = accountsDb.getAccount(a.getGoogleId()); @@ -51,15 +51,15 @@ public void testGetAccountsForEmail() throws Exception { assertTrue(accounts.isEmpty()); ______TS("typical success case: one account with email"); - AccountAttributes firstAccount = createNewAccount("first.googleId", true); + AccountAttributes firstAccount = createNewAccount("first.googleId"); accounts = accountsDb.getAccountsForEmail("valid@email.com"); assertEquals(List.of(firstAccount), accounts); ______TS("typical success case: multiple accounts with email"); - AccountAttributes secondAccount = createNewAccount("second.googleId", true); - AccountAttributes thirdAccount = createNewAccount("third.googleId", false); + AccountAttributes secondAccount = createNewAccount("second.googleId"); + AccountAttributes thirdAccount = createNewAccount("third.googleId"); accounts = accountsDb.getAccountsForEmail("valid@email.com"); @@ -78,9 +78,7 @@ public void testCreateAccount() throws Exception { ______TS("typical success case"); AccountAttributes a = AccountAttributes.builder("test.account") .withName("Test account Name") - .withIsInstructor(false) .withEmail("fresh-account@email.com") - .withInstitute("TEAMMATES Test Institute 1") .build(); accountsDb.createEntity(a); @@ -90,8 +88,6 @@ public void testCreateAccount() throws Exception { AccountAttributes duplicatedAccount = AccountAttributes.builder("test.account") .withName("name2") .withEmail("test2@email.com") - .withInstitute("de2v") - .withIsInstructor(false) .build(); assertThrows(EntityAlreadyExistsException.class, () -> { accountsDb.createEntity(duplicatedAccount); @@ -117,7 +113,7 @@ public void testCreateAccount() throws Exception { @Test public void testUpdateAccount_noChangeToAccount_shouldNotIssueSaveRequest() throws Exception { - AccountAttributes a = createNewAccount("valid.googleId", true); + AccountAttributes a = createNewAccount("valid.googleId"); AccountAttributes updatedAccount = accountsDb.updateAccount( @@ -126,40 +122,21 @@ public void testUpdateAccount_noChangeToAccount_shouldNotIssueSaveRequest() thro // please verify the log message manually to ensure that saving request is not issued assertEquals(JsonUtils.toJson(a), JsonUtils.toJson(updatedAccount)); - - updatedAccount = - accountsDb.updateAccount( - AccountAttributes.updateOptionsBuilder(a.getGoogleId()) - .withIsInstructor(a.isInstructor()) - .build()); - - // please verify the log message manually to ensure that saving request is not issued - assertEquals(JsonUtils.toJson(a), JsonUtils.toJson(updatedAccount)); } @Test public void testUpdateAccount() throws Exception { - AccountAttributes a = createNewAccount("valid.googleId", false); + AccountAttributes a = createNewAccount("valid.googleId"); ______TS("typical edit success case"); - assertFalse(a.isInstructor()); - AccountAttributes updatedAccount = accountsDb.updateAccount( - AccountAttributes.updateOptionsBuilder(a.getGoogleId()) - .withIsInstructor(true) - .build() - ); - - AccountAttributes actualAccount = accountsDb.getAccount(a.getGoogleId()); - assertTrue(actualAccount.isInstructor()); - assertTrue(updatedAccount.isInstructor()); + // No test case as currently account is not updatable ______TS("non-existent account"); EntityDoesNotExistException ednee = assertThrows(EntityDoesNotExistException.class, () -> accountsDb.updateAccount( AccountAttributes.updateOptionsBuilder("non.existent") - .withIsInstructor(true) .build() )); AssertHelper.assertContains(AccountsDb.ERROR_UPDATE_NON_EXISTENT, ednee.getMessage()); @@ -172,24 +149,9 @@ public void testUpdateAccount() throws Exception { accountsDb.deleteAccount(a.getGoogleId()); } - // the test is to ensure that optimized saving policy is implemented without false negative - @Test - public void testUpdateAccount_singleFieldUpdate_shouldUpdateCorrectly() throws Exception { - AccountAttributes typicalAccount = createNewAccount("valid.googleId", false); - - assertFalse(typicalAccount.isInstructor()); - AccountAttributes updatedAccount = accountsDb.updateAccount( - AccountAttributes.updateOptionsBuilder(typicalAccount.getGoogleId()) - .withIsInstructor(true) - .build()); - AccountAttributes actualAccount = accountsDb.getAccount(typicalAccount.getGoogleId()); - assertTrue(actualAccount.isInstructor()); - assertTrue(updatedAccount.isInstructor()); - } - @Test public void testDeleteAccount() throws Exception { - AccountAttributes a = createNewAccount("valid.googleId", true); + AccountAttributes a = createNewAccount("valid.googleId"); ______TS("silent deletion of non-existent account"); @@ -214,17 +176,12 @@ public void testDeleteAccount() throws Exception { () -> accountsDb.deleteAccount(null)); } - private AccountAttributes createNewAccount(String googleId, boolean isInstructor) throws Exception { - AccountAttributes a = getNewAccountAttributes(googleId, isInstructor); - return accountsDb.putEntity(a); - } - - private AccountAttributes getNewAccountAttributes(String googleId, boolean isInstructor) { - return AccountAttributes.builder(googleId) + private AccountAttributes createNewAccount(String googleId) throws Exception { + AccountAttributes a = AccountAttributes.builder(googleId) .withName("Valid Fresh Account") - .withIsInstructor(isInstructor) .withEmail("valid@email.com") - .withInstitute("TEAMMATES Test Institute 1") .build(); + return accountsDb.putEntity(a); } + } diff --git a/src/test/java/teammates/test/AbstractBackDoor.java b/src/test/java/teammates/test/AbstractBackDoor.java index 3b831fecab2..b7e05d9b3b6 100644 --- a/src/test/java/teammates/test/AbstractBackDoor.java +++ b/src/test/java/teammates/test/AbstractBackDoor.java @@ -310,8 +310,6 @@ public AccountAttributes getAccount(String googleId) { return AccountAttributes.builder(accountData.getGoogleId()) .withName(accountData.getName()) .withEmail(accountData.getEmail()) - .withInstitute(accountData.getInstitute()) - .withIsInstructor(accountData.isInstructor()) .build(); } @@ -321,7 +319,6 @@ public AccountAttributes getAccount(String googleId) { public CourseData getCourseData(String courseId) { Map params = new HashMap<>(); params.put(Const.ParamsNames.COURSE_ID, courseId); - params.put(Const.ParamsNames.ENTITY_TYPE, Const.EntityType.STUDENT); ResponseBodyAndCode response = executeGetRequest(Const.ResourceURIs.COURSE, params); if (response.responseCode == HttpStatus.SC_NOT_FOUND) { return null; diff --git a/src/test/java/teammates/ui/webapi/CreateCourseActionTest.java b/src/test/java/teammates/ui/webapi/CreateCourseActionTest.java index d32a630e44b..5e6f6f11b45 100644 --- a/src/test/java/teammates/ui/webapi/CreateCourseActionTest.java +++ b/src/test/java/teammates/ui/webapi/CreateCourseActionTest.java @@ -4,6 +4,7 @@ import teammates.common.datatransfer.attributes.CourseAttributes; import teammates.common.datatransfer.attributes.InstructorAttributes; +import teammates.common.datatransfer.attributes.StudentAttributes; import teammates.common.util.Const; import teammates.ui.output.CourseData; import teammates.ui.request.CourseCreateRequest; @@ -29,7 +30,17 @@ public void testExecute() { ______TS("Not enough parameters"); - verifyHttpRequestBodyFailure(null); + String[] submissionParams = { + Const.ParamsNames.INSTRUCTOR_INSTITUTION, "TEAMMATES Test Institute 1", + }; + + CourseCreateRequest courseCreateRequest = new CourseCreateRequest(); + courseCreateRequest.setCourseName("New Course"); + courseCreateRequest.setTimeZone("UTC"); + courseCreateRequest.setCourseId("new-course"); + + verifyHttpRequestBodyFailure(null, submissionParams); + verifyHttpParameterFailure(courseCreateRequest); ______TS("Typical case with new course id"); @@ -37,17 +48,12 @@ public void testExecute() { String instructorId = instructor1OfCourse1.getGoogleId(); String courseId = instructor1OfCourse1.getCourseId(); - CourseCreateRequest courseCreateRequest = new CourseCreateRequest(); - courseCreateRequest.setCourseName("New Course"); - courseCreateRequest.setTimeZone("UTC"); - courseCreateRequest.setCourseId("new-course"); - if (logic.getCourse("new-course") != null) { logic.deleteCourseCascade("new-course"); } loginAsInstructor(instructorId); - CreateCourseAction action = getAction(courseCreateRequest); + CreateCourseAction action = getAction(courseCreateRequest, submissionParams); JsonResult result = getJsonResult(action); @@ -71,7 +77,7 @@ public void testExecute() { courseCreateRequest.setTimeZone("UTC"); courseCreateRequest.setCourseId(courseId); - InvalidOperationException ioe = verifyInvalidOperation(courseCreateRequest); + InvalidOperationException ioe = verifyInvalidOperation(courseCreateRequest, submissionParams); assertEquals("The course ID idOfTypicalCourse1 has been used by another course, possibly by some other user. " + "Please try again with a different course ID.", ioe.getMessage()); @@ -81,14 +87,41 @@ public void testExecute() { courseCreateRequest.setTimeZone("UTC"); courseCreateRequest.setCourseId(""); - verifyHttpRequestBodyFailure(courseCreateRequest); + verifyHttpRequestBodyFailure(courseCreateRequest, submissionParams); } @Override @Test protected void testAccessControl() { - String[] submissionParams = new String[] {}; + InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1"); + loginAsInstructor(instructor1OfCourse1.getGoogleId()); + + ______TS("Cannot access with wrong/missing institute param"); + + verifyHttpParameterFailureAcl(); + + String[] submissionParams = new String[] { + Const.ParamsNames.INSTRUCTOR_INSTITUTION, "Unknown Institute", + }; + verifyCannotAccess(submissionParams); + + ______TS("Can access with correct institute param"); + + submissionParams = new String[] { + Const.ParamsNames.INSTRUCTOR_INSTITUTION, "TEAMMATES Test Institute 1", + }; + verifyCanAccess(submissionParams); - verifyOnlyInstructorsCanAccess(submissionParams); + ______TS("Cannot access without instructor privilege"); + + StudentAttributes studentAttributes = typicalBundle.students.get("student1InCourse1"); + loginAsStudent(studentAttributes.getGoogleId()); + + verifyCannotAccess(submissionParams); + + loginAsUnregistered("Unknown"); + + verifyCannotAccess(submissionParams); } + } diff --git a/src/test/java/teammates/ui/webapi/DowngradeAccountActionTest.java b/src/test/java/teammates/ui/webapi/DowngradeAccountActionTest.java deleted file mode 100644 index c52e8ed1b9b..00000000000 --- a/src/test/java/teammates/ui/webapi/DowngradeAccountActionTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package teammates.ui.webapi; - -import org.testng.annotations.Test; - -import teammates.common.datatransfer.attributes.InstructorAttributes; -import teammates.common.datatransfer.attributes.StudentAttributes; -import teammates.common.util.Const; -import teammates.ui.output.MessageOutput; - -/** - * SUT: {@link DowngradeAccountAction}. - */ -public class DowngradeAccountActionTest extends BaseActionTest { - - @Override - protected String getActionUri() { - return Const.ResourceURIs.ACCOUNT_DOWNGRADE; - } - - @Override - protected String getRequestMethod() { - return PUT; - } - - @Override - @Test - protected void testExecute() { - InstructorAttributes instructor1ofCourse1 = typicalBundle.instructors.get("instructor1OfCourse1"); - StudentAttributes student1InCourse1 = typicalBundle.students.get("student1InCourse1"); - - loginAsAdmin(); - - ______TS("Not enough parameters"); - - verifyHttpParameterFailure(); - - ______TS("Typical case"); - - String[] params = { - Const.ParamsNames.INSTRUCTOR_ID, instructor1ofCourse1.getGoogleId(), - }; - - DowngradeAccountAction a = getAction(params); - JsonResult r = getJsonResult(a); - - MessageOutput response = (MessageOutput) r.getOutput(); - - assertEquals("Instructor account is successfully downgraded to student.", response.getMessage()); - assertFalse(logic.getAccount(instructor1ofCourse1.getGoogleId()).isInstructor()); - - ______TS("Failure: Downgrades an invalid account"); - - String[] invalidParams = { - Const.ParamsNames.INSTRUCTOR_ID, "invalid-google-id", - }; - - verifyEntityNotFound(invalidParams); - - ______TS("Failure: Tries to downgrade a student account"); - - String[] paramsStudent = { - Const.ParamsNames.INSTRUCTOR_ID, student1InCourse1.getId(), - }; - - verifyEntityNotFound(paramsStudent); - } - - @Override - @Test - protected void testAccessControl() { - verifyOnlyAdminCanAccess(); - } - -} diff --git a/src/test/java/teammates/ui/webapi/GetAccountActionTest.java b/src/test/java/teammates/ui/webapi/GetAccountActionTest.java index 9a08a5cbef1..2a0ed86cdec 100644 --- a/src/test/java/teammates/ui/webapi/GetAccountActionTest.java +++ b/src/test/java/teammates/ui/webapi/GetAccountActionTest.java @@ -55,8 +55,6 @@ protected void testExecute() { assertEquals(response.getGoogleId(), instructor1OfCourse1.getGoogleId()); assertEquals(response.getName(), instructor1OfCourse1.getName()); assertEquals(response.getEmail(), instructor1OfCourse1.getEmail()); - assertEquals(response.getInstitute(), instructor1OfCourse1.getInstitute()); - assertTrue(response.isInstructor()); ______TS("Failure: invalid account not found"); diff --git a/src/test/java/teammates/ui/webapi/GetAccountsActionTest.java b/src/test/java/teammates/ui/webapi/GetAccountsActionTest.java index 801a3691da1..b23455fa91a 100644 --- a/src/test/java/teammates/ui/webapi/GetAccountsActionTest.java +++ b/src/test/java/teammates/ui/webapi/GetAccountsActionTest.java @@ -107,8 +107,6 @@ private void assertEqualAccounts(List accounts, List alert('hi!'); ", - "isInstructor": true, - "email": "instructor1@sanitization.tmt", - "institute": "inst" + "email": "instructor1@sanitization.tmt" }, "student1InCourse1": { "googleId": "student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "student2InCourse1", "name": "Student in two courses", - "isInstructor": false, - "email": "student2InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student2InCourse1@gmail.tmt" }, "student1InTestingNoEmailsSentCourse": { "googleId": "student1InTestingNoEmailsSentCourse", "name": "Student in course with no session emails sent", - "isInstructor": false, - "email": "student1@noemailssent.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1@noemailssent.tmt" }, "student1InTestingSanitizationCourse": { "googleId": "student1InTestingSanitizationCourse", "name": "Stud1", - "isInstructor": false, - "email": "normal@sanitization.tmt", - "institute": "inst" + "email": "normal@sanitization.tmt" } }, "courses": { diff --git a/src/test/resources/data/FeedbackContributionQuestionTest.json b/src/test/resources/data/FeedbackContributionQuestionTest.json index a32068da21a..57f80e5c8f3 100644 --- a/src/test/resources/data/FeedbackContributionQuestionTest.json +++ b/src/test/resources/data/FeedbackContributionQuestionTest.json @@ -3,128 +3,92 @@ "instructor1OfCourse1": { "googleId": "idOfInstructor1OfCourse1", "name": "Instructor 1 of Course 1", - "isInstructor": true, - "email": "instr1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course1.tmt" }, "instructor2OfCourse1": { "googleId": "idOfInstructor2OfCourse1", "name": "Instructor 2 of Course 1", - "isInstructor": true, - "email": "instr2@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course1.tmt" }, "helperOfCourse1": { "googleId": "idOfHelperOfCourse1", "name": "Helper of Course 1", - "isInstructor": true, - "email": "helper@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "helper@course1.tmt" }, "instructor1OfCourse2": { "googleId": "idOfInstructor1OfCourse2", "name": "Instructor 1 of Course 2", - "isInstructor": true, - "email": "instr1@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course2.tmt" }, "instructor2OfCourse2": { "googleId": "idOfInstructor2OfCourse2", "name": "Instructor 2 of Course 2", - "isInstructor": true, - "email": "instr2@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course2.tmt" }, "instructor1OfCourse3": { "googleId": "idOfInstructor1OfCourse3", "name": "Instructor 1 of Course 3", - "isInstructor": true, - "email": "instr1@course3.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course3.tmt" }, "instructor2OfCourse3": { "googleId": "idOfInstructor2OfCourse3", "name": "Instructor 2 of Course 3", - "isInstructor": true, - "email": "instr2@course3.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course3.tmt" }, "instructor3": { "googleId": "idOfInstructor3", "name": "Instructor 3 of Course 1 and 2", - "isInstructor": true, - "email": "instr3@course1n2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr3@course1n2.tmt" }, "instructor4": { "googleId": "idOfInstructor4", "name": "Instructor 4 of CourseNoEvals", - "isInstructor": true, - "email": "instr4@coursenoevals.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr4@coursenoevals.tmt" }, "instructor5": { "googleId": "idOfInstructor5", "name": "Instructor 5 of CourseNoRegister", - "isInstructor": true, - "email": "instructor5@courseNoRegister.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instructor5@courseNoRegister.tmt" }, "instructorWithoutCourses": { "googleId": "instructorWithoutCourses", "name": "Instructor Without Courses", - "isInstructor": true, - "email": "iwc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwc@yahoo.tmt" }, "instructorWithOnlyOneSampleCourse": { "googleId": "idOfInstructorWithOnlyOneSampleCourse", "name": "Instructor With Only One Sample Course", - "isInstructor": true, - "email": "iwosc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwosc@yahoo.tmt" }, "instructorOfArchivedCourse": { "googleId": "idOfInstructorOfArchivedCourse", "name": "InstructorOfArchiveCourse name", - "isInstructor": true, - "email": "instructorOfArchiveCourse@archiveCourse.tmt", - "institute": "TEAMMATES Test Institute 5" + "email": "instructorOfArchiveCourse@archiveCourse.tmt" }, "instructor1OfTestingSanitizationCourse": { "googleId": "idOfInstructor1OfTestingSanitizationCourse", "name": "Instructor", - "isInstructor": true, - "email": "instructor1@sanitization.tmt", - "institute": "inst" + "email": "instructor1@sanitization.tmt" }, "student1InCourse1": { "googleId": "student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "student2InCourse1", "name": "Student in two courses", - "isInstructor": false, - "email": "student2InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student2InCourse1@gmail.tmt" }, "student1InArchivedCourse": { "googleId": "student1InArchivedCourse", "name": "Student in Archived Course", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student1InTestingSanitizationCourse": { "googleId": "student1InTestingSanitizationCourse", "name": "Stud1", - "isInstructor": false, - "email": "normal@sanitization.tmt", - "institute": "inst" + "email": "normal@sanitization.tmt" } }, "courses": { diff --git a/src/test/resources/data/FeedbackResponseCommentCRUDTest.json b/src/test/resources/data/FeedbackResponseCommentCRUDTest.json index 5300d646afd..864311a355b 100644 --- a/src/test/resources/data/FeedbackResponseCommentCRUDTest.json +++ b/src/test/resources/data/FeedbackResponseCommentCRUDTest.json @@ -3,58 +3,42 @@ "instructor1OfCourse1": { "googleId": "instructor1OfCourse1", "name": "Teammates Test", - "isInstructor": true, - "email": "instructor1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instructor1@course1.tmt" }, "instructor2OfCourse1": { "googleId": "instructor2OfCourse1", "name": "Teammates Test2", - "isInstructor": true, - "email": "instructor2@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instructor2@course1.tmt" }, "instructor1OfCourse2": { "googleId": "idOfInstructor1OfCourse2", "name": "Instructor 1 of Course 2", - "isInstructor": true, - "email": "instr1@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course2.tmt" }, "helperOfCourse1": { "googleId": "idOfHelperOfCourse1", "name": "helper of Course 1", - "isInstructor": true, - "email": "helper@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "helper@course1.tmt" }, "student1InCourse1": { "googleId": "student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "student1inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1inCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "student2InCourse1", "name": "Student 2 in course 1", - "isInstructor": false, - "email": "student2inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student2inCourse1@gmail.tmt" }, "student3InCourse1": { "googleId": "student3InCourse1", "name": "Student 3 in course 1", - "isInstructor": false, - "email": "student3inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student3inCourse1@gmail.tmt" }, "student1InCourse2": { "googleId": "student1InCourse2", "name": "Student 1 in course 2", - "isInstructor": false, - "email": "student1inCourse2@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1inCourse2@gmail.tmt" } }, "courses": { diff --git a/src/test/resources/data/FeedbackSessionQuestionTypeTest.json b/src/test/resources/data/FeedbackSessionQuestionTypeTest.json index e7d303f04fc..bd9dea2c098 100644 --- a/src/test/resources/data/FeedbackSessionQuestionTypeTest.json +++ b/src/test/resources/data/FeedbackSessionQuestionTypeTest.json @@ -3,72 +3,52 @@ "instructor1OfCourse1": { "googleId": "FSQTT.idOfInstructor1OfCourse1", "name": "Instructor 1 of Course 1", - "isInstructor": true, - "email": "instr1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course1.tmt" }, "instructor2OfCourse1": { "googleId": "FSQTT.idOfInstructor2OfCourse1", "name": "Instructor 2 of Course 1", - "isInstructor": true, - "email": "instr2@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course1.tmt" }, "instructor1OfCourse2": { "googleId": "FSQTT.idOfInstructor1OfCourse2", "name": "Instructor 1 of Course 2", - "isInstructor": true, - "email": "instr1@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course2.tmt" }, "instructor2OfCourse2": { "googleId": "FSQTT.idOfInstructor2OfCourse2", "name": "Instructor 2 of Course 2", - "isInstructor": true, - "email": "instr2@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course2.tmt" }, "instructor3": { "googleId": "FSQTT.idOfInstructor3", "name": "Instructor 3 of Course 1 and 2", - "isInstructor": true, - "email": "instr3@course1n2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr3@course1n2.tmt" }, "instructor4": { "googleId": "FSQTT.idOfInstructor4", "name": "Instructor 4 of CourseNoEvals", - "isInstructor": true, - "email": "instr4@coursenoevals.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr4@coursenoevals.tmt" }, "instructor1OfCourseWithSections": { "googleId": "FSQTT.idOfInstructor1OfCourseWithSections", "name": "Instructor 1 of Course With Sections", - "isInstructor": true, - "email": "instr1@coursewithsections.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@coursewithsections.tmt" }, "instructorWithoutCourses": { "googleId": "FSQTT.instructorWithoutCourses", "name": "Instructor Without Courses", - "isInstructor": true, - "email": "iwc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwc@yahoo.tmt" }, "student1InCourse1": { "googleId": "FSQTT.student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "sudent1inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "sudent1inCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "FSQTT.student2InCourse1", "name": "Student in two courses", - "isInstructor": false, - "email": "sudent2inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "sudent2inCourse1@gmail.tmt" } }, "courses": { diff --git a/src/test/resources/data/FeedbackSessionResultsBundleTest.json b/src/test/resources/data/FeedbackSessionResultsBundleTest.json index 34a4e2d2df5..d2c270b5de9 100644 --- a/src/test/resources/data/FeedbackSessionResultsBundleTest.json +++ b/src/test/resources/data/FeedbackSessionResultsBundleTest.json @@ -3,28 +3,21 @@ "instructor1OfCourse1": { "googleId": "idOfInstructor1OfCourse1", "name": "Instructor 1 of Course 1", - "isInstructor": true, - "email": "instr1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course1.tmt" }, "student1InCourse1": { "googleId": "student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "student2InCourse1", "name": "Student in two courses", - "isInstructor": false, - "email": "student2InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student2InCourse1@gmail.tmt" }, "student3InCourse1": { "googleId": "student3InCourse1", "name": "student3 In Course1", - "isInstructor": false, "email": "student3InCourse1@gmail.tmt" } }, diff --git a/src/test/resources/data/FeedbackSessionResultsTest.json b/src/test/resources/data/FeedbackSessionResultsTest.json index 255cf031f4f..a7d36302909 100644 --- a/src/test/resources/data/FeedbackSessionResultsTest.json +++ b/src/test/resources/data/FeedbackSessionResultsTest.json @@ -3,65 +3,47 @@ "instructor1OfCourse1": { "googleId": "FSRTest.idOfInstructor1OfCourse1", "name": "Instructor 1 of Course 1", - "isInstructor": true, - "email": "FSRTest.instr1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSRTest.instr1@course1.tmt" }, "instructor2OfCourse1": { "googleId": "FSRTest.idOfInstructor2OfCourse1", "name": "Instructor 2 of Course 1", - "isInstructor": true, - "email": "FSRTest.instr2@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSRTest.instr2@course1.tmt" }, "instructor3": { "googleId": "FSRTest.idOfInstructor3", "name": "Instructor 3 of Course 1 and No Sessions", - "isInstructor": true, - "email": "FSRTest.instr3@course1n2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSRTest.instr3@course1n2.tmt" }, "instructorWithoutCourses": { "googleId": "FSRTest.instructorWithoutCourses", "name": "Instructor Without Courses", - "isInstructor": true, - "email": "FSRTest.iwc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "FSRTest.iwc@yahoo.tmt" }, "student1InCourse1": { "googleId": "FSRTest.student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "FSRTest.sudent1inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSRTest.sudent1inCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "FSRTest.student2InCourse1", "name": "Student in two courses", - "isInstructor": false, - "email": "FSRTest.sudent2inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSRTest.sudent2inCourse1@gmail.tmt" }, "student3InCourse1": { "googleId": "FSRTest.student3InCourse1", "name": "Student 3 in course 1", - "isInstructor": false, - "email": "FSRTest.sudent1inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSRTest.sudent1inCourse1@gmail.tmt" }, "student4InCourse1": { "googleId": "FSRTest.student4InCourse1", "name": "Student 4 in course 1", - "isInstructor": false, - "email": "FSRTest.sudent4inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSRTest.sudent4inCourse1@gmail.tmt" }, "student5InCourse1": { "googleId": "FSRTest.student5InCourse1", "name": "Student 5 in course 1", - "isInstructor": false, - "email": "FSRTest.sudent5inCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FSRTest.sudent5inCourse1@gmail.tmt" } }, "courses": { diff --git a/src/test/resources/data/FeedbackSessionsLogicTest.json b/src/test/resources/data/FeedbackSessionsLogicTest.json index 5a603030f81..5304bb7ab7a 100644 --- a/src/test/resources/data/FeedbackSessionsLogicTest.json +++ b/src/test/resources/data/FeedbackSessionsLogicTest.json @@ -3,107 +3,77 @@ "instructor1OfCourse1": { "googleId": "idOfInstructor1OfCourse1", "name": "Instructor 1 of Course 1", - "isInstructor": true, - "email": "instr1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course1.tmt" }, "instructor2OfCourse1": { "googleId": "idOfInstructor2OfCourse1", "name": "Instructor 2 of Course 1", - "isInstructor": true, - "email": "instr2@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course1.tmt" }, "helperOfCourse1": { "googleId": "idOfHelperOfCourse1", "name": "Helper of Course 1", - "isInstructor": true, - "email": "helper@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "helper@course1.tmt" }, "instructor1OfCourse2": { "googleId": "idOfInstructor1OfCourse2", "name": "Instructor 1 of Course 2", - "isInstructor": true, - "email": "instr1@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course2.tmt" }, "instructor2OfCourse2": { "googleId": "idOfInstructor2OfCourse2", "name": "Instructor 2 of Course 2", - "isInstructor": true, - "email": "instr2@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course2.tmt" }, "instructor1OfCourse3": { "googleId": "idOfInstructor1OfCourse3", "name": "Instructor 1 of Course 3", - "isInstructor": true, - "email": "instr1@course3.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course3.tmt" }, "instructor3": { "googleId": "idOfInstructor3", "name": "Instructor 3 of Course 1 and 2", - "isInstructor": true, - "email": "instr3@course1n2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr3@course1n2.tmt" }, "instructor4": { "googleId": "idOfInstructor4", "name": "Instructor 4 of CourseNoEvals", - "isInstructor": true, - "email": "instr4@coursenoevals.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr4@coursenoevals.tmt" }, "instructor5": { "googleId": "idOfInstructor5", "name": "Instructor 5 of CourseNoRegister", - "isInstructor": true, - "email": "instructor5@courseNoRegister.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instructor5@courseNoRegister.tmt" }, "instructorWithoutCourses": { "googleId": "instructorWithoutCourses", "name": "Instructor Without Courses", - "isInstructor": true, - "email": "iwc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwc@yahoo.tmt" }, "instructorWithOnlyOneSampleCourse": { "googleId": "idOfInstructorWithOnlyOneSampleCourse", "name": "Instructor With Only One Sample Course", - "isInstructor": true, - "email": "iwosc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwosc@yahoo.tmt" }, "instructorOfArchivedCourse": { "googleId": "idOfInstructorOfArchivedCourse", "name": "InstructorOfArchiveCourse name", - "isInstructor": true, - "email": "instructorOfArchiveCourse@archiveCourse.tmt", - "institute": "TEAMMATES Test Institute 5" + "email": "instructorOfArchiveCourse@archiveCourse.tmt" }, "student1InCourse1": { "googleId": "student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "student2InCourse1", "name": "Student in two courses", - "isInstructor": false, - "email": "student2InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student2InCourse1@gmail.tmt" }, "student1InArchivedCourse": { "googleId": "student1InArchivedCourse", "name": "Student in Archived Course", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" } }, "courses": { diff --git a/src/test/resources/data/GetCoursesActionTest.json b/src/test/resources/data/GetCoursesActionTest.json index b37fb746e6e..a8e229a2207 100644 --- a/src/test/resources/data/GetCoursesActionTest.json +++ b/src/test/resources/data/GetCoursesActionTest.json @@ -3,16 +3,12 @@ "instructor1": { "googleId": "idOfInstructor1", "name": "Instructor 1", - "isInstructor": true, - "email": "instr1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course1.tmt" }, "student1": { "googleId": "idOfStudent1", "name": "student 1", - "isInstructor": false, - "email": "student1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1@gmail.tmt" } }, "courses": { diff --git a/src/test/resources/data/GetFeedbackQuestionRecipientsActionTest.json b/src/test/resources/data/GetFeedbackQuestionRecipientsActionTest.json index bb0443f562e..12792b514fa 100644 --- a/src/test/resources/data/GetFeedbackQuestionRecipientsActionTest.json +++ b/src/test/resources/data/GetFeedbackQuestionRecipientsActionTest.json @@ -3,128 +3,92 @@ "instructor1OfCourse1": { "googleId": "idOfInstructor1OfCourse1", "name": "Instructor 1 of Course 1", - "isInstructor": true, - "email": "instr1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course1.tmt" }, "instructor2OfCourse1": { "googleId": "idOfInstructor2OfCourse1", "name": "Instructor 2 of Course 1", - "isInstructor": true, - "email": "instr2@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course1.tmt" }, "helperOfCourse1": { "googleId": "idOfHelperOfCourse1", "name": "Helper of Course 1", - "isInstructor": true, - "email": "helper@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "helper@course1.tmt" }, "instructor1OfCourse2": { "googleId": "idOfInstructor1OfCourse2", "name": "Instructor 1 of Course 2", - "isInstructor": true, - "email": "instr1@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course2.tmt" }, "instructor2OfCourse2": { "googleId": "idOfInstructor2OfCourse2", "name": "Instructor 2 of Course 2", - "isInstructor": true, - "email": "instr2@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course2.tmt" }, "instructor1OfCourse3": { "googleId": "idOfInstructor1OfCourse3", "name": "Instructor 1 of Course 3", - "isInstructor": true, - "email": "instr1@course3.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course3.tmt" }, "instructor2OfCourse3": { "googleId": "idOfInstructor2OfCourse3", "name": "Instructor 2 of Course 3", - "isInstructor": true, - "email": "instr2@course3.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course3.tmt" }, "instructor3": { "googleId": "idOfInstructor3", "name": "Instructor 3 of Course 1 and 2", - "isInstructor": true, - "email": "instr3@course1n2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr3@course1n2.tmt" }, "instructor4": { "googleId": "idOfInstructor4", "name": "Instructor 4 of CourseNoEvals", - "isInstructor": true, - "email": "instr4@coursenoevals.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr4@coursenoevals.tmt" }, "instructor5": { "googleId": "idOfInstructor5", "name": "Instructor 5 of CourseNoRegister", - "isInstructor": true, - "email": "instructor5@courseNoRegister.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instructor5@courseNoRegister.tmt" }, "instructorWithoutCourses": { "googleId": "instructorWithoutCourses", "name": "Instructor Without Courses", - "isInstructor": true, - "email": "iwc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwc@yahoo.tmt" }, "instructorWithOnlyOneSampleCourse": { "googleId": "idOfInstructorWithOnlyOneSampleCourse", "name": "Instructor With Only One Sample Course", - "isInstructor": true, - "email": "iwosc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwosc@yahoo.tmt" }, "instructorOfArchivedCourse": { "googleId": "idOfInstructorOfArchivedCourse", "name": "InstructorOfArchiveCourse name", - "isInstructor": true, - "email": "instructorOfArchiveCourse@archiveCourse.tmt", - "institute": "TEAMMATES Test Institute 5" + "email": "instructorOfArchiveCourse@archiveCourse.tmt" }, "instructor1OfTestingSanitizationCourse": { "googleId": "idOfInstructor1OfTestingSanitizationCourse", "name": "Instructor", - "isInstructor": true, - "email": "instructor1@sanitization.tmt", - "institute": "inst" + "email": "instructor1@sanitization.tmt" }, "student1InCourse1": { "googleId": "student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "student2InCourse1", "name": "Student in two courses", - "isInstructor": false, - "email": "student2InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student2InCourse1@gmail.tmt" }, "student1InArchivedCourse": { "googleId": "student1InArchivedCourse", "name": "Student in Archived Course", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student1InTestingSanitizationCourse": { "googleId": "student1InTestingSanitizationCourse", "name": "Stud1", - "isInstructor": false, - "email": "normal@sanitization.tmt", - "institute": "inst" + "email": "normal@sanitization.tmt" } }, "courses": { diff --git a/src/test/resources/data/SpecialCharacterTest.json b/src/test/resources/data/SpecialCharacterTest.json index 0d42a5f7dfb..6f1cb5351dd 100644 --- a/src/test/resources/data/SpecialCharacterTest.json +++ b/src/test/resources/data/SpecialCharacterTest.json @@ -3,44 +3,32 @@ "FQLogicPCT.instr": { "googleId": "FQLogicPCT.instr", "name": "Teammates Test", - "isInstructor": true, - "email": "FQLogicPCT.instr@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FQLogicPCT.instr@gmail.tmt" }, "FQLogicPCT.alice.b": { "googleId": "FQLogicPCT.alice.b", "name": "Alice B.", - "isInstructor": false, - "email": "FQLogicPCT.alice.b@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FQLogicPCT.alice.b@gmail.tmt" }, "FQLogicPCT.benny.c": { "googleId": "FQLogicPCT.benny.c", "name": "Benny C.", - "isInstructor": false, - "email": "FQLogicPCT.benny.c@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FQLogicPCT.benny.c@gmail.tmt" }, "FQLogicPCT.charlie.d": { "googleId": "FQLogicPCT.charlie.d", "name": "Charlie D.", - "isInstructor": false, - "email": "FQLogicPCT.charlie.d@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FQLogicPCT.charlie.d@gmail.tmt" }, "FQLogicPCT.danny.e": { "googleId": "FQLogicPCT.danny.e", "name": "Danny E.", - "isInstructor": false, - "email": "FQLogicPCT.danny.e@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FQLogicPCT.danny.e@gmail.tmt" }, "FQLogicPCT.emily.f": { "googleId": "FQLogicPCT.emily.f", "name": "Emily F.", - "isInstructor": false, - "email": "FQLogicPCT.emily.f@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "FQLogicPCT.emily.f@gmail.tmt" } }, "courses": { diff --git a/src/test/resources/data/typicalDataBundle.json b/src/test/resources/data/typicalDataBundle.json index d825b58514a..2e602d30c49 100644 --- a/src/test/resources/data/typicalDataBundle.json +++ b/src/test/resources/data/typicalDataBundle.json @@ -3,128 +3,92 @@ "instructor1OfCourse1": { "googleId": "idOfInstructor1OfCourse1", "name": "Instructor 1 of Course 1", - "isInstructor": true, - "email": "instr1@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course1.tmt" }, "instructor2OfCourse1": { "googleId": "idOfInstructor2OfCourse1", "name": "Instructor 2 of Course 1", - "isInstructor": true, - "email": "instr2@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course1.tmt" }, "helperOfCourse1": { "googleId": "idOfHelperOfCourse1", "name": "Helper of Course 1", - "isInstructor": true, - "email": "helper@course1.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "helper@course1.tmt" }, "instructor1OfCourse2": { "googleId": "idOfInstructor1OfCourse2", "name": "Instructor 1 of Course 2", - "isInstructor": true, - "email": "instr1@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course2.tmt" }, "instructor2OfCourse2": { "googleId": "idOfInstructor2OfCourse2", "name": "Instructor 2 of Course 2", - "isInstructor": true, - "email": "instr2@course2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course2.tmt" }, "instructor1OfCourse3": { "googleId": "idOfInstructor1OfCourse3", "name": "Instructor 1 of Course 3", - "isInstructor": true, - "email": "instr1@course3.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr1@course3.tmt" }, "instructor2OfCourse3": { "googleId": "idOfInstructor2OfCourse3", "name": "Instructor 2 of Course 3", - "isInstructor": true, - "email": "instr2@course3.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr2@course3.tmt" }, "instructor3": { "googleId": "idOfInstructor3", "name": "Instructor 3 of Course 1 and 2", - "isInstructor": true, - "email": "instr3@course1n2.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr3@course1n2.tmt" }, "instructor4": { "googleId": "idOfInstructor4", "name": "Instructor 4 of CourseNoEvals", - "isInstructor": true, - "email": "instr4@coursenoevals.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instr4@coursenoevals.tmt" }, "instructor5": { "googleId": "idOfInstructor5", "name": "Instructor 5 of CourseNoRegister", - "isInstructor": true, - "email": "instructor5@courseNoRegister.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "instructor5@courseNoRegister.tmt" }, "instructorWithoutCourses": { "googleId": "instructorWithoutCourses", "name": "Instructor Without Courses", - "isInstructor": true, - "email": "iwc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwc@yahoo.tmt" }, "instructorWithOnlyOneSampleCourse": { "googleId": "idOfInstructorWithOnlyOneSampleCourse", "name": "Instructor With Only One Sample Course", - "isInstructor": true, - "email": "iwosc@yahoo.tmt", - "institute": "TEAMMATES Test Institute 7" + "email": "iwosc@yahoo.tmt" }, "instructorOfArchivedCourse": { "googleId": "idOfInstructorOfArchivedCourse", "name": "InstructorOfArchiveCourse name", - "isInstructor": true, - "email": "instructorOfArchiveCourse@archiveCourse.tmt", - "institute": "TEAMMATES Test Institute 5" + "email": "instructorOfArchiveCourse@archiveCourse.tmt" }, "instructor1OfTestingSanitizationCourse": { "googleId": "idOfInstructor1OfTestingSanitizationCourse", "name": "Instructor", - "isInstructor": true, - "email": "instructor1@sanitization.tmt", - "institute": "inst" + "email": "instructor1@sanitization.tmt" }, "student1InCourse1": { "googleId": "student1InCourse1", "name": "Student 1 in course 1", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student2InCourse1": { "googleId": "student2InCourse1", "name": "Student in two courses", - "isInstructor": false, - "email": "student2InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student2InCourse1@gmail.tmt" }, "student1InArchivedCourse": { "googleId": "student1InArchivedCourse", "name": "Student in Archived Course", - "isInstructor": false, - "email": "student1InCourse1@gmail.tmt", - "institute": "TEAMMATES Test Institute 1" + "email": "student1InCourse1@gmail.tmt" }, "student1InTestingSanitizationCourse": { "googleId": "student1InTestingSanitizationCourse", "name": "Stud1", - "isInstructor": false, - "email": "normal@sanitization.tmt", - "institute": "inst" + "email": "normal@sanitization.tmt" } }, "courses": { diff --git a/src/web/app/components/copy-course-modal/__snapshots__/copy-course-modal.component.spec.ts.snap b/src/web/app/components/copy-course-modal/__snapshots__/copy-course-modal.component.spec.ts.snap index 5057e8751f2..46259ff40cf 100644 --- a/src/web/app/components/copy-course-modal/__snapshots__/copy-course-modal.component.spec.ts.snap +++ b/src/web/app/components/copy-course-modal/__snapshots__/copy-course-modal.component.spec.ts.snap @@ -9,9 +9,11 @@ exports[`CopyCourseModalComponent should snap when copying from other sessions 1 allCourses={[Function Array]} courseToFeedbackSession={[Function Object]} fetchFeedbackSessionsEvent={[Function EventEmitter_]} + institutes={[Function Array]} isCopyFromOtherSession={[Function Boolean]} newCourseId="" newCourseIdIsConflicting="false" + newCourseInstitute="" newCourseName="" newTimezone={[Function String]} oldCourseId="" @@ -93,7 +95,31 @@ exports[`CopyCourseModalComponent should snap when copying from other sessions 1

-
+
+
+
+
+
+
- +
+ +
+
+
+
+ [(ngModel)]="course.courseId" name="courseId" required disabled>
@@ -46,6 +45,13 @@
+
+ +
+ +
+
+
+ +
+ +
+
@@ -992,6 +1017,7 @@ exports[`InstructorCoursesPageComponent should snap when new course form is expa >
- +
`; @@ -1509,6 +1528,7 @@ exports[`InstructorCoursesPageComponent should snap with default fields 1`] = `
+
+ +
+ +
+
@@ -181,6 +206,7 @@ exports[`AddCourseFormComponent should snap when not enabled 1`] = ` >
+
+ +
+ +
+
@@ -373,6 +424,7 @@ exports[`AddCourseFormComponent should snap with default fields 1`] = ` >
- @@ -41,6 +41,18 @@
Or:
[maxlength]="80" [disabled]="isAddingCourse" placeholder="e.g. Software Engineering"/>
+
+ +
+ +
+
- diff --git a/src/web/app/pages-instructor/instructor-courses-page/add-course-form/add-course-form.component.ts b/src/web/app/pages-instructor/instructor-courses-page/add-course-form/add-course-form.component.ts index 1665e1739e6..5ad77a65cf9 100644 --- a/src/web/app/pages-instructor/instructor-courses-page/add-course-form/add-course-form.component.ts +++ b/src/web/app/pages-instructor/instructor-courses-page/add-course-form/add-course-form.component.ts @@ -40,10 +40,12 @@ export class AddCourseFormComponent implements OnInit { @Output() closeCourseFormEvent: EventEmitter = new EventEmitter(); @Output() copyCourseEvent: EventEmitter = new EventEmitter(); + institutes: string[] = []; timezones: Timezone[] = []; timezone: string = ''; newCourseId: string = ''; newCourseName: string = ''; + newCourseInstitute: string = ''; isAddingCourse: boolean = false; constructor(private statusMessageService: StatusMessageService, @@ -62,7 +64,10 @@ export class AddCourseFormComponent implements OnInit { offset: offset === 0 ? 'UTC' : `UTC ${sign}${formatTwoDigits(hourOffset)}:${formatTwoDigits(minOffset)}`, }); } - + this.institutes = Array.from(new Set(this.allCourses.map((course: Course) => course.institute))); + if (this.institutes.length) { + this.newCourseInstitute = this.institutes[0]; + } this.timezone = this.timezoneService.guessTimezone(); } @@ -90,7 +95,7 @@ export class AddCourseFormComponent implements OnInit { } this.isAddingCourse = true; - this.courseService.createCourse({ + this.courseService.createCourse(this.newCourseInstitute, { courseName: this.newCourseName, timeZone: this.timezone, courseId: this.newCourseId, @@ -99,12 +104,11 @@ export class AddCourseFormComponent implements OnInit { })).subscribe(() => { this.courseAdded.emit(); this.statusMessageService.showSuccessToast('The course has been added.'); + this.newCourseId = ''; + this.newCourseName = ''; }, (resp: ErrorMessageOutput) => { this.statusMessageService.showErrorToast(resp.error.message); }); - this.newCourseId = ''; - this.newCourseName = ''; - this.timezone = this.timezoneService.guessTimezone(); } /** diff --git a/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.html b/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.html index 2cdf46f8e59..6dcf7c7875e 100644 --- a/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.html +++ b/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.html @@ -1,10 +1,10 @@
-
+
{ it('should show add course form and disable button when clicking on add new course', () => { component.activeCourses = [courseModelCS3282]; component.isLoading = false; + fixture.detectChanges(); + const button: any = fixture.debugElement.nativeElement.querySelector('#btn-add-course'); button.click(); fixture.detectChanges(); @@ -552,6 +554,7 @@ describe('InstructorCoursesPageComponent', () => { it('should snap when new course form is expanded', () => { component.isAddNewCourseFormExpanded = true; + component.isLoading = false; // Mock the timezone service to prevent unexpected changes in time zones over time, such as daylight savings time const timezones: Record = { Jamaica: -5 * 60, diff --git a/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.ts b/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.ts index e4f98287539..d3499199668 100644 --- a/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.ts +++ b/src/web/app/pages-instructor/instructor-courses-page/instructor-courses-page.component.ts @@ -311,7 +311,7 @@ export class InstructorCoursesPageComponent implements OnInit { this.totalNumberOfSessionsToCopy = result.totalNumberOfSessions; this.copyProgressPercentage = 0; - this.courseService.createCourse({ + this.courseService.createCourse(result.newCourseInstitute, { courseName: result.newCourseName, timeZone: result.newTimeZone, courseId: result.newCourseId, diff --git a/src/web/app/pages-instructor/instructor-page.component.html b/src/web/app/pages-instructor/instructor-page.component.html index 7fe3dc33f7d..b017c0c6f82 100644 --- a/src/web/app/pages-instructor/instructor-page.component.html +++ b/src/web/app/pages-instructor/instructor-page.component.html @@ -1,6 +1,5 @@ -
-
- - Course ID: - -
+ Course ID: +
+ CS3281
-
-
- - Session: - -
+ Session: +
+ Peer Feedback
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
-
-
- - Course ID: - -
+ Course ID: +
-
-
- - Session: - -
+ Session: +
- Peer Review 1 + Peer Feedback
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
@@ -315,6 +299,9 @@ exports[`SessionResultPageComponent should snap with default fields 1`] = ` authService={[Function AuthService]} backendUrl={[Function String]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} entityType={[Function String]} feedbackSessionName={[Function String]} feedbackSessionsService={[Function FeedbackSessionsService]} @@ -323,6 +310,7 @@ exports[`SessionResultPageComponent should snap with default fields 1`] = ` hasFeedbackSessionResultsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading="false" isFeedbackSessionDetailsLoading="false" isFeedbackSessionResultsLoading="false" logService={[Function LogService]} @@ -371,75 +359,64 @@ exports[`SessionResultPageComponent should snap with default fields 1`] = `
-
-
- - Course ID: - -
+ Course ID: +
+ CS3281
-
-
- - Session: - -
+ Session: +
+ Peer Feedback
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
@@ -467,6 +444,9 @@ exports[`SessionResultPageComponent should snap with feedback session with quest authService={[Function AuthService]} backendUrl={[Function String]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} entityType={[Function String]} feedbackSessionName={[Function String]} feedbackSessionsService={[Function FeedbackSessionsService]} @@ -475,6 +455,7 @@ exports[`SessionResultPageComponent should snap with feedback session with quest hasFeedbackSessionResultsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading="false" isFeedbackSessionDetailsLoading="false" isFeedbackSessionResultsLoading="false" logService={[Function LogService]} @@ -531,77 +512,64 @@ exports[`SessionResultPageComponent should snap with feedback session with quest
-
-
- - Course ID: - -
+ Course ID: +
- CS1231 + CS3281
-
-
- - Session: - -
+ Session: +
- First Session + Peer Feedback
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
@@ -1033,6 +1001,9 @@ exports[`SessionResultPageComponent should snap with feedback session with quest authService={[Function AuthService]} backendUrl={[Function String]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} entityType={[Function String]} feedbackSessionName={[Function String]} feedbackSessionsService={[Function FeedbackSessionsService]} @@ -1041,6 +1012,7 @@ exports[`SessionResultPageComponent should snap with feedback session with quest hasFeedbackSessionResultsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading="false" isFeedbackSessionDetailsLoading="false" isFeedbackSessionResultsLoading="false" logService={[Function LogService]} @@ -1097,77 +1069,64 @@ exports[`SessionResultPageComponent should snap with feedback session with quest
-
-
- - Course ID: - -
+ Course ID: +
- CS1231 + CS3281
-
-
- - Session: - -
+ Session: +
- First Session + Peer Feedback
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
@@ -1464,6 +1423,9 @@ exports[`SessionResultPageComponent should snap with session details and results authService={[Function AuthService]} backendUrl={[Function String]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} entityType={[Function String]} feedbackSessionName={[Function String]} feedbackSessionsService={[Function FeedbackSessionsService]} @@ -1472,6 +1434,7 @@ exports[`SessionResultPageComponent should snap with session details and results hasFeedbackSessionResultsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading={[Function Boolean]} isFeedbackSessionDetailsLoading={[Function Boolean]} isFeedbackSessionResultsLoading={[Function Boolean]} logService={[Function LogService]} @@ -1514,7 +1477,21 @@ exports[`SessionResultPageComponent should snap with session details and results
- + +
+
+
+ Loading... +
+
+
-
-
- - Course ID: - -
+ Course ID: +
+ CS3281
-
-
- - Session: - -
+ Session: +
+ Peer Feedback
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
@@ -1692,6 +1662,9 @@ exports[`SessionResultPageComponent should snap with user that is logged in and authService={[Function AuthService]} backendUrl={[Function String]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} entityType={[Function String]} feedbackSessionName={[Function String]} feedbackSessionsService={[Function FeedbackSessionsService]} @@ -1700,6 +1673,7 @@ exports[`SessionResultPageComponent should snap with user that is logged in and hasFeedbackSessionResultsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading="false" isFeedbackSessionDetailsLoading="false" isFeedbackSessionResultsLoading="false" logService={[Function LogService]} @@ -1749,75 +1723,64 @@ exports[`SessionResultPageComponent should snap with user that is logged in and
-
-
- - Course ID: - -
+ Course ID: +
+ CS3281
-
-
- - Session: - -
+ Session: +
+ Peer Feedback
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
@@ -1845,6 +1808,9 @@ exports[`SessionResultPageComponent should snap with user that is not logged in authService={[Function AuthService]} backendUrl={[Function String]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} entityType={[Function String]} feedbackSessionName={[Function String]} feedbackSessionsService={[Function FeedbackSessionsService]} @@ -1853,6 +1819,7 @@ exports[`SessionResultPageComponent should snap with user that is not logged in hasFeedbackSessionResultsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading="false" isFeedbackSessionDetailsLoading="false" isFeedbackSessionResultsLoading="false" logService={[Function LogService]} @@ -1901,75 +1868,64 @@ exports[`SessionResultPageComponent should snap with user that is not logged in
-
-
- - Course ID: - -
+ Course ID: +
+ CS3281
-
-
- - Session: - -
+ Session: +
+ Peer Feedback
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
diff --git a/src/web/app/pages-session/session-result-page/session-result-page.component.html b/src/web/app/pages-session/session-result-page/session-result-page.component.html index 4c674c55782..63e21b64dde 100644 --- a/src/web/app/pages-session/session-result-page/session-result-page.component.html +++ b/src/web/app/pages-session/session-result-page/session-result-page.component.html @@ -18,33 +18,36 @@

-
+
-
-
Course ID:
-
{{ session.courseId }}
+ +
{{ courseId }}
+
+
+ +
{{ courseName }}
+
+
+ +
{{ courseInstitute }}
-
-
Session:
-
{{ session.feedbackSessionName }}
+ +
{{ feedbackSessionName }}
-
-
Opening time:
+
{{ formattedSessionOpeningTime }}
-
-
Closing time:
+
{{ formattedSessionClosingTime }}
-
-
+
If you wish to view the feedback results of the entire course, click here.
diff --git a/src/web/app/pages-session/session-result-page/session-result-page.component.scss b/src/web/app/pages-session/session-result-page/session-result-page.component.scss index 4d83a0746f9..2ac942bbfd6 100644 --- a/src/web/app/pages-session/session-result-page/session-result-page.component.scss +++ b/src/web/app/pages-session/session-result-page/session-result-page.component.scss @@ -4,3 +4,7 @@ border: 0; box-shadow: 0 0 0 0; } + +label { + font-weight: bold; +} diff --git a/src/web/app/pages-session/session-result-page/session-result-page.component.spec.ts b/src/web/app/pages-session/session-result-page/session-result-page.component.spec.ts index 58b7fbe4c6a..fd5a1007179 100644 --- a/src/web/app/pages-session/session-result-page/session-result-page.component.spec.ts +++ b/src/web/app/pages-session/session-result-page/session-result-page.component.spec.ts @@ -246,6 +246,7 @@ describe('SessionResultPageComponent', () => { logService = TestBed.inject(LogService); component = fixture.componentInstance; // Set both loading flags to false initially for testing purposes only + component.isCourseLoading = false; component.isFeedbackSessionDetailsLoading = false; component.isFeedbackSessionResultsLoading = false; fixture.detectChanges(); @@ -260,6 +261,7 @@ describe('SessionResultPageComponent', () => { }); it('should snap with session details and results are loading', () => { + component.isCourseLoading = true; component.isFeedbackSessionDetailsLoading = true; component.isFeedbackSessionResultsLoading = true; fixture.detectChanges(); @@ -267,6 +269,7 @@ describe('SessionResultPageComponent', () => { }); it('should snap with session details loaded and results are loading', () => { + component.isCourseLoading = false; component.isFeedbackSessionDetailsLoading = false; component.isFeedbackSessionResultsLoading = true; fixture.detectChanges(); @@ -274,6 +277,7 @@ describe('SessionResultPageComponent', () => { }); it('should snap when session results failed to load', () => { + component.isCourseLoading = false; component.isFeedbackSessionDetailsLoading = false; component.isFeedbackSessionResultsLoading = false; component.hasFeedbackSessionResultsLoadingFailed = true; diff --git a/src/web/app/pages-session/session-result-page/session-result-page.component.ts b/src/web/app/pages-session/session-result-page/session-result-page.component.ts index d8fe89ab4d2..910c2deb6c1 100644 --- a/src/web/app/pages-session/session-result-page/session-result-page.component.ts +++ b/src/web/app/pages-session/session-result-page/session-result-page.component.ts @@ -1,9 +1,11 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; +import { Observable } from 'rxjs'; import { finalize, switchMap, tap } from 'rxjs/operators'; import { environment } from '../../../environments/environment'; import { AuthService } from '../../../services/auth.service'; +import { CourseService } from '../../../services/course.service'; import { FeedbackSessionsService } from '../../../services/feedback-sessions.service'; import { InstructorService } from '../../../services/instructor.service'; import { LogService } from '../../../services/log.service'; @@ -13,6 +15,7 @@ import { StudentService } from '../../../services/student.service'; import { TimezoneService } from '../../../services/timezone.service'; import { AuthInfo, + Course, FeedbackSession, FeedbackSessionLogType, FeedbackSessionPublishStatus, FeedbackSessionSubmissionStatus, Instructor, @@ -58,6 +61,8 @@ export class SessionResultPageComponent implements OnInit { instructorDeadlines: {}, }; questions: QuestionOutput[] = []; + courseName: string = ''; + courseInstitute: string = ''; formattedSessionOpeningTime: string = ''; formattedSessionClosingTime: string = ''; personName: string = ''; @@ -71,6 +76,7 @@ export class SessionResultPageComponent implements OnInit { intent: Intent = Intent.STUDENT_RESULT; + isCourseLoading: boolean = true; isFeedbackSessionDetailsLoading: boolean = true; isFeedbackSessionResultsLoading: boolean = true; hasFeedbackSessionResultsLoadingFailed: boolean = false; @@ -86,6 +92,7 @@ export class SessionResultPageComponent implements OnInit { private authService: AuthService, private studentService: StudentService, private instructorService: InstructorService, + private courseService: CourseService, private statusMessageService: StatusMessageService, private logService: LogService, private ngbModal: NgbModal) { @@ -123,6 +130,7 @@ export class SessionResultPageComponent implements OnInit { { courseid: this.courseId, fsname: this.feedbackSessionName }); } else { // Valid, unused registration key; load information based on the key + this.loadCourseInfo(); this.loadPersonName(); this.loadFeedbackSession(); } @@ -156,6 +164,7 @@ export class SessionResultPageComponent implements OnInit { }); } else if (this.loggedInUser) { // Load information based on logged in user + this.loadCourseInfo(); this.loadPersonName(); this.loadFeedbackSession(); } else { @@ -169,6 +178,29 @@ export class SessionResultPageComponent implements OnInit { }); } + private loadCourseInfo(): void { + this.isCourseLoading = true; + let request: Observable; + switch (this.intent) { + case Intent.STUDENT_RESULT: + request = this.courseService.getCourseAsStudent(this.courseId, this.regKey); + break; + case Intent.INSTRUCTOR_RESULT: + request = this.courseService.getCourseAsInstructor(this.courseId, this.regKey); + break; + default: + this.isCourseLoading = false; + return; + } + request.subscribe((resp: Course) => { + this.courseName = resp.courseName; + this.courseInstitute = resp.institute; + this.isCourseLoading = false; + }, () => { + this.isCourseLoading = false; + }); + } + private loadPersonName(): void { switch (this.intent) { case Intent.STUDENT_RESULT: diff --git a/src/web/app/pages-session/session-submission-page/__snapshots__/session-submission-page.component.spec.ts.snap b/src/web/app/pages-session/session-submission-page/__snapshots__/session-submission-page.component.spec.ts.snap index c2ee3c21f4d..58d7b4e7e7d 100644 --- a/src/web/app/pages-session/session-submission-page/__snapshots__/session-submission-page.component.spec.ts.snap +++ b/src/web/app/pages-session/session-submission-page/__snapshots__/session-submission-page.component.spec.ts.snap @@ -8,6 +8,9 @@ exports[`SessionSubmissionPageComponent should snap when feedback session questi backendUrl={[Function String]} commentService={[Function FeedbackResponseCommentService]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} document={[Function Document]} entityType={[Function String]} feedbackQuestionsService={[Function FeedbackQuestionsService]} @@ -22,6 +25,7 @@ exports[`SessionSubmissionPageComponent should snap when feedback session questi hasFeedbackSessionQuestionsLoadingFailed={[Function Boolean]} instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading={[Function Boolean]} isFeedbackSessionLoading={[Function Boolean]} isFeedbackSessionQuestionsLoading={[Function Boolean]} isModerationHintExpanded="false" @@ -134,6 +138,9 @@ exports[`SessionSubmissionPageComponent should snap when saving responses 1`] = backendUrl={[Function String]} commentService={[Function FeedbackResponseCommentService]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} document={[Function Document]} entityType={[Function String]} feedbackQuestionsService={[Function FeedbackQuestionsService]} @@ -148,6 +155,7 @@ exports[`SessionSubmissionPageComponent should snap when saving responses 1`] = hasFeedbackSessionQuestionsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading={[Function Boolean]} isFeedbackSessionLoading={[Function Boolean]} isFeedbackSessionQuestionsLoading={[Function Boolean]} isModerationHintExpanded="false" @@ -257,6 +265,9 @@ exports[`SessionSubmissionPageComponent should snap with default fields 1`] = ` backendUrl={[Function String]} commentService={[Function FeedbackResponseCommentService]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} document={[Function Document]} entityType={[Function String]} feedbackQuestionsService={[Function FeedbackQuestionsService]} @@ -271,6 +282,7 @@ exports[`SessionSubmissionPageComponent should snap with default fields 1`] = ` hasFeedbackSessionQuestionsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading={[Function Boolean]} isFeedbackSessionLoading={[Function Boolean]} isFeedbackSessionQuestionsLoading={[Function Boolean]} isModerationHintExpanded="false" @@ -380,6 +392,9 @@ exports[`SessionSubmissionPageComponent should snap with feedback session and us backendUrl={[Function String]} commentService={[Function FeedbackResponseCommentService]} courseId={[Function String]} + courseInstitute={[Function String]} + courseName={[Function String]} + courseService={[Function CourseService]} document={[Function Document]} entityType={[Function String]} feedbackQuestionsService={[Function FeedbackQuestionsService]} @@ -394,6 +409,7 @@ exports[`SessionSubmissionPageComponent should snap with feedback session and us hasFeedbackSessionQuestionsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading="false" isFeedbackSessionLoading="false" isFeedbackSessionQuestionsLoading={[Function Boolean]} isModerationHintExpanded="false" @@ -468,19 +484,14 @@ exports[`SessionSubmissionPageComponent should snap with feedback session and us
-
-
- - Course ID: - -
+ Course ID: +
-
+
+ Course name +
+
+
+ +
+ Test institute
+
+
+
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
-
- - Instructions: - -
+ Instructions: +
-
@@ -600,6 +618,9 @@ exports[`SessionSubmissionPageComponent should snap with feedback session questi backendUrl={[Function String]} commentService={[Function FeedbackResponseCommentService]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} document={[Function Document]} entityType={[Function String]} feedbackQuestionsService={[Function FeedbackQuestionsService]} @@ -614,6 +635,7 @@ exports[`SessionSubmissionPageComponent should snap with feedback session questi hasFeedbackSessionQuestionsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading="false" isFeedbackSessionLoading="false" isFeedbackSessionQuestionsLoading="false" isModerationHintExpanded="false" @@ -687,19 +709,14 @@ exports[`SessionSubmissionPageComponent should snap with feedback session questi
-
-
- - Course ID: - -
+ Course ID: +
-
-
- - Session: - -
+ Session: +
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
-
- - Instructions: - -
+ Instructions: +
-
@@ -2813,9 +2807,6 @@ exports[`SessionSubmissionPageComponent should snap with feedback session questi
-
@@ -2845,6 +2836,9 @@ exports[`SessionSubmissionPageComponent should snap with feedback session questi backendUrl={[Function String]} commentService={[Function FeedbackResponseCommentService]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} document={[Function Document]} entityType={[Function String]} feedbackQuestionsService={[Function FeedbackQuestionsService]} @@ -2859,6 +2853,7 @@ exports[`SessionSubmissionPageComponent should snap with feedback session questi hasFeedbackSessionQuestionsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading="false" isFeedbackSessionLoading="false" isFeedbackSessionQuestionsLoading="false" isModerationHintExpanded="false" @@ -2932,19 +2927,14 @@ exports[`SessionSubmissionPageComponent should snap with feedback session questi
-
-
- - Course ID: - -
+ Course ID: +
-
-
- - Session: - -
+ Session: +
-
-
- - Opening time: - -
+ Opening time: +
-
-
- - Closing time: - -
+ Closing time: +
-
-
- - Instructions: - -
+ Instructions: +
-
@@ -5083,9 +5050,6 @@ exports[`SessionSubmissionPageComponent should snap with feedback session questi
-
@@ -5116,6 +5080,9 @@ exports[`SessionSubmissionPageComponent should snap with user that is logged in backendUrl={[Function String]} commentService={[Function FeedbackResponseCommentService]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} document={[Function Document]} entityType={[Function String]} feedbackQuestionsService={[Function FeedbackQuestionsService]} @@ -5130,6 +5097,7 @@ exports[`SessionSubmissionPageComponent should snap with user that is logged in hasFeedbackSessionQuestionsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading={[Function Boolean]} isFeedbackSessionLoading={[Function Boolean]} isFeedbackSessionQuestionsLoading={[Function Boolean]} isModerationHintExpanded="false" @@ -5240,6 +5208,9 @@ exports[`SessionSubmissionPageComponent should snap with user that is not logged backendUrl={[Function String]} commentService={[Function FeedbackResponseCommentService]} courseId={[Function String]} + courseInstitute="" + courseName="" + courseService={[Function CourseService]} document={[Function Document]} entityType={[Function String]} feedbackQuestionsService={[Function FeedbackQuestionsService]} @@ -5254,6 +5225,7 @@ exports[`SessionSubmissionPageComponent should snap with user that is not logged hasFeedbackSessionQuestionsLoadingFailed="false" instructorService={[Function InstructorService]} intent={[Function String]} + isCourseLoading={[Function Boolean]} isFeedbackSessionLoading={[Function Boolean]} isFeedbackSessionQuestionsLoading={[Function Boolean]} isModerationHintExpanded="false" diff --git a/src/web/app/pages-session/session-submission-page/session-submission-page.component.html b/src/web/app/pages-session/session-submission-page/session-submission-page.component.html index 65aa89db10f..39b6d24925d 100644 --- a/src/web/app/pages-session/session-submission-page/session-submission-page.component.html +++ b/src/web/app/pages-session/session-submission-page/session-submission-page.component.html @@ -49,34 +49,36 @@

Previewing Session as

-
+
-
-
Course ID:
+
{{ courseId }}
-
+
+ +
{{ courseName }}
+
+
+ +
{{ courseInstitute }}
+
-
Session:
+
{{ feedbackSessionName }}
-
-
Opening time:
+
{{ formattedSessionOpeningTime }}
-
-
Closing time:
+
{{ formattedSessionClosingTime }}
-
-
Instructions:
+
-
@@ -91,7 +93,6 @@

Previewing Session as (deleteCommentEvent)="deleteParticipantComment(i, $event)" > -
+
+
+ +
+
+ + Test Institute + +
+
diff --git a/src/web/app/pages-student/student-course-details-page/student-course-details-page.component.html b/src/web/app/pages-student/student-course-details-page/student-course-details-page.component.html index d5da94c3709..bacb4ed12ae 100644 --- a/src/web/app/pages-student/student-course-details-page/student-course-details-page.component.html +++ b/src/web/app/pages-student/student-course-details-page/student-course-details-page.component.html @@ -20,6 +20,14 @@

Team Details for {{ co {{ course.courseName }}

+
+
+ +
+
+ {{ course.institute }} +
+
diff --git a/src/web/app/pages-student/student-page.component.html b/src/web/app/pages-student/student-page.component.html index 97cedb5a150..a76a48c37bc 100644 --- a/src/web/app/pages-student/student-page.component.html +++ b/src/web/app/pages-student/student-page.component.html @@ -1,6 +1,5 @@ ', + template: '', }) export class PublicPageComponent { - institute: string = ''; - constructor(private route: ActivatedRoute, - private authService: AuthService, - private studentService: StudentService, - private instructorService: InstructorService) { + private authService: AuthService) { if (environment.maintenance) { return; } this.route.queryParams.subscribe((queryParams: any) => { this.authService.getAuthUser(queryParams.user).subscribe(() => { // No need to do anything with result; this is necessary to get CSRF token - - // Loads institute for student session submission and result - const courseId: string = queryParams.courseid; - const regKey: string = queryParams.key; - const entityType: string = queryParams.entitytype; - if (courseId && regKey) { - if (entityType === 'instructor') { - this.instructorService.getInstructor({ - courseId, - key: regKey, - intent: Intent.INSTRUCTOR_SUBMISSION, - }).subscribe((instructor: Instructor) => { - this.institute = instructor.institute || ''; - }); - } else { - this.studentService.getStudent(courseId, '', regKey).subscribe((student: Student) => { - this.institute = student.institute || ''; - }); - } - } }); }); } diff --git a/src/web/services/account.service.spec.ts b/src/web/services/account.service.spec.ts index cb8941676f5..593bc24afd4 100644 --- a/src/web/services/account.service.spec.ts +++ b/src/web/services/account.service.spec.ts @@ -105,14 +105,6 @@ describe('AccountService', () => { expect(spyHttpRequestService.put).toHaveBeenCalledWith(ResourceEndpoints.ACCOUNT_REQUEST_RESET, paramMap); }); - it('should execute PUT on account/downgrade endpoint', () => { - service.downgradeAccount(id); - const paramMap: Record = { - instructorid: id, - }; - expect(spyHttpRequestService.put).toHaveBeenCalledWith(ResourceEndpoints.ACCOUNT_DOWNGRADE, paramMap); - }); - it('should execute PUT on account/reset endpoint for student', () => { service.resetStudentAccount(id, 'testStudentEmail'); const paramMap: Record = { diff --git a/src/web/services/account.service.ts b/src/web/services/account.service.ts index b2f6590cbfd..18f85d0254a 100644 --- a/src/web/services/account.service.ts +++ b/src/web/services/account.service.ts @@ -33,16 +33,6 @@ export class AccountService { return this.httpRequestService.post(ResourceEndpoints.ACCOUNT_REQUEST, {}, request); } - /** - * Downgrades an account from instructor to student by calling API. - */ - downgradeAccount(id: string): Observable { - const paramMap: Record = { - instructorid: id, - }; - return this.httpRequestService.put(ResourceEndpoints.ACCOUNT_DOWNGRADE, paramMap); - } - /** * Deletes an account by calling API. */ diff --git a/src/web/services/course.service.spec.ts b/src/web/services/course.service.spec.ts index 5b741f38066..78477af968b 100644 --- a/src/web/services/course.service.spec.ts +++ b/src/web/services/course.service.spec.ts @@ -1,7 +1,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { TestBed } from '@angular/core/testing'; import { ResourceEndpoints } from '../types/api-const'; -import { CourseArchiveRequest, CourseCreateRequest } from '../types/api-request'; +import { CourseArchiveRequest, CourseCreateRequest, CourseUpdateRequest } from '../types/api-request'; import { CourseService } from './course.service'; import { HttpRequestService } from './http-request.service'; @@ -111,15 +111,16 @@ describe('CourseService', () => { courseName: 'test-name', timeZone: 'test-zone', }; - const paramMap: { [key: string]: string } = {}; - service.createCourse(request); + const paramMap: { [key: string]: string } = { + instructorinstitution: 'test-institute', + }; + service.createCourse('test-institute', request); expect(spyHttpRequestService.post).toHaveBeenCalledWith(ResourceEndpoints.COURSE, paramMap, request); }); it('should execute PUT to update course', () => { const courseid: string = 'test-id'; - const request: CourseCreateRequest = { - courseId: courseid, + const request: CourseUpdateRequest = { courseName: 'test-name', timeZone: 'test-zone', }; diff --git a/src/web/services/course.service.ts b/src/web/services/course.service.ts index 59eaed764c9..a53943a424b 100644 --- a/src/web/services/course.service.ts +++ b/src/web/services/course.service.ts @@ -40,11 +40,14 @@ export class CourseService { /** * Get course data by calling API as an instructor. */ - getCourseAsInstructor(courseId: string): Observable { + getCourseAsInstructor(courseId: string, regKey?: string): Observable { const paramMap: Record = { courseid: courseId, entitytype: 'instructor', }; + if (regKey) { + paramMap.key = regKey; + } return this.httpRequestService.get(ResourceEndpoints.COURSE, paramMap); } @@ -61,11 +64,14 @@ export class CourseService { /** * Get course data by calling API as a student. */ - getCourseAsStudent(courseId: string): Observable { + getCourseAsStudent(courseId: string, regKey?: string): Observable { const paramMap: Record = { courseid: courseId, entitytype: 'student', }; + if (regKey) { + paramMap.key = regKey; + } return this.httpRequestService.get(ResourceEndpoints.COURSE, paramMap); } @@ -120,8 +126,10 @@ export class CourseService { /** * Creates a course by calling API. */ - createCourse(request: CourseCreateRequest): Observable { - const paramMap: Record = {}; + createCourse(institute: string, request: CourseCreateRequest): Observable { + const paramMap: Record = { + instructorinstitution: institute, + }; return this.httpRequestService.post(ResourceEndpoints.COURSE, paramMap, request); }