Merge remote-tracking branch 'origin/master' into fix-structured-errors
This commit is contained in:
@ -364,7 +364,7 @@ class Exercise < ActiveRecord::Base
|
||||
end
|
||||
private :valid_main_file?
|
||||
|
||||
def needs_more_feedback
|
||||
def needs_more_feedback?
|
||||
user_exercise_feedbacks.size <= MAX_EXERCISE_FEEDBACKS
|
||||
end
|
||||
|
||||
|
@ -57,7 +57,7 @@ class Submission < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def redirect_to_feedback?
|
||||
((user_id + exercise.created_at.to_i) % 10 == 1) && exercise.needs_more_feedback
|
||||
((user_id + exercise.created_at.to_i) % 10 == 1) && exercise.needs_more_feedback?
|
||||
end
|
||||
|
||||
def own_unsolved_rfc
|
||||
|
@ -54,8 +54,6 @@ h1 = "#{@exercise} (external user #{@external_user})"
|
||||
-submission_or_intervention.testruns.each do |run|
|
||||
- if run.passed
|
||||
.unit-test-result.positive-result title=run.output
|
||||
- elsif run.failed
|
||||
.unit-test-result.negative-result title=run.output
|
||||
- else
|
||||
.unit-test-result.unknown-result title=run.output
|
||||
td = Time.at(deltas[1..index].inject(:+)).utc.strftime("%H:%M:%S") if index > 0
|
||||
|
@ -1,59 +0,0 @@
|
||||
class Xikolo::Client
|
||||
def self.get_user(user_id)
|
||||
params = {:user_id => user_id}
|
||||
response = get_request(user_profile_url(user_id), params)
|
||||
if response
|
||||
return JSON.parse(response)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def self.user_profile_url(user_id)
|
||||
return url + 'v2/users/' + user_id
|
||||
end
|
||||
|
||||
def self.post_request(url, params)
|
||||
begin
|
||||
return RestClient.post url, params, http_header
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def self.get_request(url, params)
|
||||
begin
|
||||
return RestClient.get url, {:params => params}.merge(http_header)
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def self.http_header
|
||||
return {:accept => accept, :authorization => token}
|
||||
end
|
||||
|
||||
def self.url
|
||||
@url ||= CodeOcean::Config.new(:code_ocean).read.fetch(:xikolo_api_url, 'http://localhost:3000/api/') #caches this with ||=, second value of fetch is default value
|
||||
end
|
||||
|
||||
def self.accept
|
||||
'application/vnd.xikolo.v1, application/vnd.api+json, application/json'
|
||||
end
|
||||
|
||||
def self.token
|
||||
'Token token='+Rails.application.secrets.openhpi_api_token#+'"'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def authenticate_with_user
|
||||
params = {:email => "admin@openhpi.de", :password => "admin"}
|
||||
response = post_request(authentication_url, params)
|
||||
@token = 'Token token="'+JSON.parse(response)['token']+'"'
|
||||
end
|
||||
|
||||
def self.authentication_url
|
||||
return @url + 'authenticate'
|
||||
end
|
||||
end
|
@ -1,15 +0,0 @@
|
||||
class Xikolo::UserClient
|
||||
def self.get(user_id)
|
||||
user = Xikolo::Client.get_user(user_id)
|
||||
|
||||
# return default values if user is not found or if there is a server issue:
|
||||
if user
|
||||
name = user.dig('data', 'attributes', 'name') || "User " + user_id
|
||||
user_visual = user.dig('data', 'attributes', 'avatar_url') || ActionController::Base.helpers.image_path('default.png')
|
||||
language = user.dig('data', 'attributes', 'language') || "DE"
|
||||
return {display_name: name, user_visual: user_visual, language: language}
|
||||
else
|
||||
return {display_name: "User " + user_id, user_visual: ActionController::Base.helpers.image_path('default.png'), language: "DE"}
|
||||
end
|
||||
end
|
||||
end
|
@ -132,12 +132,14 @@ describe SessionsController do
|
||||
end
|
||||
|
||||
it 'redirects to recommended exercise if requested token of proxy exercise' do
|
||||
pending 'test is currently oscillating'
|
||||
FactoryBot.create(:proxy_exercise, exercises: [exercise])
|
||||
post :create_through_lti, custom_locale: locale, custom_token: ProxyExercise.first.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id
|
||||
expect(controller).to redirect_to(implement_exercise_path(exercise.id))
|
||||
end
|
||||
|
||||
it 'recommends only exercises who are 1 degree more complicated than what user has seen' do
|
||||
pending 'test is currently oscillating'
|
||||
# dummy user has no exercises finished, therefore his highest difficulty is 0
|
||||
FactoryBot.create(:proxy_exercise, exercises: [exercise, exercise2])
|
||||
exercise.expected_difficulty = 3
|
||||
|
Reference in New Issue
Block a user