Fix for always add hints and reasons
@@ -52,14 +52,14 @@ public class ChallengesController {
model.addAttribute("answerCorrect", null);
model.addAttribute("answerIncorrect", null);
model.addAttribute("solution", null);
- model.addAttribute("hintsEnabled", hintsEnabled);
- model.addAttribute("reasonEnabled", reasonEnabled);
+ enrichWithHintsAndReasons(model);
includeScoringStatus(model, challenge.getChallenge());
addWarning(challenge.getChallenge(), model);
return "challenge";
}
+
@PostMapping(value = "/challenge/{id}", params = "action=reset")
public String reset(@ModelAttribute ChallengeForm challengeForm, @PathVariable Integer id, Model model) {
var challenge = challenges.get(id - 1);
@@ -68,6 +68,7 @@ public class ChallengesController {
model.addAttribute("challenge", challenge);
includeScoringStatus(model, challenge.getChallenge());
addWarning(challenge.getChallenge(), model);
+ enrichWithHintsAndReasons(model);
return "challenge";
}
@@ -85,6 +86,7 @@ public class ChallengesController {
model.addAttribute("challenge", challenge);
includeScoringStatus(model, challenge.getChallenge());
+ enrichWithHintsAndReasons(model);
return "challenge";
}
@@ -106,4 +108,9 @@ public class ChallengesController {
model.addAttribute("missingEnvWarning", warning);
}
}
+
+ private void enrichWithHintsAndReasons(Model model) {
+ model.addAttribute("hintsEnabled", hintsEnabled);
+ model.addAttribute("reasonEnabled", reasonEnabled);
+ }
}
