Merge branch 'backend' of https://github.com/TeamBNBN/edufocus into be/Registration
This commit is contained in:
commit
4ebed1ca3a
@ -1,7 +1,8 @@
|
||||
package com.edufocus.edufocus.report.controller;
|
||||
|
||||
import com.edufocus.edufocus.report.entity.Report;
|
||||
import com.edufocus.edufocus.report.entity.ReportRequset;
|
||||
import com.edufocus.edufocus.report.entity.dto.ReportResponse;
|
||||
import com.edufocus.edufocus.report.entity.vo.Report;
|
||||
import com.edufocus.edufocus.report.entity.dto.ReportRequset;
|
||||
import com.edufocus.edufocus.report.service.ReportService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -27,8 +28,8 @@ public class ReportController{
|
||||
|
||||
|
||||
@PostMapping("/submit")
|
||||
public ResponseEntity<Report> submit(@RequestBody ReportRequset reportRequset) throws SQLException {
|
||||
Report report = reportService.grading(reportRequset);
|
||||
public ResponseEntity<ReportResponse> submit(@RequestBody ReportRequset reportRequset) throws SQLException {
|
||||
ReportResponse report = reportService.grading(reportRequset);
|
||||
return new ResponseEntity<>(report,HttpStatus.CREATED);
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.edufocus.edufocus.report.entity;
|
||||
package com.edufocus.edufocus.report.entity.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.edufocus.edufocus.report.entity;
|
||||
package com.edufocus.edufocus.report.entity.dto;
|
||||
|
||||
public class QuizSubmissionDto {
|
||||
private Long quizSetId;
|
@ -1,4 +1,4 @@
|
||||
package com.edufocus.edufocus.report.entity;
|
||||
package com.edufocus.edufocus.report.entity.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
@ -0,0 +1,26 @@
|
||||
package com.edufocus.edufocus.report.entity.dto;
|
||||
|
||||
import com.edufocus.edufocus.report.entity.vo.Answer;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class ReportResponse {
|
||||
|
||||
private Long quizesetId;
|
||||
private Long userId;
|
||||
|
||||
private String title;
|
||||
private int allCount;
|
||||
private int correctCount;
|
||||
private Date testAt;
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.edufocus.edufocus.report.entity;
|
||||
package com.edufocus.edufocus.report.entity.vo;
|
||||
|
||||
|
||||
import com.edufocus.edufocus.quiz.entity.Quiz;
|
@ -1,4 +1,4 @@
|
||||
package com.edufocus.edufocus.report.entity;
|
||||
package com.edufocus.edufocus.report.entity.vo;
|
||||
|
||||
import com.edufocus.edufocus.quiz.entity.QuizSet;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
@ -1,6 +1,6 @@
|
||||
package com.edufocus.edufocus.report.repository;
|
||||
|
||||
import com.edufocus.edufocus.report.entity.Answer;
|
||||
import com.edufocus.edufocus.report.entity.vo.Answer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface AnswerRepository extends JpaRepository<Answer,Long> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.edufocus.edufocus.report.repository;
|
||||
|
||||
import com.edufocus.edufocus.report.entity.Report;
|
||||
import com.edufocus.edufocus.report.entity.vo.Report;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.edufocus.edufocus.report.service;
|
||||
|
||||
import com.edufocus.edufocus.report.entity.Answer;
|
||||
import com.edufocus.edufocus.report.entity.vo.Answer;
|
||||
|
||||
public interface AnswerService {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.edufocus.edufocus.report.service;
|
||||
|
||||
import com.edufocus.edufocus.report.entity.Answer;
|
||||
import com.edufocus.edufocus.report.entity.vo.Answer;
|
||||
import com.edufocus.edufocus.report.repository.AnswerRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.edufocus.edufocus.report.service;
|
||||
|
||||
import com.edufocus.edufocus.report.entity.Report;
|
||||
import com.edufocus.edufocus.report.entity.ReportRequset;
|
||||
import com.edufocus.edufocus.report.entity.dto.ReportResponse;
|
||||
import com.edufocus.edufocus.report.entity.vo.Report;
|
||||
import com.edufocus.edufocus.report.entity.dto.ReportRequset;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Service
|
||||
public interface ReportService {
|
||||
Report grading(ReportRequset reportRequset) throws SQLException;
|
||||
ReportResponse grading(ReportRequset reportRequset) throws SQLException;
|
||||
|
||||
}
|
||||
|
@ -5,10 +5,11 @@ import com.edufocus.edufocus.quiz.entity.QuizSet;
|
||||
import com.edufocus.edufocus.quiz.repository.QuizRepository;
|
||||
import com.edufocus.edufocus.quiz.service.QuizService;
|
||||
import com.edufocus.edufocus.quiz.service.QuizSetService;
|
||||
import com.edufocus.edufocus.report.entity.Answer;
|
||||
import com.edufocus.edufocus.report.entity.AnswerInput;
|
||||
import com.edufocus.edufocus.report.entity.Report;
|
||||
import com.edufocus.edufocus.report.entity.ReportRequset;
|
||||
import com.edufocus.edufocus.report.entity.dto.ReportResponse;
|
||||
import com.edufocus.edufocus.report.entity.vo.Answer;
|
||||
import com.edufocus.edufocus.report.entity.dto.AnswerInput;
|
||||
import com.edufocus.edufocus.report.entity.vo.Report;
|
||||
import com.edufocus.edufocus.report.entity.dto.ReportRequset;
|
||||
import com.edufocus.edufocus.report.repository.ReportRepository;
|
||||
import com.edufocus.edufocus.user.model.entity.User;
|
||||
import com.edufocus.edufocus.user.model.repository.UserRepository;
|
||||
@ -36,7 +37,7 @@ public class ReportServiceImpl implements ReportService {
|
||||
|
||||
|
||||
@Override
|
||||
public Report grading(ReportRequset reportRequset) throws SQLException {
|
||||
public ReportResponse grading(ReportRequset reportRequset) throws SQLException {
|
||||
|
||||
|
||||
QuizSet quizSet = quizSetService.findQuizSet(reportRequset.getQuizsetId());
|
||||
@ -90,10 +91,15 @@ public class ReportServiceImpl implements ReportService {
|
||||
.allCount(allCount)
|
||||
.correctCount(correctCount)
|
||||
.testAt(new Date()).build();
|
||||
ReportResponse reportResponse = ReportResponse.builder()
|
||||
.quizesetId(quizSet.getId())
|
||||
.userId(testuser.getId())
|
||||
.title(quizSet.getTitle())
|
||||
.allCount(allCount)
|
||||
.correctCount(correctCount)
|
||||
.testAt(new Date())
|
||||
.build();
|
||||
|
||||
reportRepository.save(report);
|
||||
return report;
|
||||
|
||||
|
||||
return reportResponse;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user