quiz_proctor_engine 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 653bb7ff658988d53fab1b23011f54ab55f99b37
|
4
|
+
data.tar.gz: 9c9dc7171138db52e9edd23af674627f027a47db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9719c5ef7a2ec286ca99223103d77a4f6c2c05f2e57c679e8f812e133d4bc6169a4a6ebeb8fe2cc97d09e358c63b908155b82446691b5f753d9e358804d6118
|
7
|
+
data.tar.gz: 7308d47d012af9b7f36ffd7b259df63f779f07f5ec64c88b5c6fb4b3abd8e99a67673e0039a5ad05d0cf7f05b06d12227123b0f871ff3b5e2bb28a472e7cacb7
|
@@ -20,6 +20,7 @@ module Concerns::ValidateSignature
|
|
20
20
|
raise "Invalid Signature " if !params[:signature]
|
21
21
|
plugin = PluginSetting.find_by(name: "quiz_proctor")
|
22
22
|
verifier = ActiveSupport::MessageVerifier.new plugin.settings[:proctor_secret]
|
23
|
-
verifier.verify(params[:signature])
|
23
|
+
verified = verifier.verify(params[:signature])
|
24
|
+
verified && Time.now.to_i - params[:date].to_i < 30
|
24
25
|
end
|
25
26
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (C) 2017 Atomic Jolt
|
2
|
+
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU Affero General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU Affero General Public License for more details.
|
12
|
+
|
13
|
+
# You should have received a copy of the GNU Affero General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
require "httparty"
|
16
|
+
|
17
|
+
class ProctorConversationsController < ApplicationController
|
18
|
+
skip_before_filter :verify_authenticity_token
|
19
|
+
before_action :verify_messageable
|
20
|
+
|
21
|
+
def initiate_conversation
|
22
|
+
proctor = User.find(params[:proctor_id])
|
23
|
+
student = User.find(params[:student_id])
|
24
|
+
message = Conversation.build_message(proctor, params[:body])
|
25
|
+
conversation = proctor.initiate_conversation([student], true, subject: params[:subject])
|
26
|
+
conversation.add_message(message, update_for_sender: false, cc_author: true)
|
27
|
+
render json: { status: :ok }
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def verify_messageable
|
33
|
+
headers = {
|
34
|
+
"Content-Type" => "application/json",
|
35
|
+
}
|
36
|
+
plugin = PluginSetting.find_by(name: "quiz_proctor")
|
37
|
+
|
38
|
+
query = {
|
39
|
+
student_id: params[:student_id],
|
40
|
+
proctor_code: params[:proctor_code],
|
41
|
+
unstarted: true,
|
42
|
+
}.to_query
|
43
|
+
|
44
|
+
quiz = HTTParty.get(
|
45
|
+
"#{plugin.settings[:adhesion_url]}/api/proctored_exams?#{query}",
|
46
|
+
headers: headers,
|
47
|
+
# verify: false,
|
48
|
+
)
|
49
|
+
if quiz.parsed_response["error"].present?
|
50
|
+
render json: { error: "Unauthorized" }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/config/routes.rb
CHANGED
@@ -17,4 +17,5 @@ Rails.application.routes.draw do
|
|
17
17
|
get "proctor_login" => "proctor_login#login"
|
18
18
|
get "proctored_exams" => "proctored_exams#show"
|
19
19
|
post "proctored_exams" => "proctored_exams#start_quiz"
|
20
|
+
post "proctor_conversations" => "proctor_conversations#initiate_conversation"
|
20
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quiz_proctor_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dittonjs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- app/controllers/concerns/proctor_quizzes.rb
|
40
40
|
- app/controllers/concerns/validate_signature.rb
|
41
41
|
- app/controllers/concerns/whitelist.rb
|
42
|
+
- app/controllers/proctor_conversations_controller.rb
|
42
43
|
- app/controllers/proctor_login_controller.rb
|
43
44
|
- app/controllers/proctored_exams_controller.rb
|
44
45
|
- app/views/layouts/quiz_proctor.erb
|