mumuki-domain 7.0.5 → 7.0.6
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 +4 -4
- data/app/models/exam.rb +24 -5
- data/lib/mumuki/domain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c111563c53bbd8b40ee80ea56f0d3dc90f8c8ac666ca1688fb8419745bc63cff
|
|
4
|
+
data.tar.gz: 298300bc4e45eda5c512c637b91e90f10cc13c80b6e7fa9155c485b4bfce56ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f452c3d9383b0b59a458a88332e879351e342d63e574e512bb1c70adb9b3b3a11c24019ac86a86425910d72a19a8c9f686ee62bab4924add598c827df1843003
|
|
7
|
+
data.tar.gz: 8afb07a6b0ea3d070311fd70008f008059366889ee78509dff3f17b47a10713b4d30c4db04a5926bc3d439ce5a1183ca846057ddd80b39e620b3b39315b6fc9a
|
data/app/models/exam.rb
CHANGED
|
@@ -96,13 +96,21 @@ class Exam < ApplicationRecord
|
|
|
96
96
|
authorization_for(user).started_at
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
def authorize_users!(users)
|
|
100
|
+
users.each { |user| authorize! user }
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def unauthorize_users!(users)
|
|
104
|
+
authorizations_for(users).destroy_all
|
|
105
|
+
end
|
|
106
|
+
|
|
99
107
|
def process_users(users)
|
|
100
|
-
users
|
|
108
|
+
authorize_users!(users)
|
|
101
109
|
clean_authorizations users
|
|
102
110
|
end
|
|
103
111
|
|
|
104
|
-
def clean_authorizations(
|
|
105
|
-
|
|
112
|
+
def clean_authorizations(authorized_users)
|
|
113
|
+
unauthorize_users!(users.all_except(authorized_users))
|
|
106
114
|
end
|
|
107
115
|
|
|
108
116
|
def reindex_usages!
|
|
@@ -111,7 +119,7 @@ class Exam < ApplicationRecord
|
|
|
111
119
|
|
|
112
120
|
def self.import_from_resource_h!(json)
|
|
113
121
|
exam_data = json.with_indifferent_access
|
|
114
|
-
organization = Organization.
|
|
122
|
+
organization = Organization.locate! exam_data[:organization]
|
|
115
123
|
organization.switch!
|
|
116
124
|
adapt_json_values exam_data
|
|
117
125
|
remove_previous_version exam_data[:eid], exam_data[:guide_id]
|
|
@@ -120,8 +128,19 @@ class Exam < ApplicationRecord
|
|
|
120
128
|
exam
|
|
121
129
|
end
|
|
122
130
|
|
|
131
|
+
def self.upsert_students!(json)
|
|
132
|
+
data = json.with_indifferent_access
|
|
133
|
+
exam = find_by(classroom_id: data[:eid])
|
|
134
|
+
|
|
135
|
+
added_users = User.where(uid: data[:added])
|
|
136
|
+
deleted_users = User.where(uid: data[:deleted])
|
|
137
|
+
|
|
138
|
+
exam.authorize_users! added_users
|
|
139
|
+
exam.unauthorize_users! deleted_users
|
|
140
|
+
end
|
|
141
|
+
|
|
123
142
|
def self.adapt_json_values(exam)
|
|
124
|
-
exam[:guide_id] = Guide.
|
|
143
|
+
exam[:guide_id] = Guide.locate!(exam[:slug]).id
|
|
125
144
|
exam[:organization_id] = Organization.current.id
|
|
126
145
|
exam[:users] = User.where(uid: exam[:uids])
|
|
127
146
|
[:start_time, :end_time].each { |param| exam[param] = exam[param].to_time }
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mumuki-domain
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.0.
|
|
4
|
+
version: 7.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Franco Leonardo Bulgarelli
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-12-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|