Asked by:
preventing link copy- just for one test -VB.NET

Question
-
User-1578974752 posted
For Online test page ,Below code is helping me to prevent copying link to another browser.But there are many test which user have to do simultaneously.This code prevent them from re-login to next exam..One test user can attend 3 times .like that 10 test are there. how to do this .Appreciate the help
<system.web>
<sessionState mode="InProc" timeout="120"/>
</system.web>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then Dim record = Session("record")
If record Is Nothing Then Session("record") = "have started"
Else
Response.Write("you have started the exam")
Response.End()
End If
End If
End Sub
Thursday, November 29, 2018 2:15 AM
All replies
-
User-893317190 posted
Hi shsu,
You could use a counter to record the umber of exams.The counter is recorded in session.
Every time the user starts the exam, the counter will add one.
If its value is beyond 3, you could stop the exam.
Below is my code.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then Dim record = Session("record") If record Is Nothing Then Session("record") = 1 Else Dim count As Int32 = Session("record") Session("record") = count + 1 If count + 1 >= 4 Then Response.Write("you have finished all the exams") Response.End() End If End If End If End Sub
Best regards,
Ackerly Xu
Friday, November 30, 2018 3:10 AM -
User-1578974752 posted
Multiple users are using the system at the same time. If I login and tried to copy link to another browser,then it stops the user. that is fine
But if another user login in another browser also same you have started the exam" message is showing.I have login ID.. How can I restrict copying the link using Login ID.SEESION TIME OUT IS SET TO 60 FOR TEST earlier.so I didn't use <sessionState mode="InProc" timeout="120"/>
or I placed the whole website session time out to be 60 minutes. I can not change it . Is it possible to have this particular session's time out to be 5 minutes.
Else
Response.Write("you have started the exam")
Response.End()
End If
End If
Friday, November 30, 2018 9:43 AM -
User475983607 posted
This is a pure design question and fundamental state management in ASP.
Session will not wok by itself because Session is unique to the browser instance. You can learn about Session by reading the documentation.
I recommend a database to track the user and the exam(s) they are taking. The table will have at least an exam id, User Id, start date and end date. When the user starts an exam, write a record to the database. When the user completes an exam, set the end date.
If the user has 3 records without an end date then they have reached the max exam limit and cannot start a new exam. I'm assuming they can take 3 different exams at the same time.
All you have to do is check the user's exam state whenever needed. That could be on every request or when the user accesses an exam. This is very simple, assuming that you are using standard ASP.NET security and know the identity of the user.
Friday, November 30, 2018 1:42 PM -
User-1578974752 posted
Thanks mgebhard
In my code and the database ,maximum 3 attempts are clearly defined. If user login for the 3rd time and select the same test for the 4 th time, they are not allowed to take the test and they can not even go to Test page.
But when they copy the Test page link to another browser ,then start exam page is showing .Exam page is a repeater with 3 pages,and they could do the test again.start exam page is having 3 pages in repeater control.
Wednesday, December 5, 2018 5:23 AM -
User-893317190 posted
Hi shsu,
If you want to prevent the student to login with another browser, you should design a user table for the students.
For example , the table has three columns id , name , examtime(default is zero),password and you could use examtime to record exam time.
The use must login with the password.
And then after they login , you could save the use data (id,name,examtime) in your session.
Every time they go to the text page, you could update the user data in database , add the examtime.
If they use another browser, you could ask them to login and get the examtime in the database.
If it is bigger than three, then they are not allowed to restart the exam.
Best regards,
Ackerly Xu
Wednesday, December 5, 2018 5:34 AM