This repository has been archived by the owner on Apr 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from WisdomWorks/dev-herry-ho
Dev herry ho
- Loading branch information
Showing
7 changed files
with
142 additions
and
11 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/java/com/example/codeE/controller/Common/PingController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.codeE.controller.Common; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Map; | ||
|
||
@RestController | ||
@RequestMapping("/ping") | ||
public class PingController { | ||
@GetMapping | ||
@RequestMapping(value = "", method = RequestMethod.GET) | ||
public ResponseEntity<?> pingAPI(){ | ||
return ResponseEntity.status(HttpStatus.OK).body(Map.of("message", "Ping to api successful")); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/example/codeE/controller/ReportController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.codeE.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.HttpStatusCode; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/reports") | ||
@Validated | ||
public class ReportController { | ||
@GetMapping | ||
@RequestMapping(value = "", method = RequestMethod.GET) | ||
public ResponseEntity<?> getOverviewScoreExerciseReport(@PathVariable String exerciseId){ | ||
return ResponseEntity.status(HttpStatus.OK).body(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/example/codeE/request/report/OverviewScoreReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.codeE.request.report; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Setter | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class OverviewScoreReport { | ||
private int AScore; | ||
private int BScore; | ||
private int CScore; | ||
private int numberSubmission; | ||
private int numberStudent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/com/example/codeE/service/report/ReportImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.example.codeE.service.report; | ||
|
||
import com.example.codeE.model.exercise.Exercise; | ||
import com.example.codeE.repository.*; | ||
import com.example.codeE.request.exercise.essay.EssaySubmissionsResponse; | ||
import com.example.codeE.request.report.OverviewScoreReport; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
public class ReportImpl implements ReportService{ | ||
@Autowired | ||
private ExerciseRepository exerciseRepository; | ||
@Autowired | ||
private TopicRepository topicRepository; | ||
@Autowired | ||
private CourseStudentRepository courseStudentRepository; | ||
@Autowired | ||
private QuizSubmissionRepository quizSubmissionRepository; | ||
@Autowired | ||
private EssaySubmissionRepository essaySubmissionRepository; | ||
@Autowired | ||
private CodeSubmissionRepository codeSubmissionRepository; | ||
@Autowired | ||
|
||
|
||
@Override | ||
public OverviewScoreReport getOverviewScoreReportByExerciseId(String exerciseId) { | ||
OverviewScoreReport result = new OverviewScoreReport(); | ||
var exercise = this.exerciseRepository.findById(exerciseId).orElseThrow(() -> new NoSuchElementException("No exercise found by id: " +exerciseId)); | ||
if(exercise.isShowAll()){ | ||
String courseId = this.topicRepository.findById(exercise.getTopicId()).orElseThrow(() -> new NoSuchElementException("No topic found by id: " +exercise.getTopicId())).getCourseId(); | ||
var courseStudents = this.courseStudentRepository.getAllStudentsInCourse(courseId); | ||
result.setNumberStudent(courseStudents.size()); | ||
|
||
}else { | ||
|
||
} | ||
return result; | ||
} | ||
private OverviewScoreReport getAllSubmission(Exercise exercise){ | ||
OverviewScoreReport result = new OverviewScoreReport(); | ||
switch (exercise.getType()){ | ||
case "code" ->{} | ||
case "file" ->{} | ||
case "quiz" ->{} | ||
case "essay" -> { | ||
var essays = this.essaySubmissionRepository.findAll(); | ||
|
||
} | ||
} | ||
return result; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/example/codeE/service/report/ReportService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.codeE.service.report; | ||
|
||
import com.example.codeE.request.report.OverviewScoreReport; | ||
|
||
public interface ReportService { | ||
OverviewScoreReport getOverviewScoreReportByExerciseId(String exerciseId); | ||
} |