feat: qna
This commit is contained in:
commit
3442e9b91e
@ -34,15 +34,17 @@ public class Board {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(columnDefinition = "TEXT", nullable = false)
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@Column(nullable = true)
|
@Column(nullable = true)
|
||||||
private int viewCount;
|
private int viewCount;
|
||||||
|
|
||||||
|
@Column(columnDefinition = "TIMESTAMP")
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
LocalDateTime createdAt;
|
LocalDateTime createdAt;
|
||||||
|
|
||||||
|
@Column(columnDefinition = "TIMESTAMP")
|
||||||
@LastModifiedDate
|
@LastModifiedDate
|
||||||
LocalDateTime modifiedAt;
|
LocalDateTime modifiedAt;
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
|
import org.springframework.data.annotation.LastModifiedDate;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@ -22,13 +24,16 @@ public class Comment {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private long id;
|
private long id;
|
||||||
@Column
|
|
||||||
|
@Column(columnDefinition = "TEXT", nullable = false)
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@Column
|
@Column(columnDefinition = "TIMESTAMP")
|
||||||
|
@CreatedDate
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
@Column
|
@Column(columnDefinition = "TIMESTAMP")
|
||||||
|
@LastModifiedDate
|
||||||
private LocalDateTime modifiedAt;
|
private LocalDateTime modifiedAt;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
@ -27,10 +27,10 @@ public class Lecture {
|
|||||||
@Column
|
@Column
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@Lob
|
@Column(columnDefinition = "text")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Lob
|
@Column(columnDefinition = "text")
|
||||||
private String plan;
|
private String plan;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
|
@ -36,7 +36,7 @@ public class RegistrationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{registrationId}")
|
@PutMapping("/{registrationId}")
|
||||||
public ResponseEntity<?> acceptRigistration(@RequestHeader("Authorization") String accessToken, @PathVariable long registrationId) {
|
public ResponseEntity<?> acceptRegistration(@RequestHeader("Authorization") String accessToken, @PathVariable long registrationId) {
|
||||||
Long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
|
Long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
|
||||||
|
|
||||||
if (!registrationService.acceptRegistration(userId, registrationId)) {
|
if (!registrationService.acceptRegistration(userId, registrationId)) {
|
||||||
@ -47,7 +47,7 @@ public class RegistrationController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{registrationId}")
|
@DeleteMapping("/{registrationId}")
|
||||||
public ResponseEntity<?> deleteRigistration(@RequestHeader("Authorization") String accessToken, @PathVariable long registrationId) {
|
public ResponseEntity<?> deleteRegistration(@RequestHeader("Authorization") String accessToken, @PathVariable long registrationId) {
|
||||||
Long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
|
Long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
|
||||||
|
|
||||||
if (!registrationService.deleteRegistration(userId, registrationId)) {
|
if (!registrationService.deleteRegistration(userId, registrationId)) {
|
||||||
|
@ -63,7 +63,10 @@ public class ReportController {
|
|||||||
return new ResponseEntity<>(detailReport, HttpStatus.OK);
|
return new ResponseEntity<>(detailReport, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> 935331e7e93d9c25ec6f32ba6155ed19b5fd60f9
|
||||||
@GetMapping("/teacher/reportSet/{lectureId}")
|
@GetMapping("/teacher/reportSet/{lectureId}")
|
||||||
public ResponseEntity<List<ReportSetResponse>> searchReportSets(@PathVariable("lectureId") long lectureId) {
|
public ResponseEntity<List<ReportSetResponse>> searchReportSets(@PathVariable("lectureId") long lectureId) {
|
||||||
List<ReportSetResponse> reportSetResponses = reportService.findReportSets(lectureId);
|
List<ReportSetResponse> reportSetResponses = reportService.findReportSets(lectureId);
|
||||||
@ -84,4 +87,13 @@ public class ReportController {
|
|||||||
return new ResponseEntity<>(reportResponses, HttpStatus.OK);
|
return new ResponseEntity<>(reportResponses, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/teacher/report/{reportSetId}")
|
||||||
|
public ResponseEntity<?> deleteReportSet(@PathVariable("reportSetId") UUID reportSetId, HttpServletRequest request){
|
||||||
|
String token = request.getHeader("Authorization");
|
||||||
|
long userId = Long.parseLong(jwtUtil.getUserId(token));
|
||||||
|
|
||||||
|
reportService.deleteReportSet(reportSetId, userId);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@ public class QuizDto {
|
|||||||
private String image;
|
private String image;
|
||||||
private String answer;
|
private String answer;
|
||||||
private String userAnswer;
|
private String userAnswer;
|
||||||
private boolean isCollect;
|
private boolean isCorrect;
|
||||||
private List<ChoiceDto> choices;
|
private List<ChoiceDto> choices;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package com.edufocus.edufocus.report.entity.dto;
|
package com.edufocus.edufocus.report.entity.dto;
|
||||||
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.*;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ReportSetResponse {
|
public class ReportSetResponse {
|
||||||
|
@ -3,9 +3,11 @@ package com.edufocus.edufocus.report.entity.vo;
|
|||||||
import com.edufocus.edufocus.quiz.entity.QuizSet;
|
import com.edufocus.edufocus.quiz.entity.QuizSet;
|
||||||
import com.edufocus.edufocus.report.entity.dto.ReportResponse;
|
import com.edufocus.edufocus.report.entity.dto.ReportResponse;
|
||||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -17,6 +19,8 @@ import java.util.List;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
|
||||||
public class Report {
|
public class Report {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@ -26,6 +30,7 @@ public class Report {
|
|||||||
|
|
||||||
private int correctCount;
|
private int correctCount;
|
||||||
|
|
||||||
|
@Column(columnDefinition = "TIMESTAMP")
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
private LocalDateTime testAt;
|
private LocalDateTime testAt;
|
||||||
|
|
||||||
|
@ -3,11 +3,13 @@ package com.edufocus.edufocus.report.entity.vo;
|
|||||||
import com.edufocus.edufocus.lecture.entity.Lecture;
|
import com.edufocus.edufocus.lecture.entity.Lecture;
|
||||||
import com.edufocus.edufocus.quiz.entity.QuizSet;
|
import com.edufocus.edufocus.quiz.entity.QuizSet;
|
||||||
import com.edufocus.edufocus.report.entity.dto.ReportSetResponse;
|
import com.edufocus.edufocus.report.entity.dto.ReportSetResponse;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.hibernate.annotations.ColumnDefault;
|
import org.hibernate.annotations.ColumnDefault;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -21,6 +23,8 @@ import java.util.UUID;
|
|||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
|
||||||
public class ReportSet {
|
public class ReportSet {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(generator = "UUID")
|
@GeneratedValue(generator = "UUID")
|
||||||
@ -30,6 +34,7 @@ public class ReportSet {
|
|||||||
)
|
)
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
|
@Column(columnDefinition = "TIMESTAMP")
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
private LocalDateTime createAt;
|
private LocalDateTime createAt;
|
||||||
|
|
||||||
@ -51,4 +56,8 @@ public class ReportSet {
|
|||||||
.testAt(createAt)
|
.testAt(createAt)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long findUserId(){
|
||||||
|
return lecture.getUser().getId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,6 @@ public interface ReportService {
|
|||||||
List<ReportResponse> findReports(long lectureId, long userid);
|
List<ReportResponse> findReports(long lectureId, long userid);
|
||||||
|
|
||||||
UUID initReportSet(long lectureId, long quizSetId);
|
UUID initReportSet(long lectureId, long quizSetId);
|
||||||
|
|
||||||
|
void deleteReportSet(UUID reportSetId, long userId);
|
||||||
}
|
}
|
||||||
|
@ -54,17 +54,17 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
for (int idx = 0; idx < answerInputList.size(); idx++) {
|
for (int idx = 0; idx < answerInputList.size(); idx++) {
|
||||||
Quiz quiz = quizList.get(idx);
|
Quiz quiz = quizList.get(idx);
|
||||||
String inputAnswer = answerInputList.get(idx);
|
String inputAnswer = answerInputList.get(idx);
|
||||||
boolean isCollect;
|
boolean isCorrect;
|
||||||
Answer answer;
|
Answer answer;
|
||||||
if (quiz.getAnswer().equals(inputAnswer)) {
|
if (quiz.getAnswer().equals(inputAnswer)) {
|
||||||
correctCount++;
|
correctCount++;
|
||||||
isCollect = true;
|
isCorrect = true;
|
||||||
} else {
|
} else {
|
||||||
isCollect = false;
|
isCorrect = false;
|
||||||
}
|
}
|
||||||
answer = Answer.builder()
|
answer = Answer.builder()
|
||||||
.userAnswer(inputAnswer)
|
.userAnswer(inputAnswer)
|
||||||
.isCorrect(isCollect)
|
.isCorrect(isCorrect)
|
||||||
.report(report)
|
.report(report)
|
||||||
.quiz(quiz)
|
.quiz(quiz)
|
||||||
.build();
|
.build();
|
||||||
@ -106,7 +106,7 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
.question(quiz.getQuestion())
|
.question(quiz.getQuestion())
|
||||||
.answer(quiz.getAnswer())
|
.answer(quiz.getAnswer())
|
||||||
.userAnswer(answer.getUserAnswer())
|
.userAnswer(answer.getUserAnswer())
|
||||||
.isCollect(answer.isCorrect())
|
.isCorrect(answer.isCorrect())
|
||||||
.choices(choiceDtos)
|
.choices(choiceDtos)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@ -172,4 +172,11 @@ public class ReportServiceImpl implements ReportService {
|
|||||||
return reportSet.getId();
|
return reportSet.getId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteReportSet(UUID reportSetId, long userId) {
|
||||||
|
ReportSet reportSet = reportSetRepository.findById(reportSetId).orElseThrow(NoSuchElementException::new);
|
||||||
|
if(reportSet.findUserId() == userId)
|
||||||
|
reportSetRepository.delete(reportSet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user