Skip to content

Instantly share code, notes, and snippets.

@chanks
Created January 12, 2011 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanks/777124 to your computer and use it in GitHub Desktop.
Save chanks/777124 to your computer and use it in GitHub Desktop.
Loading development environment (Rails 3.0.3)
ruby-1.9.2-p0 > Quiz.collection.remove
=> true
ruby-1.9.2-p0 > Fabricate :built_quiz
=> #<Quiz _id: 4d2e3c770de0690d95000001, created_at: 2011-01-12 23:42:47 UTC, updated_at: 2011-01-12 23:42:47 UTC, user_id: BSON::ObjectId('4d2e3c770de0690d95000002'), time: 0, number: 1, built_at: 2011-01-12 23:42:47 UTC, completed_at: nil, graded_at: nil>
ruby-1.9.2-p0 > Quiz.count
=> 1
ruby-1.9.2-p0 > Quiz.collection.find_one
=> {"_id"=>BSON::ObjectId('4d2e3c770de0690d95000001'), "time"=>0, "user_id"=>BSON::ObjectId('4d2e3c770de0690d95000002'), "built_at"=>2011-01-12 23:42:47 UTC, "created_at"=>2011-01-12 23:42:47 UTC, "number"=>1, "updated_at"=>2011-01-12 23:42:47 UTC, "topics"=>[{"_id"=>1, "given"=>14}, {"_id"=>2, "given"=>10}, {"_id"=>3, "given"=>15}, {"_id"=>4, "given"=>13}], "pages"=>[{"time"=>0, "_id"=>1, "questions"=>[{"strikes"=>[], "_id"=>1, "problem_id"=>8577}, {"strikes"=>[], "_id"=>2, "problem_id"=>6262}, {"strikes"=>[], "_id"=>3, "problem_id"=>1369}, {"strikes"=>[], "_id"=>4, "problem_id"=>8504}, {"strikes"=>[], "_id"=>5, "problem_id"=>2146}, {"strikes"=>[], "_id"=>6, "problem_id"=>318}]}, {"time"=>0, "_id"=>2, "passage_id"=>10, "questions"=>[{"strikes"=>[], "_id"=>7, "problem_id"=>2539}, {"strikes"=>[], "_id"=>8, "problem_id"=>451}, {"strikes"=>[], "_id"=>9, "problem_id"=>7067}, {"strikes"=>[], "_id"=>10, "problem_id"=>1748}, {"strikes"=>[], "_id"=>11, "problem_id"=>6628}, {"strikes"=>[], "_id"=>12, "problem_id"=>5750}, {"strikes"=>[], "_id"=>13, "problem_id"=>8417}]}, {"time"=>0, "_id"=>3, "questions"=>[{"strikes"=>[], "_id"=>14, "problem_id"=>7367}, {"strikes"=>[], "_id"=>15, "problem_id"=>142}, {"strikes"=>[], "_id"=>16, "problem_id"=>6592}, {"strikes"=>[], "_id"=>17, "problem_id"=>7881}]}, {"time"=>0, "_id"=>4, "passage_id"=>55, "questions"=>[{"strikes"=>[], "_id"=>18, "problem_id"=>201}, {"strikes"=>[], "_id"=>19, "problem_id"=>6590}, {"strikes"=>[], "_id"=>20, "problem_id"=>3278}, {"strikes"=>[], "_id"=>21, "problem_id"=>2737}, {"strikes"=>[], "_id"=>22, "problem_id"=>9678}]}, {"time"=>0, "_id"=>5, "questions"=>[{"strikes"=>[], "_id"=>23, "problem_id"=>4110}, {"strikes"=>[], "_id"=>24, "problem_id"=>3475}, {"strikes"=>[], "_id"=>25, "problem_id"=>4246}, {"strikes"=>[], "_id"=>26, "problem_id"=>4367}]}, {"time"=>0, "_id"=>6, "passage_id"=>126, "questions"=>[{"strikes"=>[], "_id"=>27, "problem_id"=>5232}, {"strikes"=>[], "_id"=>28, "problem_id"=>3179}, {"strikes"=>[], "_id"=>29, "problem_id"=>3444}, {"strikes"=>[], "_id"=>30, "problem_id"=>6238}, {"strikes"=>[], "_id"=>31, "problem_id"=>3847}, {"strikes"=>[], "_id"=>32, "problem_id"=>5593}]}, {"time"=>0, "_id"=>7, "passage_id"=>152, "questions"=>[{"strikes"=>[], "_id"=>33, "problem_id"=>5743}, {"strikes"=>[], "_id"=>34, "problem_id"=>4055}, {"strikes"=>[], "_id"=>35, "problem_id"=>5165}, {"strikes"=>[], "_id"=>36, "problem_id"=>7741}, {"strikes"=>[], "_id"=>37, "problem_id"=>2027}]}, {"time"=>0, "_id"=>8, "questions"=>[{"strikes"=>[], "_id"=>38, "problem_id"=>718}, {"strikes"=>[], "_id"=>39, "problem_id"=>5069}, {"strikes"=>[], "_id"=>40, "problem_id"=>6613}, {"strikes"=>[], "_id"=>41, "problem_id"=>1495}, {"strikes"=>[], "_id"=>42, "problem_id"=>4403}, {"strikes"=>[], "_id"=>43, "problem_id"=>2970}]}, {"time"=>0, "_id"=>9, "questions"=>[{"strikes"=>[], "_id"=>44, "problem_id"=>6499}, {"strikes"=>[], "_id"=>45, "problem_id"=>4954}, {"strikes"=>[], "_id"=>46, "problem_id"=>7891}, {"strikes"=>[], "_id"=>47, "problem_id"=>8288}]}, {"time"=>0, "_id"=>10, "questions"=>[{"strikes"=>[], "_id"=>48, "problem_id"=>6586}, {"strikes"=>[], "_id"=>49, "problem_id"=>6126}, {"strikes"=>[], "_id"=>50, "problem_id"=>2101}, {"strikes"=>[], "_id"=>51, "problem_id"=>561}, {"strikes"=>[], "_id"=>52, "problem_id"=>5410}]}]}
ruby-1.9.2-p0 > quiz = Quiz.first
=> #<Quiz _id: 4d2e3c770de0690d95000001, created_at: 2011-01-12 23:42:47 UTC, updated_at: 2011-01-12 23:42:47 UTC, user_id: BSON::ObjectId('4d2e3c770de0690d95000002'), time: 0, number: 1, built_at: 2011-01-12 23:42:47 UTC, completed_at: nil, graded_at: nil>
ruby-1.9.2-p0 > quiz.pages
=> [#<Page _id: 1, passage_id: nil, time: 0>, #<Page _id: 2, passage_id: 10, time: 0>, #<Page _id: 3, passage_id: nil, time: 0>, #<Page _id: 4, passage_id: 55, time: 0>, #<Page _id: 5, passage_id: nil, time: 0>, #<Page _id: 6, passage_id: 126, time: 0>, #<Page _id: 7, passage_id: 152, time: 0>, #<Page _id: 8, passage_id: nil, time: 0>, #<Page _id: 9, passage_id: nil, time: 0>, #<Page _id: 10, passage_id: nil, time: 0>]
ruby-1.9.2-p0 > quiz.pages.first
=> #<Page _id: 1, passage_id: nil, time: 0>
ruby-1.9.2-p0 > quiz.pages.first.quiz
=> #<Quiz _id: 4d2e3c770de0690d95000001, created_at: 2011-01-12 23:42:47 UTC, updated_at: 2011-01-12 23:42:47 UTC, user_id: BSON::ObjectId('4d2e3c770de0690d95000002'), time: 0, number: 1, built_at: 2011-01-12 23:42:47 UTC, completed_at: nil, graded_at: nil>
ruby-1.9.2-p0 > quiz.pages.first.questions
=> [#<Question _id: 1, problem_id: 8577, answer: nil, correct: nil, marked: nil, ever_marked: nil, strikes: [], postmortem: nil>, #<Question _id: 2, problem_id: 6262, answer: nil, correct: nil, marked: nil, ever_marked: nil, strikes: [], postmortem: nil>, #<Question _id: 3, problem_id: 1369, answer: nil, correct: nil, marked: nil, ever_marked: nil, strikes: [], postmortem: nil>, #<Question _id: 4, problem_id: 8504, answer: nil, correct: nil, marked: nil, ever_marked: nil, strikes: [], postmortem: nil>, #<Question _id: 5, problem_id: 2146, answer: nil, correct: nil, marked: nil, ever_marked: nil, strikes: [], postmortem: nil>, #<Question _id: 6, problem_id: 318, answer: nil, correct: nil, marked: nil, ever_marked: nil, strikes: [], postmortem: nil>]
ruby-1.9.2-p0 > quiz.pages.first.questions.first
=> #<Question _id: 1, problem_id: 8577, answer: nil, correct: nil, marked: nil, ever_marked: nil, strikes: [], postmortem: nil>
ruby-1.9.2-p0 > quiz.pages.first.questions.first.page
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment