Skip to content

Commit f7fb404

Browse files
authored
Merge branch 'staging' into merge-branch
2 parents bd83c75 + a110a1a commit f7fb404

File tree

4 files changed

+23
-149
lines changed

4 files changed

+23
-149
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"makefile.configureOnOpen": false
3+
}

app/controllers/odsa_exercise_attempts_controller.rb

Lines changed: 13 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ def create
141141
end
142142
end
143143

144-
# -------------------------------------------------------------
145-
# POST /odsa_exercise_attempts/pe
146-
def create_pe
144+
# POST /odsa_exercise_attempts/new
145+
def create_attempt
146+
147147
unless user_logged_in?
148148
return
149149
end
@@ -162,151 +162,14 @@ def create_pe
162162
"inst_book_id=? and inst_section_id=? and inst_exercise_id=?",
163163
params[:inst_book_id], params[:inst_section_id], inst_exercise.id
164164
).first
165-
if inst_book_section_exercise.blank?
166-
respond_to do |format|
167-
msg = {:status => "fail", :message => "Fail!"}
168-
format.json { render :json => msg }
169-
end
170-
return
171-
end
172-
threshold = inst_book_section_exercise.threshold
173-
elsif is_standalone_module
174-
inst_exercise = InstExercise.find_by(short_name: params[:exercise])
175-
inst_module_section_exercise = InstModuleSectionExercise.find_by(
176-
inst_exercise_id: inst_exercise.id,
177-
inst_module_version_id: params[:inst_module_version_id])
178-
threshold = inst_module_section_exercise.threshold
179-
else
180-
inst_course_offering_exercise = InstCourseOfferingExercise.find_by(
181-
id: params[:inst_course_offering_exercise_id],
182-
)
183-
threshold = inst_course_offering_exercise.threshold
184-
end
185-
186-
if inst_book_section_exercise != nil or inst_course_offering_exercise != nil or inst_module_section_exercise != nil
187-
if hasBook
188-
unless exercise_progress = OdsaExerciseProgress.where("user_id=? and
189-
inst_book_section_exercise_id=?",
190-
current_user.id,
191-
inst_book_section_exercise.id).first
192-
exercise_progress = OdsaExerciseProgress.new(user: current_user,
193-
inst_book_section_exercise: inst_book_section_exercise)
194-
exercise_progress.save
195-
end
196-
elsif is_standalone_module
197-
unless exercise_progress = OdsaExerciseProgress.where("user_id=? and
198-
inst_module_section_exercise_id=?",
199-
current_user.id,
200-
inst_module_section_exercise.id).first
201-
exercise_progress = OdsaExerciseProgress.new(user: current_user,
202-
inst_module_section_exercise: inst_module_section_exercise)
203-
exercise_progress.save
204-
end
205-
else
206-
unless exercise_progress = OdsaExerciseProgress.where("user_id=? and
207-
inst_course_offering_exercise_id=?",
208-
current_user.id,
209-
inst_course_offering_exercise.id).first
210-
exercise_progress = OdsaExerciseProgress.new(user: current_user,
211-
inst_course_offering_exercise: inst_course_offering_exercise)
212-
exercise_progress.save
213-
end
214-
end
215-
216-
already_proficient = exercise_progress.proficient?
217-
correct = params[:score].to_f >= params[:threshold].to_f
218-
219-
exercise_attempt = OdsaExerciseAttempt.new(
220-
inst_book_id: params[:inst_book_id],
221-
user: current_user,
222-
inst_section: inst_section,
223-
inst_book_section_exercise: inst_book_section_exercise,
224-
inst_course_offering_exercise: inst_course_offering_exercise,
225-
inst_module_section_exercise: inst_module_section_exercise,
226-
worth_credit: correct,
227-
correct: correct,
228-
time_done: Time.now,
229-
time_taken: (params[:total_time].to_f / 1000).round,
230-
count_hints: 0,
231-
count_attempts: params[:uiid],
232-
hint_used: 0,
233-
question_name: params[:exercise],
234-
request_type: "PE",
235-
ip_address: request.ip,
236-
pe_score: params[:score],
237-
pe_steps_fixed: params[:steps_fixed],
238-
)
239-
165+
if inst_book_section_exercise.blank?
240166
respond_to do |format|
241-
if exercise_attempt.save
242-
if hasBook
243-
exercise_progress = OdsaExerciseProgress.where(
244-
"user_id=? and inst_book_section_exercise_id=?",
245-
current_user.id,
246-
inst_book_section_exercise.id
247-
).first
248-
elsif is_standalone_module
249-
exercise_progress = OdsaExerciseProgress.find_by(user_id: current_user.id,
250-
inst_module_section_exercise_id: inst_module_section_exercise.id)
251-
else
252-
exercise_progress = OdsaExerciseProgress.find_by(user_id: current_user.id,
253-
inst_course_offering_exercise_id: inst_course_offering_exercise.id)
254-
end
255-
if !already_proficient and exercise_progress.proficient? and
256-
exercise_progress.has_inst_course_offering_exercise?()
257-
258-
exercise_progress.post_course_offering_exercise_score_to_lms()
259-
end
260-
format.json {
261-
render :json => {
262-
:exercise_progress => exercise_progress,
263-
:threshold => threshold,
264-
:was_proficient => already_proficient,
265-
:is_proficient => exercise_progress.proficient?,
266-
}
267-
}
268-
else
269-
msg = {:status => "fail", :message => "Fail!"}
270-
format.json { render :json => msg }
167+
format.json do
168+
render json: { status: "fail", message: "Unable to find inst_book_section_exercise!" }, status: :bad_request
271169
end
272170
end
273-
else
274-
respond_to do |format|
275-
msg = {:status => "fail", :message => "Fail!"}
276-
format.json { render :json => msg }
277-
end
278-
end
279-
end
280-
281-
282-
# -------------------------------------------------------------
283-
# POST /odsa_exercise_attempts/ae
284-
def create_ae
285-
unless user_logged_in?
286171
return
287172
end
288-
289-
hasBook = params.key?(:inst_book_id)
290-
is_standalone_module = params.key?(:inst_module_version_id)
291-
if params.key?(:inst_book_section_exercise_id)
292-
inst_book_section_exercise = InstBookSectionExercise.find(params[:inst_book_section_exercise_id])
293-
inst_section = inst_book_section_exercise.inst_section
294-
threshold = inst_book_section_exercise.threshold
295-
elsif hasBook
296-
inst_book = InstBook.find_by(id: params[:inst_book_id])
297-
inst_exercise = InstExercise.find_by(short_name: params[:exercise])
298-
inst_section = InstSection.find_by(id: params[:inst_section_id])
299-
inst_book_section_exercise = InstBookSectionExercise.where(
300-
"inst_book_id=? and inst_section_id=? and inst_exercise_id=?",
301-
params[:inst_book_id], params[:inst_section_id], inst_exercise.id
302-
).first
303-
if inst_book_section_exercise.blank?
304-
respond_to do |format|
305-
msg = {:status => "fail", :message => "Fail!"}
306-
format.json { render :json => msg }
307-
end
308-
return
309-
end
310173
threshold = inst_book_section_exercise.threshold
311174
elsif is_standalone_module
312175
inst_exercise = InstExercise.find_by(short_name: params[:exercise])
@@ -353,8 +216,12 @@ def create_ae
353216

