From 3f5f224d68ddfb0302dcd76156689c9ccc023b88 Mon Sep 17 00:00:00 2001 From: Taikelenn Date: Tue, 15 Aug 2023 12:36:14 +0300 Subject: [PATCH 1/2] More lenient exercise JSON parsing --- .../fi/aalto/cs/apluscourses/model/SubmissionInfo.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/fi/aalto/cs/apluscourses/model/SubmissionInfo.java b/src/main/java/fi/aalto/cs/apluscourses/model/SubmissionInfo.java index da8186c3d..a8e48886e 100644 --- a/src/main/java/fi/aalto/cs/apluscourses/model/SubmissionInfo.java +++ b/src/main/java/fi/aalto/cs/apluscourses/model/SubmissionInfo.java @@ -35,7 +35,13 @@ public static SubmissionInfo fromJsonObject(@NotNull JSONObject jsonObject) { return new SubmissionInfo(Collections.emptyMap()); } - JSONArray formSpec = exerciseInfo.getJSONArray("form_spec"); + JSONArray formSpec = exerciseInfo.optJSONArray("form_spec"); + if (formSpec == null) { + // Some assignments, such as https://plus.cs.aalto.fi/api/v2/exercises/50181/ don't have the + // form_spec field despite having exercise_info. + return new SubmissionInfo(Collections.emptyMap()); + } + JSONObject localizationInfo = exerciseInfo.getJSONObject("form_i18n"); Map> files = new HashMap<>(); From ff4146ae860ceb1cbbeafa524444ddce34f0fb5d Mon Sep 17 00:00:00 2001 From: Taikelenn Date: Tue, 15 Aug 2023 13:05:12 +0300 Subject: [PATCH 2/2] Fix Modules button being present where it should be hidden --- .../aalto/cs/apluscourses/intellij/services/PluginSettings.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/fi/aalto/cs/apluscourses/intellij/services/PluginSettings.java b/src/main/java/fi/aalto/cs/apluscourses/intellij/services/PluginSettings.java index 164cbcd17..10a871ce4 100644 --- a/src/main/java/fi/aalto/cs/apluscourses/intellij/services/PluginSettings.java +++ b/src/main/java/fi/aalto/cs/apluscourses/intellij/services/PluginSettings.java @@ -205,6 +205,8 @@ public void registerCourseProject(@NotNull CourseProject courseProject) { // instructed to turn the project into a course project for an example when the token is // missing. mainViewModel.toolWindowCardViewModel.setAPlusProject(true); + mainViewModel.toolWindowCardViewModel.setModuleButtonRequiresLogin( + courseProject.getCourse().requiresLoginForModules()); courseProject.user.addValueObserver(mainViewModel, MainViewModel::userChanged); courseProject.user.addSimpleObserver(courseProject, courseP -> courseP.getCourseUpdater().restart()); var exercisesViewModel = new ExercisesTreeViewModel(new ExercisesTree(), new Options());