Skip to content
Snippets Groups Projects
Commit b9a9a30c authored by Heine Mærde Brakstad's avatar Heine Mærde Brakstad
Browse files

Merge branch 'backend_frontend_sync' into 'main'

made changes in classes and methods to make frontend and backend work together

See merge request !27
parents 28ed14e6 b2a277fa
No related branches found
No related tags found
1 merge request!27made changes in classes and methods to make frontend and backend work together
Pipeline #269224 passed
Showing
with 216 additions and 219 deletions
......@@ -9,7 +9,7 @@ public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:4173")
.allowedOrigins("http://localhost:5173")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*");
}
......
package edu.ntnu.idatt2105.configuration;
import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.RSAKey;
......@@ -27,6 +26,7 @@ import org.springframework.security.oauth2.server.resource.authentication.JwtAut
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
public class SecurityConfiguration {
......@@ -36,11 +36,6 @@ public class SecurityConfiguration {
this.keys = keys;
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public AuthenticationManager authenticationManager(UserDetailsService userDetailsService, PasswordEncoder encoder) {
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
......@@ -48,6 +43,10 @@ public class SecurityConfiguration {
daoAuthenticationProvider.setPasswordEncoder(encoder);
return new ProviderManager(daoAuthenticationProvider);
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
......@@ -91,3 +90,6 @@ public class SecurityConfiguration {
return jwtAuthenticationConverter;
}
}
package edu.ntnu.idatt2105.controller;
import edu.ntnu.idatt2105.dto.QuestionAnswerDTO;
import edu.ntnu.idatt2105.exception.QuestionNotFoundException;
import edu.ntnu.idatt2105.model.Question;
import edu.ntnu.idatt2105.model.QuestionAnswer;
import edu.ntnu.idatt2105.service.QuestionAnswerService;
import edu.ntnu.idatt2105.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Optional;
@RestController
@RequestMapping("/question-answers")
public class QuestionAnswerController {
private final QuestionAnswerService questionAnswerService;
private QuestionService questionService;
@Autowired
public QuestionAnswerController(QuestionAnswerService questionAnswerService) {
public QuestionAnswerController(QuestionAnswerService questionAnswerService, QuestionService questionService) {
this.questionAnswerService = questionAnswerService;
this.questionService = questionService;
}
@PostMapping("/save")
......@@ -26,6 +33,12 @@ public class QuestionAnswerController {
return convertToQuestionAnswerDTO(savedAnswer);
}
@GetMapping("/is-correct")
public ResponseEntity<Boolean> isCorrect(@RequestBody QuestionAnswerDTO answerDTO) {
boolean correct = questionAnswerService.isCorrect(convertToQuestionAnswer(answerDTO));
return new ResponseEntity<>(correct, HttpStatus.OK);
}
private QuestionAnswerDTO convertToQuestionAnswerDTO(QuestionAnswer questionAnswer) {
QuestionAnswerDTO dto = new QuestionAnswerDTO();
dto.setId(questionAnswer.getId());
......@@ -34,4 +47,16 @@ public class QuestionAnswerController {
dto.setCorrect(questionAnswer.isCorrect());
return dto;
}
private QuestionAnswer convertToQuestionAnswer(QuestionAnswerDTO questionAnswerDTO) {
Optional<Question> questionOptional = Optional.ofNullable(questionService.findQuestionById(questionAnswerDTO.getQuestionId()));
Question question = questionOptional.orElseThrow(() ->
new QuestionNotFoundException("Question not found with ID: " + questionAnswerDTO.getQuestionId()));
QuestionAnswer questionAnswer = new QuestionAnswer();
questionAnswer.setId(questionAnswerDTO.getId());
questionAnswer.setQuestion(question);
questionAnswer.setGivenAnswer(questionAnswerDTO.getGivenAnswer());
return questionAnswer;
}
}
package edu.ntnu.idatt2105.controller;
import edu.ntnu.idatt2105.dto.QuestionDTO;
import edu.ntnu.idatt2105.model.MultipleChoiceQuestion;
import edu.ntnu.idatt2105.model.Question;
import edu.ntnu.idatt2105.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -22,36 +22,38 @@ public class QuestionController {
this.questionService = questionService;
}
@PostMapping
public QuestionDTO createMCQuestion(@RequestBody QuestionDTO questionDTO) {
MultipleChoiceQuestion question = questionService.createMCQuestion(questionDTO);
return convertToDTO(question);
@PostMapping("/save")
public QuestionDTO saveQuestion(@RequestBody QuestionDTO questionDTO) {
Question question = questionService.createOrUpdateQuestion(questionDTO);
//TODO: make a mapper class to do this
return new QuestionDTO(
question.getId(),
question.getQuestionText(),
question.getType(),
question.getAnswer(),
question.getOptionsList(),
question.getScore(),
question.getQuiz().getId()
);
}
@PostMapping("/update")
public QuestionDTO updateQuestion(@RequestBody QuestionDTO questionDTO) {
return questionService.updateQuestion(questionDTO);
@GetMapping("/get/{questionId}")
public QuestionDTO getQuestion(@PathVariable Integer questionId) {
Question question = questionService.findQuestionById(questionId);
return new QuestionDTO(
question.getId(),
question.getQuestionText(),
question.getType(),
question.getAnswer(),
question.getOptionsList(),
question.getScore(),
question.getQuiz().getId()
);
}
@PostMapping("/delete")
public void deleteQuestion(@RequestBody Map<String, Integer> payload) {
questionService.deleteQuestion(payload.get("id"));
}
@GetMapping("/list")
public List<QuestionDTO> getQuestionsByQuizId(@RequestParam Integer quizId) {
return questionService.findAllQuestionsByQuizId(quizId).stream()
.map((Question question) -> convertToDTO((MultipleChoiceQuestion) question))
.collect(Collectors.toList());
}
public QuestionDTO convertToDTO(MultipleChoiceQuestion question) {
QuestionDTO questionDTO = new QuestionDTO();
questionDTO.setId(question.getId());
questionDTO.setQuestionText(question.getQuestionText());
questionDTO.setScore(question.getScore());
questionDTO.setAnswerOptions(question.getAnswerOptions());
questionDTO.setCorrectAnswerIndex(question.getCorrectAnswerIndex());
return questionDTO;
@PostMapping("/delete/{questionId}")
public void deleteQuestion(@PathVariable Integer questionId) {
questionService.deleteQuestion(questionId);
}
}
......@@ -30,12 +30,14 @@ public class QuizController {
@PostMapping("/create")
public QuizDTO createQuiz(@RequestBody QuizDTO quizDTO) {
Quiz quiz = quizService.createQuiz(quizDTO);
return convertToDTO(quiz);
return quizService.createQuiz(quizDTO);
}
@PostMapping("/update")
public QuizDTO updateQuiz(@RequestBody QuizDTO quizDTO) {
if (quizDTO.getId() == null) {
throw new IllegalArgumentException("Quiz ID must be provided for update.");
}
return quizService.updateQuiz(quizDTO);
}
......@@ -44,8 +46,8 @@ public class QuizController {
quizService.deleteQuiz(payload.get("id"));
}
@GetMapping("/quiz")
public QuizDTO getQuizById(@RequestParam Integer quizId) {
@GetMapping("/quiz/{quizId}")
public QuizDTO getQuizById(@PathVariable Integer quizId) {
return convertToDTO(quizService.findQuizById(quizId));
}
......@@ -71,8 +73,8 @@ public class QuizController {
.collect(Collectors.toList());
}
@GetMapping("/creator")
public List<QuizDTO> getQuizzesByCreatorId(@RequestParam Integer creatorId) {
@GetMapping("/creator/{creatorId}")
public List<QuizDTO> getQuizzesByCreatorId(@PathVariable Integer creatorId) {
return quizService.findAllQuizzesByCreatorId(creatorId).stream()
.map(this::convertToDTO)
.collect(Collectors.toList());
......@@ -83,10 +85,6 @@ public class QuizController {
quizDTO.setId(quiz.getId());
quizDTO.setTitle(quiz.getTitle());
quizDTO.setCategory(quiz.getCategory());
List<Integer> questionIds = quiz.getQuestions().stream()
.map(Question::getId)
.collect(Collectors.toList());
quizDTO.setQuestionIds(questionIds);
return quizDTO;
}
......
......@@ -50,7 +50,7 @@ public class QuizResultController {
QuizResultDTO quizResultDTO = new QuizResultDTO();
quizResultDTO.setQuizId(quizResult.getQuiz().getId());
quizResultDTO.setUserId(quizResult.getUser().getId());
quizResultDTO.setScore(quizResult.getScore());
quizResultDTO.setTotalScore(quizResult.getScore());
quizResultDTO.setStatus(quizResult.getStatus());
quizResultDTO.setStartedAt(quizResult.getStartedAt());
quizResultDTO.setCompletedAt(quizResult.getCompletedAt());
......
package edu.ntnu.idatt2105.controller;
import edu.ntnu.idatt2105.dto.UserDTO;
import edu.ntnu.idatt2105.model.User;
import edu.ntnu.idatt2105.service.TokenService;
import edu.ntnu.idatt2105.service.UserService;
import org.springframework.web.bind.annotation.*;
......@@ -13,8 +15,10 @@ import java.util.List;
public class UserController {
private final UserService userService;
private final TokenService tokenService;
public UserController(UserService userService) {
public UserController(UserService userService, TokenService tokenService) {
this.tokenService = tokenService;
this.userService = userService;
}
......@@ -23,4 +27,9 @@ public class UserController {
public List<User> getAppUsers() {
return userService.findAllAppUsers();
}
@GetMapping("/getId/{token}")
public UserDTO getUserDTOFromToken(@PathVariable String token) {
return tokenService.getUserDTOFromToken(token);
}
}
package edu.ntnu.idatt2105.dto;
import edu.ntnu.idatt2105.model.QuestionType;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class QuestionDTO {
private Integer id;
private Integer quizId;
private String questionText;
private QuestionType type;
private String answer;
private List<String> options;
private int score;
private List<String> answerOptions;
private int correctAnswerIndex;
public QuestionDTO() {
}
public QuestionDTO(Integer id, String questionText, int score) {
public QuestionDTO(Integer id, String questionText, QuestionType type, String answer, List<String> options, int score, Integer quizId) {
this.id = id;
this.questionText = questionText;
this.type = type;
this.answer = answer;
this.options = options;
this.score = score;
this.quizId = quizId;
}
// Getters and setters
// Getters og setters
public Integer getId() {
return id;
}
......@@ -36,6 +46,30 @@ public class QuestionDTO {
this.questionText = questionText;
}
public QuestionType getType() {
return type;
}
public void setType(QuestionType type) {
this.type = type;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public List<String> getOptions() {
return options;
}
public void setOptions(List<String> options) {
this.options = options;
}
public int getScore() {
return score;
}
......@@ -44,21 +78,22 @@ public class QuestionDTO {
this.score = score;
}
public List<String> getAnswerOptions() {
return answerOptions;
public Integer getQuizId() {
return quizId;
}
public void setAnswerOptions(List<String> answerOptions) {
this.answerOptions = answerOptions;
public void setQuizId(Integer quizId) {
this.quizId = quizId;
}
public int getCorrectAnswerIndex() {
return correctAnswerIndex;
public void setOptionsFromString(String optionsString) {
if (optionsString != null && !optionsString.isEmpty()) {
this.options = Arrays.stream(optionsString.split("\\*"))
.collect(Collectors.toList());
}
public void setCorrectAnswerIndex(int correctAnswerIndex) {
this.correctAnswerIndex = correctAnswerIndex;
}
public String getOptionsAsString() {
return String.join("*", this.options);
}
}
......@@ -9,7 +9,6 @@ import java.util.List;
public class QuizDTO {
private Integer id;
private String title;
private List<Integer> questionIds;
private Integer creatorId;
private QuizCategory category;
private QuizDifficulty difficulty;
......@@ -17,9 +16,8 @@ public class QuizDTO {
public QuizDTO() {
}
public QuizDTO(Integer id, String title, List<Integer> questionIds, Integer creatorId, QuizCategory category, QuizDifficulty difficulty) {
public QuizDTO(String title, Integer creatorId, QuizCategory category, QuizDifficulty difficulty) {
this.title = title;
this.questionIds = questionIds;
this.creatorId = creatorId;
this.category = category;
this.difficulty = difficulty;
......@@ -42,14 +40,6 @@ public class QuizDTO {
this.title = title;
}
public Iterable<Integer> getQuestionIds() {
return questionIds;
}
public void setQuestionIds(List<Integer> questionIds) {
this.questionIds = questionIds;
}
public Integer getCreatorId() {
return creatorId;
}
......
......@@ -8,7 +8,7 @@ public class QuizResultDTO {
private Integer quizId;
private Integer userId;
private List<QuestionAnswerDTO> answers;
private int score;
private int totalScore;
private String status;
private LocalDateTime startedAt;
private LocalDateTime completedAt;
......@@ -17,12 +17,12 @@ public class QuizResultDTO {
public QuizResultDTO() {
}
public QuizResultDTO(Integer id, Integer quizId, Integer userId, List<QuestionAnswerDTO> answers, int score, String status, LocalDateTime startedAt, LocalDateTime completedAt) {
public QuizResultDTO(Integer id, Integer quizId, Integer userId, List<QuestionAnswerDTO> answers, int totalScore, String status, LocalDateTime startedAt, LocalDateTime completedAt) {
this.id = id;
this.quizId = quizId;
this.userId = userId;
this.answers = answers;
this.score = score;
this.totalScore = totalScore;
this.status = status;
this.startedAt = startedAt;
this.completedAt = completedAt;
......@@ -60,12 +60,12 @@ public class QuizResultDTO {
this.answers = answers;
}
public int getScore() {
return score;
public int getTotalScore() {
return totalScore;
}
public void setScore(int score) {
this.score = score;
public void setTotalScore(int totalScore) {
this.totalScore = totalScore;
}
public String getStatus() {
......@@ -99,7 +99,7 @@ public class QuizResultDTO {
", quizId=" + quizId +
", userId=" + userId +
", answers=" + answers +
", score=" + score +
", score=" + totalScore +
'}';
}
}
package edu.ntnu.idatt2105.model;
import jakarta.persistence.*;
import java.util.List;
@Entity
public class MultipleChoiceQuestion extends Question {
@ElementCollection
@CollectionTable(name = "answer_options", joinColumns = @JoinColumn(name = "question_id"))
@Column(name = "option")
private List<String> answerOptions;
@Column(nullable = false)
private int correctAnswerIndex;
public MultipleChoiceQuestion() {
}
public MultipleChoiceQuestion(Quiz quiz, String questionText, int score, List<String> answerOptions, int correctAnswerIndex) {
super(quiz, questionText, score);
this.answerOptions = answerOptions;
this.correctAnswerIndex = correctAnswerIndex;
}
public List<String> getAnswerOptions() {
return answerOptions;
}
public void setAnswerOptions(List<String> answerOptions) {
this.answerOptions = answerOptions;
}
public int getCorrectAnswerIndex() {
return correctAnswerIndex;
}
public void setCorrectAnswerIndex(int correctAnswerIndex) {
this.correctAnswerIndex = correctAnswerIndex;
}
@Override
public boolean checkAnswer(String answer) {
try {
int answerIndex = Integer.parseInt(answer);
return answerIndex == correctAnswerIndex + 1;
} catch (NumberFormatException e) {
return false;
}
}
}
\ No newline at end of file
package edu.ntnu.idatt2105.model;
import jakarta.annotation.Nullable;
import jakarta.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Question {
public class Question {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
......@@ -19,12 +23,27 @@ public abstract class Question {
@Column(nullable = false)
private int score;
@Column(nullable = false)
private QuestionType type;
@Column(nullable = false)
private String answer;
@Column()
@Nullable
private String options; //Used for MCQ and TrueOrFalse to store answer options, divided by *
public Question() {
}
public Question(Quiz quiz, String questionText, int score) {
public Question(String questionText, QuestionType type, int score, String answer, @Nullable String options) {
this.questionText = questionText;
this.type = type;
this.score = score;
this.answer = answer;
this.options = options;
}
public Integer getId() {
......@@ -51,12 +70,41 @@ public abstract class Question {
this.score = score;
}
public abstract boolean checkAnswer(String answer);
public Quiz getQuiz() {
return quiz;
}
public void setQuiz(Quiz quiz) {
this.quiz = quiz;
}
public QuestionType getType() {
return type;
}
public void setType(QuestionType type) {
this.type = type;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
@Nullable
public String getOptions() {
return options;
}
public void setOptions(@Nullable String options) {
this.options = options;
}
// Metode for å få en liste av alle alternativer
public List<String> getOptionsList() {
if (this.options != null && !this.options.isEmpty()) {
return List.of(this.options.split("\\*"));
}
return new ArrayList<>();
}
}
......@@ -15,9 +15,6 @@ public class QuestionAnswer {
@Column(nullable = false)
private String givenAnswer;
@Column(nullable = false)
private boolean correct;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "quiz_result_id")
private QuizResult quizResult;
......@@ -29,12 +26,6 @@ public class QuestionAnswer {
public QuestionAnswer(Question question, String givenAnswer) {
this.question = question;
this.givenAnswer = givenAnswer;
this.correct = validateAnswer(givenAnswer);
}
// Validation method
private boolean validateAnswer(String givenAnswer) {
return question.checkAnswer(givenAnswer);
}
public Integer getId() {
......@@ -51,8 +42,6 @@ public class QuestionAnswer {
public void setQuestion(Question question) {
this.question = question;
// Update 'correct' whenever the question changes
this.correct = validateAnswer(this.givenAnswer);
}
public String getGivenAnswer() {
......@@ -61,19 +50,12 @@ public class QuestionAnswer {
public void setGivenAnswer(String givenAnswer) {
this.givenAnswer = givenAnswer;
// Update 'correct' whenever the given answer changes
this.correct = validateAnswer(givenAnswer);
}
public boolean isCorrect() {
return correct;
return this.question.getAnswer().equalsIgnoreCase(this.givenAnswer);
}
public void setCorrect(boolean correct) {
this.correct = correct;
}
public QuizResult getQuizResult() {
return quizResult;
}
......
package edu.ntnu.idatt2105.model;
public enum QuestionType {
STRING, TRUE_OR_FALSE, MULTIPLE_CHOICE
}
......@@ -15,11 +15,6 @@ public class Quiz {
@Column(nullable = false)
private String title;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "quiz_id")
private List<Question> questions;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "creator_id")
private User creator;
......@@ -33,9 +28,8 @@ public class Quiz {
public Quiz() {
}
public Quiz(String title, List<Question> questions, User creator, QuizCategory category, QuizDifficulty difficulty) {
public Quiz(String title, User creator, QuizCategory category, QuizDifficulty difficulty) {
this.title = title;
this.questions = questions;
this.creator = creator;
this.category = category;
this.difficulty = difficulty;
......@@ -58,14 +52,6 @@ public class Quiz {
this.title = title;
}
public List<Question> getQuestions() {
return questions;
}
public void setQuestions(List<Question> questions) {
this.questions = questions;
}
public User getCreator() {
return creator;
}
......
package edu.ntnu.idatt2105.model;
import jakarta.annotation.Nullable;
import jakarta.persistence.*;
import java.time.LocalDateTime;
......@@ -18,9 +19,6 @@ public class QuizResult {
@JoinColumn(name = "quiz_id", nullable = false)
private Quiz quiz;
@OneToMany(mappedBy = "quizResult", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
private List<QuestionAnswer> answers = new ArrayList<>();
@Column(nullable = false)
private int score;
......@@ -28,7 +26,6 @@ public class QuizResult {
@JoinColumn(name = "user_id")
private User user;
@Column(nullable = false)
private String status;
......@@ -36,19 +33,16 @@ public class QuizResult {
private LocalDateTime startedAt;
@Column
@Nullable
private LocalDateTime completedAt;
public QuizResult() {
// JPA requires a no-arg constructor
}
// Constructor for initializing with a quiz and optionally with answers.
public QuizResult(Quiz quiz, List<QuestionAnswer> answers, User user, String status, LocalDateTime startedAt, LocalDateTime completedAt) {
public QuizResult(Quiz quiz, User user, String status, LocalDateTime startedAt, LocalDateTime completedAt) {
this.quiz = quiz;
this.setAnswers(answers);
this.user = user;
this.status = status;
this.startedAt = startedAt;
......@@ -80,17 +74,6 @@ public class QuizResult {
this.user = user;
}
public List<QuestionAnswer> getAnswers() {
return answers;
}
// When setting answers, also recalculate the score based on the correctness and question score.
public void setAnswers(List<QuestionAnswer> answers) {
this.answers = answers;
this.answers.forEach(answer -> answer.setQuizResult(this));
calculateScore(); // Recalculate the score based on the new set of answers
}
public int getScore() {
return score;
}
......@@ -115,24 +98,12 @@ public class QuizResult {
this.startedAt = startedAt;
}
@Nullable
public LocalDateTime getCompletedAt() {
return completedAt;
}
public void setCompletedAt(LocalDateTime completedAt) {
public void setCompletedAt(@Nullable LocalDateTime completedAt) {
this.completedAt = completedAt;
}
public void addQuestionAnswer(QuestionAnswer questionAnswer) {
this.answers.add(questionAnswer);
questionAnswer.setQuizResult(this);
calculateScore();
}
private void calculateScore() {
this.score = this.answers.stream()
.filter(QuestionAnswer::isCorrect)
.mapToInt(answer -> answer.getQuestion().getScore())
.sum();
}
}
......@@ -2,11 +2,11 @@ package edu.ntnu.idatt2105.model;
import jakarta.persistence.*;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.*;
@Entity
@Table(name = "users")
public class User implements UserDetails {
......@@ -38,7 +38,6 @@ public class User implements UserDetails {
public User() {
this.authorities = new HashSet<>();
}
public User(String username, String password, Set<Role> authorities) {
......@@ -47,13 +46,6 @@ public class User implements UserDetails {
this.authorities = authorities;
}
public User(Integer id, String username, String password, Set<Role> authorities) {
this.id = id;
this.username = username;
this.password = password;
this.authorities = authorities;
}
public Integer getId() {
return id;
}
......
......@@ -3,6 +3,7 @@ package edu.ntnu.idatt2105.repository;
import edu.ntnu.idatt2105.model.Quiz;
import edu.ntnu.idatt2105.model.QuizCategory;
import edu.ntnu.idatt2105.model.QuizDifficulty;
import edu.ntnu.idatt2105.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
......@@ -18,4 +19,6 @@ public interface QuizRepository extends JpaRepository<Quiz, Integer> {
List<Quiz> findAllByDifficulty(QuizDifficulty difficulty);
List<Quiz> findAllByCreatorId(Integer creatorId);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment