diff --git a/.idea/sonarlint.xml b/.idea/sonarlint.xml index a43053d..c732a21 100644 --- a/.idea/sonarlint.xml +++ b/.idea/sonarlint.xml @@ -1,13 +1,10 @@ - - \ No newline at end of file diff --git a/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/ExercisePanel.java b/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/ExercisePanel.java index 82c5963..5b88fd5 100644 --- a/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/ExercisePanel.java +++ b/src/main/java/edu/kit/kastel/sdq/intelligrade/extensions/guis/ExercisePanel.java @@ -62,6 +62,7 @@ public class ExercisePanel extends SimpleToolWindowPanel { private JPanel generalPanel; private JButton startGradingRound1Button; private JButton startGradingRound2Button; + private JButton startGradingRound3Button; private TextFieldWithBrowseButton gradingConfigPathInput; private JPanel statisticsPanel; @@ -142,10 +143,21 @@ private void createGeneralPanel() { a -> PluginState.getInstance().startNextAssessment(1)); generalPanel.add(startGradingRound2Button, "growx"); - //only add the third grading round button iff the permissions are sufficient - PluginState.getInstance().registerConnectedListener(connectionOptional -> { - connectionOptional.flatMap(PermissionUtils::getAssessorPermissionLevel).ifPresent(System.out::println); - }); + //add button for third correction round but disable it by default + startGradingRound3Button = new JButton("Start Grading Round 3"); + startGradingRound3Button.setForeground(JBColor.GREEN); + startGradingRound3Button.addActionListener( + a -> PluginState.getInstance().startNextAssessment(3)); + startGradingRound3Button.setEnabled(false); + generalPanel.add(startGradingRound3Button, "growx"); + + //only enable the third grading round button iff the permissions are sufficient + PluginState.getInstance().registerConnectedListener(connectionOptional -> connectionOptional.ifPresent(connection -> { + List perms = PermissionUtils.getAssessorPermissionLevel(connection); + if (perms.contains(PermissionUtils.PermissionLevel.INSTRUCTOR)) { + startGradingRound3Button.setEnabled(true); + } + })); gradingConfigPathInput = new TextFieldWithBrowseButton(); gradingConfigPathInput.addBrowseFolderListener( diff --git a/src/main/java/edu/kit/kastel/sdq/intelligrade/utils/PermissionUtils.java b/src/main/java/edu/kit/kastel/sdq/intelligrade/utils/PermissionUtils.java index a6e11f5..dcca822 100644 --- a/src/main/java/edu/kit/kastel/sdq/intelligrade/utils/PermissionUtils.java +++ b/src/main/java/edu/kit/kastel/sdq/intelligrade/utils/PermissionUtils.java @@ -2,7 +2,6 @@ import edu.kit.kastel.sdq.artemis4j.ArtemisNetworkException; import edu.kit.kastel.sdq.artemis4j.grading.ArtemisConnection; -import edu.kit.kastel.sdq.intelligrade.state.PluginState; import java.util.ArrayList; import java.util.List; @@ -54,14 +53,14 @@ public static List getAssessorPermissionLevel(ArtemisConnection permissionLevels.add(PermissionLevel.NONE); } - return permissionLevels; + return permissionLevels.stream().distinct().toList(); } /** * Map the string based permission level from the groups * to some cleanly switchable enum */ - public enum PermissionLevel implements Comparable { + public enum PermissionLevel { INSTRUCTOR, TUTOR, STUDENT,