Skip to content

Commit

Permalink
CSCEXAM-1258 Add more info on BYOD exam capacities for teachers (#1031)
Browse files Browse the repository at this point in the history
Co-authored-by: Matti Lupari <[email protected]>
  • Loading branch information
lupari and Matti Lupari authored Jan 30, 2024
1 parent a461d07 commit eac262e
Show file tree
Hide file tree
Showing 13 changed files with 1,426 additions and 2,464 deletions.
13 changes: 10 additions & 3 deletions app/controllers/ExamController.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,23 @@ public Result getExam(Long id, Http.Request request) {
if (exam == null) {
return notFound("i18n_error_exam_not_found");
}
// decipher the settings passwords if any
// decipher the passwords if any
if (exam.getImplementation() == Exam.Implementation.CLIENT_AUTH) {
exam
.getExaminationEventConfigurations()
.forEach(eec -> {
String plainTextPwd = byodConfigHandler.getPlaintextPassword(
String plainTextSettingsPwd = byodConfigHandler.getPlaintextPassword(
eec.getEncryptedSettingsPassword(),
eec.getSettingsPasswordSalt()
);
eec.setSettingsPassword(plainTextPwd);
eec.setSettingsPassword(plainTextSettingsPwd);
if (eec.getEncryptedQuitPassword() != null) {
String plainTextQuitPwd = byodConfigHandler.getPlaintextPassword(
eec.getEncryptedQuitPassword(),
eec.getQuitPasswordSalt()
);
eec.setQuitPassword(plainTextQuitPwd);
}
});
}
User user = request.attrs().get(Attrs.AUTHENTICATED_USER);
Expand Down
19 changes: 18 additions & 1 deletion app/controllers/ExaminationEventController.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.inject.Inject;
import models.Exam;
import models.ExaminationDate;
Expand Down Expand Up @@ -209,7 +210,7 @@ public Result updateExaminationEvent(Long eid, Long eecid, Http.Request request)
return ok(eec);
}
if (!hasEnrolments) {
encryptQuitPassword(eec, settingsPassword);
encryptQuitPassword(eec, quitPassword);
encryptSettingsPassword(eec, settingsPassword, quitPassword);
eec.save();
// Pass back the plaintext passwords, so they can be shown to user
Expand Down Expand Up @@ -321,4 +322,20 @@ public Result listExaminationEvents(Optional<String> start, Optional<String> end
Set<ExaminationEventConfiguration> exams = query.where().eq("exam.state", Exam.State.PUBLISHED).findSet();
return ok(exams, pp);
}

@Restrict({ @Group("TEACHER"), @Group("ADMIN") })
public Result listOverlappingExaminationEvents(String start, Integer duration) {
PathProperties pp = PathProperties.parse("(*, examinationEventConfiguration(exam(id, duration)))");
DateTime startDate = DateTime.parse(start, ISODateTimeFormat.dateTimeParser());
DateTime endDate = startDate.plusMinutes(duration);
Set<ExaminationEvent> events = DB
.find(ExaminationEvent.class)
.where()
.le("start", endDate)
.findSet()
.stream()
.filter(ee -> !getEventEnding(ee).isBefore(startDate))
.collect(Collectors.toSet());
return ok(events, pp);
}
}
7 changes: 7 additions & 0 deletions app/controllers/SettingsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ public Result getCourseCodePrefix() {
return ok(Json.toJson(node));
}

@Restrict({ @Group("ADMIN"), @Group("TEACHER") })
public Result getByodMaxParticipants() {
ObjectNode node = Json.newObject();
node.put("max", configReader.getMaxByodExaminationParticipantCount());
return ok(Json.toJson(node));
}

private URL parseExternalUrl(String reservationRef) throws MalformedURLException {
return URI
.create(configReader.getIopHost() + String.format("/api/enrolments/%s/instructions", reservationRef))
Expand Down
2 changes: 2 additions & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ POST /app/exam/:eid/examinationevents controll
PUT /app/exam/:eid/examinationevents/:eecid controllers.ExaminationEventController.updateExaminationEvent(eid: Long, eecid: Long, request: Request)
DELETE /app/exam/:eid/examinationevents/:eecid controllers.ExaminationEventController.removeExaminationEvent(eid: Long, eecid: Long)
GET /app/examinationevents controllers.ExaminationEventController.listExaminationEvents(start: java.util.Optional[String], end: java.util.Optional[String])
GET /app/examinationevents/conflicting controllers.ExaminationEventController.listOverlappingExaminationEvents(start: String, duration: Int)

############### Question review interface ###############
GET /app/exam/:id/questions controllers.QuestionReviewController.getEssays(id: Long, ids: java.util.Optional[LongList], request: Request)
Expand Down Expand Up @@ -438,6 +439,7 @@ GET /app/settings/appVersion controlle
GET /app/settings/maturityInstructions controllers.SettingsController.getMaturityInstructions(lang: String, ref: java.util.Optional[String])
GET /app/settings/examinationQuitLink controllers.SettingsController.getExaminationQuitLink
GET /app/settings/coursecodeprefix controllers.SettingsController.getCourseCodePrefix
GET /app/settings/byodmaxparticipants controllers.SettingsController.getByodMaxParticipants


################# Statistics interface ##################
Expand Down
Loading

0 comments on commit eac262e

Please sign in to comment.