354217
already_proficient = exercise_progress.proficient?
355218

356-
correct = 1
357-
#correct = params[:score].to_f >= params[:threshold].to_f
219+
220+
correct = 1 #params[:score][:correct]
221+
request_type = params[:type]
222+
if request_type == "PE"
223+
correct = params[:score][:correct].to_f >= params[:threshold].to_f
224+
end
358225

359226
exercise_attempt = OdsaExerciseAttempt.new(
360227
inst_book_id: params[:inst_book_id],
@@ -371,7 +238,7 @@ def create_ae
371238
count_attempts: params[:uiid],
372239
hint_used: 0,
373240
question_name: params[:exercise],
374-
request_type: "AE",
241+
request_type: request_type,
375242
ip_address: request.ip,
376243
pe_score: params[:score],
377244
pe_steps_fixed: params[:steps_fixed],

app/models/odsa_module_progress.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ def update_proficiency(inst_exercise, force_send = false)
139139

140140
def post_score_to_lms()
141141
if self.lis_outcome_service_url and self.lis_result_sourcedid
142-
143142
consumer_key = nil
144143
consumer_secret = nil
145144
lms_instance = nil
@@ -192,6 +191,7 @@ def post_score_to_lms()
192191

193192
def post_score_to_lti_13(lms_instance)
194193
begin
194+
puts params
195195
lti_launch = LtiLaunch.where(user_id: self.user_id, lms_instance_id: lms_instance.id).order(created_at: :desc).first
196196

197197
if lti_launch.nil?

config/routes.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
get 'lti/launch_extrtool/:exercise_id', to: 'lti#launch_extrtool', as: :lti_launch_extrtool
1212
post 'lti/outcomes', to: 'lti#grade_passback', as: :lti_grade_passback
1313

14+
get '/odsa_user_interactions/latest_state' => 'odsa_user_interactions#get_latest_state'
1415
resources :odsa_user_interactions
1516
resources :odsa_user_time_tracking
1617
resources :odsa_exercise_attempts do
@@ -32,9 +33,12 @@
3233
get '/odsa_exercise_progresses/:inst_course_offering_exercise_id' =>
3334
'odsa_exercise_progresses#show_exercise',
3435
constraints: { inst_course_offering_exercise_id: /\d+/ }
35-
post '/odsa_exercise_attempts/pe' => 'odsa_exercise_attempts#create_pe'
36-
post '/odsa_exercise_attempts/ae' => 'odsa_exercise_attempts#create_ae'
36+
post '/odsa_exercise_attempts/pe' => 'odsa_exercise_attempts#create_attempt'
37+
post '/odsa_exercise_attempts/ae' => 'odsa_exercise_attempts#create_attempt'
3738
post '/odsa_exercise_attempts/pi' => 'odsa_exercise_attempts#create_pi'
39+
post '/odsa_exercise_attempts/new' => 'odsa_exercise_attempts#create_attempt'
40+
post '/odsa_exercise_attempts/new/pe' => 'odsa_exercise_attempts#create_attempt'
41+
post '/odsa_exercise_attempts/new/ka' => 'odsa_exercise_attempts#create'
3842
post '/odsa_exercise_attempts/get_attempts' => 'odsa_exercise_attempts#get_attempts'
3943
post '/odsa_exercise_attempts/get_checkpoint' => 'odsa_exercise_attempts#get_checkpoint'
4044
post '/odsa_exercise_attempts/get_progress' => 'odsa_exercise_attempts#get_progress'

0 commit comments

Comments
 (0)