9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/learn/exercise.rb', line 9
def self.submit(name, contents)
settings = Learn.read_settings
begin
legal_name = name.match(/ex(?<order>\d+)/)
if legal_name
response = RestClient.post(
"#{Learn::HOST}/students/#{settings["account_number"].chomp}/exercises.json",
{exercise: {name: name, contents: contents, ordering: legal_name[:order]}})
print green, "Exercise #{legal_name[:order]} submitted successfully", reset, "\n"
end
rescue Exception => e
puts e
print red, "Exercise could not be submitted :(", reset, "\n"
end
end
|