Skip to content

Commit

Permalink
LMSA-7975 - last pass at feature before code review
Browse files Browse the repository at this point in the history
  • Loading branch information
iudsobiera committed Sep 19, 2023
1 parent bd6dda8 commit bedcd0c
Show file tree
Hide file tree
Showing 7 changed files with 285 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public interface CrosslistConstants {

String LOOKUP_SUCCESS_FOUND_MESSAGE = "Parent course is found";
String LOOKUP_FAILURE_COURSE_NOT_CROSSLISTED_MESSAGE = "This course has not been crosslisted";
String LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE = "This section has not been found in Canvas";
String LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_SIS_MESSAGE = "Section not found in SIS";
String LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE = "Not found in Canvas";
String LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE = "Not found in SIS";

String LOOKUP_SUCCESS_CSS = "rvt-color-green rvt-bg-green-100";
String LOOKUP_FAILURE_CSS = "rvt-orange-green rvt-bg-orange-100";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,43 +879,45 @@ public String endSelfImpersonation(@PathVariable("courseId") String courseId, @M

@RequestMapping("/lookup-launch")
@Secured({LTIConstants.ADMIN_AUTHORITY, LTIConstants.INSTRUCTOR_AUTHORITY})
public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Model model, HttpServletRequest request) {
OidcAuthenticationToken token = getTokenWithoutContext();
OidcTokenUtils oidcTokenUtils = new OidcTokenUtils(token);
String courseId = oidcTokenUtils.getCourseId();
public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) {
getTokenWithoutContext();

OidcAuthenticationToken sessionToken = courseSessionService.getAttributeFromSession(request.getSession(), courseId, OidcTokenAwareController.SESSION_TOKEN_KEY, OidcAuthenticationToken.class);
List<CanvasTerm> terms = termService.getEnrollmentTerms()
.stream()
.filter(term -> term.getSisTermId().compareTo("4218") >= 0 && term.getSisTermId().charAt(0) == '4')
.sorted(Comparator.comparing(CanvasTerm::getSisTermId))
.toList();

if (sessionToken == null) {
courseSessionService.addAttributeToSession(request.getSession(), courseId, OidcTokenAwareController.SESSION_TOKEN_KEY, token);
if (courseSessionService.getAttributeFromSession(session, "all", "terms", List.class) == null) {
courseSessionService.addAttributeToSession(session, "all", "terms", terms);
}

// model.addAttribute("courseId", courseId);
// model.addAttribute("hideFooter", true);

// SubmissionStatus status = new SubmissionStatus();
// status.setStatusClass(CrosslistConstants.STATUS_SUCCESS);
// status.setStatusMessage("Ta dah!");
//
// model.addAttribute("submissionStatus", status);
model.addAttribute("terms", terms);

return "findParentCourse";
}

@PostMapping(value = "/lookup-search-sisid")
@Secured({LTIConstants.BASE_USER_AUTHORITY})
public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) {
log.info("SIS search text = {}", findParentModel.getSisIdSearch());
getTokenWithoutContext();

FindParentResult findParentResult = null;

if (findParentModel.getSisIdSearch() != null && ! findParentModel.getSisIdSearch().trim().isEmpty()) {
// Section section = sectionService.getSection(String.format("sis_section_id:%s", findParentModel.getSisIdSearch()));
List<CanvasTerm> terms = courseSessionService.getAttributeFromSession(session, "all",
"terms", List.class);

if (findParentModel.getSisIdSearch() == null || findParentModel.getSisIdSearch().trim().isEmpty()) {
findParentResult = new FindParentResult();
findParentResult.setStatusMessage("SIS ID needs to have a value");
findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS);
} else {
SisCourse sisCourse = sisService.getSisCourseBySiteId(findParentModel.getSisIdSearch().trim());
findParentResult = crosslistService.processSisLookup(sisCourse);
}

model.addAttribute("terms", terms);

if (findParentResult != null) {
model.addAttribute("findParentResult", findParentResult);
}
Expand All @@ -926,58 +928,32 @@ public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentMode
@PostMapping(value = "/lookup-search-termandclassnumber")
@Secured({LTIConstants.BASE_USER_AUTHORITY})
public String lookupSearchByTermAndClassNUmber(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) {
log.info("Term by Class Number = {}", findParentModel.getTermByClassNumberSearch());
log.info("Class Number search text = {}", findParentModel.getClassNumberSearch());
getTokenWithoutContext();

FindParentResult findParentResult = null;

if (findParentModel.getTermByClassNumberSearch() != null && ! findParentModel.getTermByClassNumberSearch().trim().isEmpty() &&
findParentModel.getClassNumberSearch() != null && ! findParentModel.getClassNumberSearch().trim().isEmpty()) {

List<CanvasTerm> terms = courseSessionService.getAttributeFromSession(session, "all",
"terms", List.class);

if (findParentModel.getTermByClassNumberSearch() == null || findParentModel.getTermByClassNumberSearch().trim().isEmpty()) {
findParentResult = new FindParentResult();
findParentResult.setStatusMessage("Term needs to have a value");
findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS);
} else if (findParentModel.getClassNumberSearch() == null || findParentModel.getClassNumberSearch().trim().isEmpty()) {
findParentResult = new FindParentResult();
findParentResult.setStatusMessage("Class Number needs to have a value");
findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS);
} else {
final String strm = findParentModel.getTermByClassNumberSearch().trim();
final String classNumber = findParentModel.getClassNumberSearch().trim();

final String iuSiteId = sisService.getIuSiteIdFromStrmAndClassNumber(strm, classNumber);

SisCourse sisCourse = sisService.getSisCourseBySiteId(iuSiteId);

// Section section = sectionService.getSection(String.format("sis_section_id:%s", iuSiteId));

findParentResult = crosslistService.processSisLookup(sisCourse);
}

if (findParentResult != null) {
model.addAttribute("findParentResult", findParentResult);
}


return "findParentCourse";
}

@PostMapping(value = "/lookup-search-canvascourseid")
@Secured({LTIConstants.BASE_USER_AUTHORITY})
public String lookupSearchByCourseId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) {
log.info("Canvas CourseId search text = {}", findParentModel.getCanvasCourseIdSearch());

FindParentResult findParentResult = null;

if (findParentModel.getCanvasCourseIdSearch() != null && ! findParentModel.getCanvasCourseIdSearch().trim().isEmpty()) {
List<Section> sections = courseService.getCourseSections(findParentModel.getCanvasCourseIdSearch().trim());

boolean isCrosslisted = false;

for (Section section : sections) {
if (section.getSis_section_id() != null && ! section.getSis_section_id().isEmpty() &&
section.getSis_course_id() != null && ! section.getSis_course_id().isEmpty() &&
! section.getSis_section_id().equals(section.getSis_course_id())) {
SisCourse sisCourse = new SisCourse();
findParentResult = crosslistService.processSisLookup(sisCourse);

}

}

}
model.addAttribute("terms", terms);

if (findParentResult != null) {
model.addAttribute("findParentResult", findParentResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ public class FindParentModel {
private String sisIdSearch;
private String termByClassNumberSearch;
private String classNumberSearch;
private String canvasCourseIdSearch;
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,29 +394,33 @@ public FindParentResult processSisLookup(SisCourse sisCourse) {
FindParentResult findParentResult = new FindParentResult();

if (sisCourse == null || sisCourse.getIuSiteId() == null) {
findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_SIS_MESSAGE);
findParentResult.setShowCourseInfo(false);
findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE);
findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS);
return findParentResult;
}

Section section = sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId()));

if (section == null) {
findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE);
findParentResult.setShowCourseInfo(false);
findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE);
findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS);
return findParentResult;
}

if (section.getSis_course_id() == null || section.getSis_section_id() == null) {
findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE);
findParentResult.setShowCourseInfo(false);
findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE);
findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS);
return findParentResult;
}

Course course = courseService.getCourse(section.getCourse_id());

if (course == null) {
findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE);
findParentResult.setShowCourseInfo(false);
findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE);
findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS);
return findParentResult;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/css/crosslisting.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@
margin-bottom: 0.5rem;
}

.alertThing {
.resultsWidth {
width: max-content;
}
Loading

0 comments on commit bedcd0c

Please sign in to comment.