update gem

fix codeharbor endpoint usage and translations
This commit is contained in:
Karol
2021-12-09 20:36:57 +01:00
parent a006a477e0
commit 886a5b68f6
8 changed files with 27 additions and 29 deletions

View File

@ -14,21 +14,20 @@ module ExerciseService
req.headers['Authorization'] = "Bearer #{@codeharbor_link.api_key}"
req.body = {uuid: @uuid}.to_json
end
response_hash = JSON.parse(response.body, symbolize_names: true).slice(:exercise_found, :update_right)
response_hash = JSON.parse(response.body, symbolize_names: true).slice(:task_found, :update_right)
{error: false,
message: message(response_hash[:exercise_found], response_hash[:update_right])}.merge(response_hash)
{error: false, message: message(response_hash[:task_found], response_hash[:update_right])}.merge(response_hash)
rescue Faraday::Error, JSON::ParserError
{error: true, message: I18n.t('exercises.export_codeharbor.error')}
end
private
def message(exercise_found, update_right)
if exercise_found
update_right ? I18n.t('exercises.export_codeharbor.check.exercise_found') : I18n.t('exercises.export_codeharbor.check.exercise_found_no_right')
def message(task_found, update_right)
if task_found
update_right ? I18n.t('exercises.export_codeharbor.check.task_found') : I18n.t('exercises.export_codeharbor.check.task_found_no_right')
else
I18n.t('exercises.export_codeharbor.check.no_exercise')
I18n.t('exercises.export_codeharbor.check.no_task')
end
end