-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
If you try to change a student's topic in the student dashboard (when logged in as teacher or admin), the server will send back an error 500.
Following error log:
java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')
at de.igslandstuhl.database.server.webserver.requests.PostRequest.getInt(PostRequest.java:152)
at de.igslandstuhl.database.server.webserver.requests.APIPostRequest.getTopic(APIPostRequest.java:56)
at de.igslandstuhl.database.server.webserver.handlers.PostRequestHandler.lambda$registerHandlers$15(PostRequestHandler.java:261)
at de.igslandstuhl.database.server.webserver.handlers.HttpHandler.handleHttpRequest(HttpHandler.java:38)
at de.igslandstuhl.database.server.webserver.handlers.PostRequestHandler.handlePostRequest(PostRequestHandler.java:86)
at de.igslandstuhl.database.server.WebServer$ClientHandler.handlePost(WebServer.java:149)
at de.igslandstuhl.database.server.WebServer$ClientHandler.run(WebServer.java:103)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
The error is thrown in the following line:
Line 261 in ce60199
| Topic topic = rq.getTopic(); |
(whole handler:
Lines 257 to 265 in ce60199
| HttpHandler.registerPostRequestHandler("/change-current-topic", AccessLevel.TEACHER, (rq) -> { | |
| Student student = rq.getCurrentStudent(); | |
| if (student == null) return PostResponse.unauthorized(rq); | |
| Subject subject = rq.getSubject(); | |
| Topic topic = rq.getTopic(); | |
| if (subject == null || topic == null) return PostResponse.badRequest("Subject or topic id not found", rq); | |
| student.setCurrentTopic(subject, topic); | |
| return PostResponse.ok("Current topic changed successfully", ContentType.TEXT_PLAIN, rq); | |
| }); |
Probably the issue is that the handler expects the topic id (as a number) but it is either given the topic name or the topic id as string.
This is the relevant code in the front end:
student-database/src/main/resources/js/site/student-database.js
Lines 663 to 673 in ce60199
| const topicSelect = document.createElement('select'); | |
| topicSelect.id = "topicSelect"; | |
| populateTopicSelect(topicSelect, subject.id, studentData.schoolClass.grade, topic); | |
| topicSelect.addEventListener('change', async e => { | |
| result = await changeCurrentTopic(studentId, subject.id, topicSelect.value); | |
| if (result.ok) { | |
| panel.refresh(); | |
| } else { | |
| alert('Fehler beim Ändern des Themas') | |
| } | |
| }); |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers