Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
fix: session exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
HoXuanHieu committed Apr 16, 2024
1 parent d316dfb commit 3e46da2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.List;

@Getter
@Setter
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

public interface SessionExerciseRepository extends MongoRepository<SessionExercise, String> {
List<SessionExercise> findByStudentIdAndLoginId(String studentId, String loginId);
List<SessionExercise> findByStudentId(String studentId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.example.codeE.request.user.UserAuthenRequest;
import com.example.codeE.security.BCryptPassword;
import com.example.codeE.service.course.CourseService;
import com.example.codeE.service.exercise.common.SessionExerciseService;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ else if (exercise.getKey().equals(key) && isReTemp(exercise.getExerciseId(), stu
}
}
//check session exercise
var sessionExercises = this.sessionExerciseRepository.findByStudentIdAndLoginId(studentId, loginId);
var sessionExercises = this.sessionExerciseRepository.findByStudentId(studentId);
if (sessionExercises.isEmpty()) {
// if it does not have any session has been saved create new one.
// get time now
Expand Down Expand Up @@ -204,7 +204,7 @@ else if (exercise.getKey().equals(key) && isReTemp(exercise.getExerciseId(), stu
throw new IllegalArgumentException("Student need to complete another current exercise before participating in a new one.");
}
} else {
throw new IllegalArgumentException("Failed to retrieve exercise information.");
throw new IllegalArgumentException("Student is using another browser to take an exercise.");
}
}
}
Expand Down

0 comments on commit 3e46da2

Please sign in to comment.