Skip to content
Snippets Groups Projects
Commit ba921b4f authored by User expired's avatar User expired
Browse files

OPENOLAT-368: sort list of external courses showing not yet created courses...

OPENOLAT-368: sort list of external courses showing not yet created courses first and by title descending
parent cdf0aca8
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
package at.ac.uibk.course;
import java.util.Comparator;
import java.util.List;
import org.olat.core.gui.control.generic.ajax.autocompletion.ListProvider;
......@@ -62,11 +63,19 @@ public class ExternalCourseSearchListProvider implements ListProvider {
try {
final SisCourses courses = SisManager.getInstance().findCourses(userIdentity, searchValue);
if (courses != null && courses.getCourses() != null) {
List<String> existingCourses = RepositoryManager.getInstance().lookupExistingExternalIds(courses.getSisCourseIds());
for (SisCourse c : courses.getCourses()) {
receiver.addEntry(c.getSisCourseId(), c.getSisCourseId(), c.getTitle(),
existingCourses.contains(c.getSisCourseId()) ? CSSHelper.CSS_CLASS_DISABLED: "");
}
List<String> existingCourses = RepositoryManager.getInstance()
.lookupExistingExternalIds(courses.getSisCourseIds());
Comparator<SisCourse> byExisting = (c1, c2) -> Boolean.compare(
existingCourses.contains(c1.getSisCourseId()),
existingCourses.contains(c2.getSisCourseId()));
Comparator<SisCourse> byTitle = (c1, c2)
-> c2.getTitle().compareTo(c1.getTitle());
courses.getCourses().stream()
.sorted(byExisting.thenComparing(byTitle))
.forEachOrdered(c -> receiver.addEntry(
c.getSisCourseId(), c.getSisCourseId(), c.getTitle(),
existingCourses.contains(c.getSisCourseId()) ?
CSSHelper.CSS_CLASS_DISABLED: ""));
}
} catch (SisManagerException ex) {
receiver.addEntry("-", "-", backend_errormsg, CSSHelper.CSS_CLASS_ERROR);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment