i am building a MCQ module(online MCQ module) for students. so here i encountered a problem regarding that i have identified a one student as one device. simply thinkin a one student is having one device for the exam. but when it comes to a local network it doesnt work due to subnet and stuff.
please help me resolving this issue. what should i do to avoid this issue? i have provided my backend down here.
the Repo class
@Repository
public interface StudentExamRepository extends
CrudRepository<StudentExam,Long>
{
@Query(value = "select * from student_exam where exam_link_id = ?1 and
(student_id = ?2 or attempted_ip = ?3)", nativeQuery = true)
List<StudentExam> findByExamLinkIdStudentIdAndIp( long examId, long
studentId, String ip );
}
service class
public Boolean hasStudentAttempted( long examLinkId, long studentId, String attemptedId )
{
return studentExamRepository.findByExamLinkIdStudentIdAndIp( examLinkId, studentId, attemptedId ).size() != 0;
}
@RequestMapping(method = RequestMethod.GET, value = "/allowed/hasStudentAttempted")
public ResponseEntity<Boolean> hasStudentAttempted( @RequestParam long examLinkId, @RequestParam long studentId, HttpServletRequest request )
{
return new ResponseEntity<>( studentExamService.hasStudentAttempted( examLinkId, studentId, request.getRemoteAddr() ), HttpStatus.OK );
}
controller class
@RequestMapping(method = RequestMethod.GET, value = "/allowed/hasStudentAttempted")
public ResponseEntity<Boolean> hasStudentAttempted( @RequestParam long examLinkId, @RequestParam long studentId, HttpServletRequest request )
{
return new ResponseEntity<>( studentExamService.hasStudentAttempted( examLinkId, studentId, request.getRemoteAddr() ), HttpStatus.OK );
}