82 lines
2.5 KiB
Java
Executable File
82 lines
2.5 KiB
Java
Executable File
package com.mmkilic.education.controller;
|
|
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import com.mmkilic.education.dto.AnswerRequset;
|
|
import com.mmkilic.education.dto.AnswerResponse;
|
|
import com.mmkilic.education.dto.HintResponse;
|
|
import com.mmkilic.education.dto.NewQuizRequset;
|
|
import com.mmkilic.education.dto.OptionsResponse;
|
|
import com.mmkilic.education.dto.Scoreboard;
|
|
import com.mmkilic.education.entity.QAPair;
|
|
import com.mmkilic.education.entity.Quiz;
|
|
import com.mmkilic.education.service.QuizService;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
@RestController
|
|
@RequiredArgsConstructor
|
|
@RequestMapping("/quizzes")
|
|
public class QuizController {
|
|
private final QuizService service;
|
|
|
|
@GetMapping("/{id}")
|
|
public Quiz getById(@PathVariable UUID id){
|
|
return service.getById(id);
|
|
}
|
|
|
|
@GetMapping
|
|
public List<Quiz> getAll(){
|
|
return service.getAll();
|
|
}
|
|
|
|
@GetMapping("/search")
|
|
public List<Quiz> search(@RequestParam String search, @RequestParam(required = false) String name){
|
|
return service.search(search, name);
|
|
}
|
|
|
|
@GetMapping("/user-name")
|
|
public List<Quiz> getByUserName(@RequestParam String name){
|
|
return service.getByUserName(name);
|
|
}
|
|
|
|
@GetMapping("/hint")
|
|
public HintResponse getHint(@RequestParam UUID qaPairId) {
|
|
return service.getHint(qaPairId);
|
|
}
|
|
|
|
@GetMapping("/options")
|
|
public OptionsResponse getOptions(@RequestParam UUID qaPairId) {
|
|
return service.getOptions(qaPairId);
|
|
}
|
|
|
|
@PostMapping("/start-new")
|
|
public Quiz start(@RequestBody NewQuizRequset quizReq) {
|
|
return service.startNew(quizReq);
|
|
}
|
|
|
|
@PostMapping("/next-qa")
|
|
public QAPair getNextQA(@RequestParam UUID id) {
|
|
return service.getNextQA(id);
|
|
}
|
|
|
|
@PostMapping("/answer")
|
|
public AnswerResponse answer(@RequestBody AnswerRequset req) {
|
|
return service.answer(req);
|
|
}
|
|
|
|
@PostMapping("/score")
|
|
public Scoreboard score(@RequestBody AnswerRequset req) {
|
|
return service.score(req);
|
|
}
|
|
|
|
} |