diff --git a/README.md b/README.md index 0928368..a6aa3f6 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Before you begin, make sure you have the following installed: - Apache Maven - Vertex AI Configuartion - Cloudinary API Key and Secret (for profile image management) -- You can also access from deployment server.http://65.2.175.178:8080/ +- You can also access from deployment server.http://43.205.68.79:8080/ @@ -209,7 +209,7 @@ Please check back soon for the completed Postman collection, which will provide ### Swagger API Documentation QuizApp provides Swagger for easy API documentation and testing. You can access the Swagger UI to interact with the APIs as follows: -http://65.2.175.178:8080/swagger-ui/index.html +http://43.205.68.79:8080/swagger-ui/index.html ```shell http://localhost:8080/swagger-ui.html diff --git a/src/main/java/com/example/quizapp/QuizApp/Services/SessionService.java b/src/main/java/com/example/quizapp/QuizApp/Services/SessionService.java index 60b2b34..25497ad 100644 --- a/src/main/java/com/example/quizapp/QuizApp/Services/SessionService.java +++ b/src/main/java/com/example/quizapp/QuizApp/Services/SessionService.java @@ -17,6 +17,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.temporal.Temporal; import java.util.*; import java.util.stream.Collectors; @@ -46,6 +50,7 @@ public class SessionService { @Autowired ModelMapper modelMapper; + public record sessionMessage(String message, Long timeLeft){} public SessionDTO createSession(SessionDTO sessionDTO) { List updatedQuestionList=new ArrayList<>(); @@ -119,7 +124,7 @@ private Date calculateExpirationTime(int expirationTime) { return new Date(calendar.getTime().getTime()); } - public SessionDTO getSessionDetails(Integer sessionId) { + public Object getSessionDetails(Integer sessionId) { log.info(sessionId.toString()); // log.info(sessionId); // if (sessionId.equals("all")) { @@ -129,13 +134,24 @@ public SessionDTO getSessionDetails(Integer sessionId) { //Collections.singletonList(sessionDAO.findById(Integer.parseInt(sessionId)).get()); if (!sessionDAO.existsById(sessionId)) { //throw exception - throw new CustomException("Unable to find sessionDetails check the sessionId carefully"); + throw new CustomException("Session id not exist check the carefully"); + } + + Session session=sessionDAO.findById(sessionId).get(); + + Date currTimeStamp=new Date(); + if(currTimeStamp.before(session.getStartTimeStamp())){ +// log.info("reach here"); + // Duration duration=Duration.between((Temporal) session.getStartTimeStamp(), (Temporal) currTimeStamp); + LocalDateTime dateTime1 = session.getStartTimeStamp().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + LocalDateTime dateTime2 = currTimeStamp.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + return new sessionMessage("Session has not started yet !!",Duration.between(dateTime2,dateTime1).toMinutes() ); } //rank changes handle here // return Collections.singletonList(modelMapper.map(sessionDAO.findById(Integer.parseInt(sessionId)).get(), SessionDTO.class)); - Session session=sessionDAO.findById(sessionId).get(); + List sessionUserListAttempted=new ArrayList<>(); List sessionUserListNonAttempted=new ArrayList<>(); for(SessionUser sessionUser:session.getSessionUserList()){ diff --git a/src/main/java/com/example/quizapp/QuizApp/controller/SessionController.java b/src/main/java/com/example/quizapp/QuizApp/controller/SessionController.java index 0676673..61e70bf 100644 --- a/src/main/java/com/example/quizapp/QuizApp/controller/SessionController.java +++ b/src/main/java/com/example/quizapp/QuizApp/controller/SessionController.java @@ -40,7 +40,7 @@ public ResponseEntity createSession(@RequestBody SessionDTO session){ } @GetMapping("/session/{sessionId}") - public ResponseEntity getSessionDetails(@PathVariable Integer sessionId) + public ResponseEntity getSessionDetails(@PathVariable Integer sessionId) { return new ResponseEntity<>(sessionService.getSessionDetails(sessionId),HttpStatus.OK); } diff --git a/src/main/java/com/example/quizapp/QuizApp/entity/Session.java b/src/main/java/com/example/quizapp/QuizApp/entity/Session.java index eca3574..8943bbe 100644 --- a/src/main/java/com/example/quizapp/QuizApp/entity/Session.java +++ b/src/main/java/com/example/quizapp/QuizApp/entity/Session.java @@ -18,10 +18,10 @@ public class Session { String dateAndTime ; - @JsonIgnore +// @JsonIgnore Date startTimeStamp; - @JsonIgnore +// @JsonIgnore Date expiryTimeStamp; Integer delayDuration; diff --git a/src/main/java/com/example/quizapp/QuizApp/model/QuestionDTO.java b/src/main/java/com/example/quizapp/QuizApp/model/QuestionDTO.java index 335531d..3300515 100644 --- a/src/main/java/com/example/quizapp/QuizApp/model/QuestionDTO.java +++ b/src/main/java/com/example/quizapp/QuizApp/model/QuestionDTO.java @@ -1,5 +1,6 @@ package com.example.quizapp.QuizApp.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.NoArgsConstructor; @@ -16,6 +17,7 @@ public class QuestionDTO { String options4; @JsonProperty( access = JsonProperty.Access.WRITE_ONLY) String rightAnswer; + @JsonIgnore Integer rightOption; String category; String topic; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 42c7d48..749039c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -27,3 +27,4 @@ spring.mail.username=srivastavharshraj@gmail.com spring.mail.password=dyxwysgcrtlszoys spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true +