pwcoleman/TinCanRuby

Correct TinCanApi::Activity and TinCanApi::Result calls

Closed this issue · 1 comments

Am attempting to pass a statement for an activity with name and decription, including a result

agent = TinCanApi::Agent.new(mbox: 'mailto:arnold.marunda@live.com')
verb = TinCanApi::Verb.new(id: 'http://adlnet.gov/expapi/verbs/completed', name: 'completed')
object = TinCanApi::Activity.new(id: "https://somelms/quizzes/numerical-reasoning", 
         name: 'Numerical Reasoning', 
         type: 'http://adlnet.gov/expapi/activities/assessment', 
         description: 'Numerical ability tests are used to establish a candidate’s ability to read and understand the information presented in numerical form and then use the correct and most effective operations to find the right answer. Although it is senior-school level maths, you will still need to be efficient and well-practiced.',
         extensions: { "http://id.tincanapi.com/extension/planned-duration" => 'PT20M' }
                              )
result = TinCanApi::Result.new(
         response: 'Passed', 
         score: {min: 0, raw: 1, max: 2}, 
         success: true, 
         extensions: {"https://somelms/quizzes/numerical-reasoning" => [
                     'Xavier calls each of his employees on Monday mornings. He speaks to John second, Henry third, Joanna fifth and Layla sixth. Based on the information above, which of the following statements CANNOT be true?',
                     'Lola lives in the United States of America but visits Canada twice a year, bringing her three dogs with her. She needs to buy new insurance for her dogs. Which plan is the best for Lola’s needs?'
                     ]})

                     
statement = TinCanApi::Statement.new do |s|
  s.actor = agent
  s.verb = verb
  s.object = object
  s.result = result
end

response = remote_lrs.save_statement(statement)

Can somebody help with the correct syntax to make the above calls.

agent     = TinCanApi::Agent.new(mbox: 'mailto:arnold.marunda@live.com', name: 'Arnold Marunda')
verb      = TinCanApi::Verb.new(id: 'http://adlnet.gov/expapi/verbs/completed', display: {en: "completed"})
definition = TinCanApi::ActivityDefinition.new(name: {en: 'Numerical Reasoning'}, type: 'http://adlnet.gov/expapi/activities/assessment', description: {en: 'A fictitious example CBT course.'}, interaction_type: "choice", extensions: { "http://id.tincanapi.com/extension/planned-duration" => 'PT20M' })
activity    = TinCanApi::Activity.new(id: "http://www.candidatetalent.com/quizzes/numerical-reasoning", definition: definition)
score     = TinCanApi::Score.new(scaled: 0.75, raw: 15, min: 0, max: 20)
duration = Duration.new(minutes: 12)
result    = TinCanApi::Result.new(response: 'Passed', 
                                  score: score, 
                                  success: true,
                                  completion: true,
                                  duration: duration)
              
statement = TinCanApi::Statement.new do |s|
  s.actor = agent
  s.verb = verb
  s.object = activity
  s.result = result
end

response = remote_lrs.save_statement(statement)