Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
995e69e302 | ||
|
|
698bb0e99f | ||
|
|
3c0455bff7 | ||
|
|
ed109df111 | ||
|
|
e8de49732b | ||
|
|
123261aad3 |
No files matched your search
@@ -2,6 +2,7 @@ package com.example.questionbank.repository;
|
|||||||
|
|
||||||
import com.example.questionbank.domain.ExamAttempt;
|
import com.example.questionbank.domain.ExamAttempt;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -14,6 +15,8 @@ import org.springframework.stereotype.Repository;
|
|||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface ExamAttemptRepository extends JpaRepository<ExamAttempt, Long> {
|
public interface ExamAttemptRepository extends JpaRepository<ExamAttempt, Long> {
|
||||||
|
List<ExamAttempt> findAllByUserLogin(String login);
|
||||||
|
|
||||||
@Query("select examAttempt from ExamAttempt examAttempt where examAttempt.user.login = ?#{authentication.name}")
|
@Query("select examAttempt from ExamAttempt examAttempt where examAttempt.user.login = ?#{authentication.name}")
|
||||||
List<ExamAttempt> findByUserIsCurrentUser();
|
List<ExamAttempt> findByUserIsCurrentUser();
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.example.questionbank.repository;
|
|||||||
|
|
||||||
import com.example.questionbank.domain.Question;
|
import com.example.questionbank.domain.Question;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -14,6 +15,8 @@ import org.springframework.stereotype.Repository;
|
|||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface QuestionRepository extends JpaRepository<Question, Long> {
|
public interface QuestionRepository extends JpaRepository<Question, Long> {
|
||||||
|
List<Question> findAllBySubjectIdAndActiveTrue(Long subjectId);
|
||||||
|
|
||||||
default Optional<Question> findOneWithEagerRelationships(Long id) {
|
default Optional<Question> findOneWithEagerRelationships(Long id) {
|
||||||
return this.findOneWithToOneRelationships(id);
|
return this.findOneWithToOneRelationships(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import com.example.questionbank.domain.enumeration.OptionKey;
|
||||||
|
|
||||||
|
public record AnswerResult(
|
||||||
|
Long questionId,
|
||||||
|
String questionText,
|
||||||
|
OptionKey selectedOption,
|
||||||
|
String selectedContent,
|
||||||
|
boolean correct,
|
||||||
|
int awardedPoints,
|
||||||
|
String explanation
|
||||||
|
) {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import com.example.questionbank.domain.enumeration.OptionKey;
|
||||||
|
|
||||||
|
public record ChoiceView(OptionKey optionKey, String content, Integer displayOrder) {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
public record ExamAttemptStartResult(Long attemptId, Instant startedAt) {}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import com.example.questionbank.domain.enumeration.AttemptStatus;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
public record ExamAttemptSummary(
|
||||||
|
Long attemptId,
|
||||||
|
Long subjectId,
|
||||||
|
String subjectName,
|
||||||
|
Instant startedAt,
|
||||||
|
Instant submittedAt,
|
||||||
|
AttemptStatus status,
|
||||||
|
Integer score
|
||||||
|
) {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public record ExamQuestionView(Long questionId, String prompt, List<ChoiceView> choices) {}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public record ExamResult(Long attemptId, int totalScore, Instant submittedAt, List<AnswerResult> answers) {}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
public record StartExamRequest(@NotNull Long subjectId) {}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import com.example.questionbank.domain.enumeration.OptionKey;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
public record SubmitAnswerRequest(@NotNull Long questionId, OptionKey selectedOption) {}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.example.questionbank.web.rest.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public record SubmitExamRequest(@NotEmpty List<@Valid SubmitAnswerRequest> answers) {}
|
||||||
Reference in new issue
Block a user