Created
July 30, 2018 08:39
-
-
Save faizaankhan/73a11956c8e350aefb6123edc8e19d51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faker' | |
qp = QuestionPaper.new | |
qp.name = "QP-Test-React-Exam" | |
qp.save | |
4.times do | |
s = qp.sections.new | |
s.name = Faker::GameOfThrones.city | |
s.save | |
c = Category.new | |
c.name = Faker::GameOfThrones.house | |
c.description = Faker::Lorem.paragraph(2) | |
c.save | |
60.times do | |
q = Question.new | |
q.category_id = c.id | |
q.text = Faker::GameOfThrones.quote | |
q.save | |
4.times do | |
a = q.answers.new | |
a.text = Faker::GameOfThrones.character | |
a.correct_answer = false | |
a.save | |
end | |
q.answers.last.update_attribute(:correct_answer, true) | |
qpq = qp.question_papers_questions.new | |
qpq.question_id = q.id | |
qpq.section_id = s.id | |
qpq.save | |
end | |
end |
require 'csv'
file = "#{Rails.root}/public/data.csv"
CSV.open( file, 'w') do | csv |
csv << ["Sl No", "Name", "Email Id"]
Candidate.where(created_at: Date.new(2018,8,7)..Time.zone.today).find_each(:batch_size => 500).with_index do |candidate, index|
csv << [index + 1, candidate.name, candidate.email]
end
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
qp.save
4.times do
s = qp.sections.new
s.name = Faker::GameOfThrones.city
s.save
c = Category.new
c.name = Faker::GameOfThrones.house
c.description = Faker::Lorem.paragraph(2)
c.save
60.times do
q = Question.new
q.category_id = c.id
q.text = Faker::GameOfThrones.quote
q.save
end
end