class Api::V2::ExamsController
See examples here: gist.github.com/danielefrisanco/737471a124bfd67cd1711a953364d965
Public Instance Methods
POST /api/exams/:id/add_student
Adds a student to an exam
-
Args :
-
individual_info-> information that is displayed to this student at the beginning of the exam -
is_individual_info_html-> information that is will define if the individual_info should be displayed as html or plain_text (true or false) -
id-> the exam id -
name-> the name of the student -
email-> the email of the student -
attempt-> the attempt number of the student (0 by default). This must be unique per each student (bound to email). To create an additional attempt, create a new student session with the same email and increment the highest existing attempt number for a student by one. -
use_duration-> whether duration is used or not (boolean), 0 or false to not use it -
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
open_time-> epoch time in seconds of opening time for the student(must be in exam's boundaries), can be omitted -
individual_info-> information that will only be shown to this specific student -
signature-> HMAC sha256 hex encoded hash, using the user secret_key as key, of the query string build with all the other parameters in the format “name=value” joined by “?” and ordered alphabethically by name. Do not use encoding scheme on the values you use to calculate the string
-
-
Returns :
-
a json cointaining the students that was added:
-
student_session:-
individual_info-> information that is displayed to this student at the beginning of the exam -
is_individual_info_html-> information that is will define if the individual_info should be displayed as html or plain_text -
student_id-> the id of the student -
name-> the name of the student -
email-> the email of the student -
attempt-> the attempt number of the student -
exam_id-> the id of the exam -
status-> the status of the student -
open_time-> epoch time in seconds of opening time for the student -
start_time-> epoch time in seconds of start time for the student -
end_time-> epoch time in seconds of end time for the student -
token-> the token to be used in order to create the link to the exam room
-
-
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 266 def add_student @student_session = StudentSession.new(build_student_attributes) if @student_session.save save_request render json: { student_session: (build_student_session_json_response @student_session) }, status: :ok and return else render json: { errors: @student_session.errors }, status: :bad_request and return end end
POST /api/exams
Creates an exam
-
Args :
-
name-> the name of the exam -
duration-> the duration of the exam in minutes -
mobile_cam-> true if mobile recording is required -
type-> the type of the exam:1. demo 2. classroom 3. record_review 4. live_proctoring
-
start_time-> the first start time of the exam in epoch format -
end_time-> the last end time of the exam in epoch format, can be omitted -
for_reviewing-> true if you want to send the student videos to reviewers, can be omitted -
use_duration-> wether the exam uses duration, true by default -
upload_exam-> true if student has to upload one or more document at the end of the exam through proctorexam platform -
restrictions-> The instructions for the reviewer, can be omitted -
allow_websites-> Boolean for allowing websites to be used during the exam, can be omitted -
allow_external_applications-> Boolean for allowing external applications to be used during the exam, can be omitted -
allow_textbooks-> Boolean for allowing textbooks to be used during the exam, can be omitted -
allow_calculator-> Boolean for allowing calculator to be used during the exam, can be omitted -
allow_pen_paper-> Boolean for allowing pen and paper to be used during the exam, can be omitted -
allow_additional-> Boolean for allowing additional materials to be used during the exam, can be omitted -
allowed_websites-> Comma separated string with the different websites that can be used in the exam, can be omitted -
allowed_external_applications-> Comma separated string with the different external applications that can be used in the exam, can be omitted -
allowed_textbooks-> Comma separated string with the different textbooks that can be used in the exam, can be omitted -
allowed_calculator_type-> String with the calculator type that can be used in the exam, can be omitted -
allowed_additional-> Comma separated string with the different additional materials that can be used in the exam, can be omitted -
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
signature-> HMAC sha256 hex encoded hash using tf the query string build with all the other parameters in the format “name=value” joined by “?” and in alphabetical order
-
-
Returns :
-
a json:
-
id-> the id of the exam
-
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 47 def create if @json['duration'] && @json['type'] && @json['name'] @exam = Exam.new @exam.assign_attributes(build_exam_attributes) if @exam.save save_request render json: {id: @exam.id}, status: :created and return end end render nothing: true, status: :bad_request and return end
DELETE /api/exams/:id/delete_student
Deletes a student session from an exam
-
Args :
-
id-> the exam id -
student_session_id-> the student_session id -
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
signature-> HMAC sha256 hex encoded hash, using the user secret_key as key, of the query string build with all the other parameters in the format “name=value” joined by “?” and ordered alphabethically by name. Do not use encoding scheme on the values you use to calculate the string
-
-
Returns :
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 289 def delete_student if @student_session.end_time ? @student_session.archive : @student_session.destroy save_request render nothing: true, status: :ok and return else render nothing: true, status: :not_found and return end end
DELETE /api/exams/:id
Deletes the exam
-
Args :
-
id-> the exam id -
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
signature-> HMAC sha256 hex encoded hash, using the user secret_key as key, of the query string build with all the other parameters in the format “name=value” joined by “?” and ordered alphabethically by name. Do not use encoding scheme on the values you use to calculate the string
-
-
Returns :
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 107 def destroy if @exam.destroy save_request render nothing: true, status: :ok and return else render nothing: true, status: :bad_request and return end end
GET /api/exams
Index the exams that belongs to the user
-
Args :
-
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
signature-> HMAC sha256 hex encoded hash, using the user secret_key as key, of the query string build with all the other parameters in the format “name=value” joined by “?” and ordered alphabethically by name. Do not use encoding scheme on the values you use to calculate the string
-
-
Returns :
-
a json cointaining the exams:
-
exams:-
exam_id-> the id of the exam -
name-> the name of the exam -
start_time-> the start time of the exam -
end_time-> the end time of the exam -
duration-> the duration time of the exam -
upload_exam-> true if the student has to upload one or more document through proctorexam platform -
restrictions-> the instructions for the reviewer, formatted in html -
type-> the type of the exam:1. demo 2. classroom 3. record_review 4. live_proctoring
-
mobile_cam-> true if mobile recording is required -
user_id-> the id of the user who created the exam -
institute_id-> the id of the institute -
for_reviewing-> true if user wants exams to be reviewed -
use_duration-> whether the exam uses duration
-
-
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 90 def index save_request render json: { exams: Exam.where(user: @user).map{ |exam| build_exam_json_response exam } }, status: :ok and return end
POST /api/exams/:id/send_emails
Sends the check requirement email to registered students that haven't received it yet and returns the list of this students
-
Args :
-
id-> the exam id -
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
signature-> HMAC sha256 hex encoded hash, using the user secret_key as key, of the query string build with all the other parameters in the format “name=value” joined by “?” and ordered alphabethically by name. Do not use encoding scheme on the values you use to calculate the string
-
-
Returns :
-
a json cointaining the students to whom the email has been sent:
-
student_sessions:-
student_id-> the id of the student -
name-> the name of the student -
email-> the email of the student -
exam_id-> the id of the exam -
status-> the status of the student -
individual_info-> information that is displayed to this student at the beginning of the exam -
is_individual_info_html-> information that is will define if the individual_info should be displayed as html or plain_text -
attempt-> the attempt number of the student. -
use_duration-> whether duration is used or not (boolean), 0 or false to not use it -
open_time-> epoch time in seconds of opening time for the student -
start_time-> epoch time in seconds of start time for the student -
end_time-> epoch time in seconds of end time for the student
-
-
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 226 def send_emails save_request render json: { student_sessions: ( @exam.mass_email_sending.map{|student_session| build_student_session_json_response OpenStruct.new(student_session)}) }, status: :ok and return end
GET /api/exams/:id
Show the exam
-
Args :
-
id-> the exam id -
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
signature-> HMAC sha256 hex encoded hash, using the user secret_key as key, of the query string build with all the other parameters in the format “name=value” joined by “?” and ordered alphabethically by name. Do not use encoding scheme on the values you use to calculate the string
-
-
Returns :
-
a json cointaining the exam:
-
exam:-
exam_id-> the id of the exam -
name-> the name of the exam -
start_time-> the start time in seconds of the exam -
end_time-> the end time of in seconds the exam -
duration-> the duration time of the exam -
upload_exam-> true if the student has to upload one or more document through proctorexam platform -
restrictions-> the instructions for the reviewer, formatted in html -
type-> the type of the exam:1. demo 2. classroom 3. record_review 4. live_proctoring
-
mobile_cam-> true if mobile recording is required -
user_id-> the id of the user who created the exam -
institute_id-> the id of the institute -
for_reviewing-> true if user wants exams to be reviewed -
use_duration-> whether the exam uses duration
-
-
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 193 def show save_request render json: { exam: (build_exam_json_response @exam) }, status: :ok and return end
GET /api/exams/:id/show_students
Returns the list of the students registered to an exam
-
Args :
-
id-> the exam id -
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
signature-> HMAC sha256 hex encoded hash, using the user secret_key as key, of the query string build with all the other parameters in the format “name=value” joined by “?” and ordered alphabethically by name. Do not use encoding scheme on the values you use to calculate the string
-
-
Returns :
-
a json cointaining the students registered:
-
student_sessions:-
student_id-> the id of the student -
name-> the name of the student -
email-> the email of the student -
exam_id-> the id of the exam -
status-> the status of the student -
individual_info-> information that is displayed to this student at the beginning of the exam -
is_individual_info_html-> information that is will define if the individual_info should be displayed as html or plain_text -
attempt-> the attempt number of the student -
open_time-> epoch time in seconds of opening time for the student -
start_time-> epoch time in seconds of start time for the student -
end_time-> epoch time in seconds of end time for the student -
token-> token for accessing student_session information
-
-
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 325 def show_students save_request render json: { student_session: ( @exam.student_sessions.map{|student_session| build_student_session_json_response student_session}) }, status: :ok and return end
POST /api/exams/:id
Updates an exam
-
Args :
-
id-> the exam id -
name-> the new name of the exam, can be omitted -
duration-> the new duration of the exam, can be omitted -
mobile_cam-> the new value for mobile camera, true if mobile recording is required, can be omitted -
type-> the new type of the exam, can be omitted:1. demo 2. classroom 3. record_review 4. live_proctoring
-
start_time-> the new start time of the exam in epoch format, can be omitted -
end_time-> the new end time of the exam in epoch format, can be omitted -
use_duration-> wether the exam uses duration, true by default -
for_reviewing-> true if user wants exams to be reviewed -
upload_exam-> the new value for upload exam, true if student has to upload one or more document at the end of the exam through proctorexam platform, can be omitted -
restrictions-> The instructions for the reviewer, can be omitted -
allow_websites-> Boolean for allowing websites to be used during the exam, can be omitted -
allow_external_applications-> Boolean for allowing external applications to be used during the exam, can be omitted -
allow_textbooks-> Boolean for allowing textbooks to be used during the exam, can be omitted -
allow_calculator-> Boolean for allowing calculator to be used during the exam, can be omitted -
allow_pen_paper-> Boolean for allowing pen and paper to be used during the exam, can be omitted -
allow_additional-> Boolean for allowing additional materials to be used during the exam, can be omitted -
allowed_websites-> Comma separated string with the different websites that can be used in the exam, can be omitted -
allowed_external_applications-> Comma separated string with the different external applications that can be used in the exam, can be omitted -
allowed_textbooks-> Comma separated string with the different textbooks that can be used in the exam, can be omitted -
allowed_calculator_type-> String with the calculator type that can be used in the exam, can be omitted -
allowed_additional-> Comma separated string with the different additional materials that can be used in the exam, can be omitted -
timestamp-> epoch time in milliseconds -
nonce-> random number unique between the api calls made in the previous 24 hours -
api_token-> the user api_token -
signature-> HMAC sha256 hex encoded hash, using the user secret_key as key, of the query string build with all the other parameters in the format “name=value” joined by “?” and ordered alphabethically by name. Do not use encoding scheme on the values you use to calculate the string
-
-
Returns :
-
http status 200
-
# File app/controllers/api/v2/exams_controller.rb, line 153 def update if @exam.update_attributes( build_exam_update_attributes ) save_request render nothing: true, status: :ok and return else render nothing: true, status: :bad_request and return end end