module Exercises
Public Instance Methods
Get an exercise
@return [HTTParty::Response] One exercise. @example Get exercise by id
Atlas#get_exercise(id)
# File lib/client/exercises.rb, line 24 def get_exercise(id) url = "#{@api_base_path}/exercises/" + id.to_s handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "exercise") end end
Get all exercises
@return [HTTParty::Response] All exercises. @example Get all exercises
Atlas#get_exercises
# File lib/client/exercises.rb, line 11 def get_exercises url = "#{@api_base_path}/exercises" handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "exercises") end end
Update an exercise
@param id [Integer] An exercise id. @param options [Hash] A customizable set of options. @option options [String] :name Exercise name. @option options [String] :body Exercise body. @option options [Integer] :status Exercise status. @option options [String] :slug Exercise slug. @option options [String] :specs Exercise specs. @option options [String] :starting_code Exercise starting code. @option options [String] :canonical_solution Exercise solution. @option options [String] :language Exercise language. @return [Exercise] The updated checkpoint @example Update a checkpoint
Atlas#update_checkpoint(1, {name: 'Real Cool Exercise'})
# File lib/client/exercises.rb, line 47 def update_exercise(id, options={}) whitelist = [ 'name', 'description', 'body', 'status', 'slug', 'specs', 'starting_code', 'canonical_solution', 'language', 'run_strategy_attributes', 'starting_code', 'canonical_solution', 'instructions' ] options = convert_keys(options) params = whitelist_params(options, whitelist) url = "#{@api_base_path}/exercises/#{id}" handle_timeouts do response = self.class.put(url, headers: auth_header, body: { exercise: params }) convert_response(response, "exercise") end end