mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EDU-810 Friendly message in case we got no recommendations for the adaptive course
This commit is contained in:
@@ -848,4 +848,8 @@ public class StudyUtils {
|
||||
final int endOffset = startOffset + length + delta;
|
||||
return Pair.create(startOffset, endOffset);
|
||||
}
|
||||
|
||||
public static boolean isCourseValid(@Nullable Course course) {
|
||||
return course != null && !(course.isAdaptive() && course.getLessons().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -93,6 +93,10 @@ public class StudyProjectGenerator {
|
||||
Messages.showWarningDialog("Some problems occurred while creating the course", "Error in Course Creation");
|
||||
return;
|
||||
}
|
||||
else if (course.isAdaptive() && course.getLessons().isEmpty()) {
|
||||
Messages.showWarningDialog("There is no recommended tasks for this adaptive course", "Error in Course Creation");
|
||||
return;
|
||||
}
|
||||
final File courseDirectory = StudyUtils.getCourseDirectory(course);
|
||||
StudyTaskManager.getInstance(project).setCourse(course);
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
@@ -135,7 +139,7 @@ public class StudyProjectGenerator {
|
||||
ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
|
||||
return execCancelable(() -> {
|
||||
final Course course = EduStepicConnector.getCourse(project, mySelectedCourseInfo);
|
||||
if (course != null) {
|
||||
if (StudyUtils.isCourseValid(course)) {
|
||||
flushCourse(course);
|
||||
course.initCourse(false);
|
||||
}
|
||||
|
||||
+4
-7
@@ -212,19 +212,16 @@ public class EduStepicConnector {
|
||||
}
|
||||
}
|
||||
else {
|
||||
final Lesson lesson = new Lesson();
|
||||
course.setName(info.getName());
|
||||
//TODO: more specific name?
|
||||
lesson.setName("Adaptive");
|
||||
course.addLesson(lesson);
|
||||
final Task recommendation = EduAdaptiveStepicConnector.getNextRecommendation(project, course);
|
||||
if (recommendation != null) {
|
||||
final Lesson lesson = new Lesson();
|
||||
lesson.setName("Adaptive");
|
||||
course.addLesson(lesson);
|
||||
lesson.addTask(recommendation);
|
||||
return course;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return course;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user