<commit_before>user_names = ['<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>']

team_names = ['Harm & Hammer', 'Abusement Park','Silver Woogidy Woogidy Woogidy Snakes','<NAME>','Eduception','Operation Unthinkable','Team Wang','The Carpal Tunnel Crusaders','Pwn Depot']

badge_names = ['Dream Interpreter', 'Inner Eye', 'Patronus Producer','Cheerful Charmer','Invisiblity Cloak','Marauders Map','Lumos','Rune Reader','Tea Leaf Guru','Wizard Chess Grand Master','Green Thumb','Gamekeeper','Seeker','Alchemist','Healer','Parseltongue','House Cup']

badge_icons = ['/badges/above_and_beyond.png','/badges/always_learning.png','/badges/awesome_aggregator.png','/badges/concentrator.png','/badges/courageous_failure.png','/badges/early_bird_special.png','/badges/examination_expert.png','/badges/gaining_experience.png','/badges/gamer.png','/badges/great_critic.png','/badges/learning_from_mistakes.png','/badges/level_one.png','/badges/participatory_democrat.png','/badges/personal.png','/badges/practice_makes_perfect.png','/badges/presentation_of_self.png','/badges/public_speaker.png']

# Use stock badge icons
badge_icon_paths = Dir.glob(Rails.root.join('test/support/assets/*'))

grade_scheme_hash = { [0,600000] => 'F', [600000,649000] => 'D+', [650000,699999] => 'C-', [700000,749999] => 'C', [750000,799999] => 'C+', [800000,849999] => 'B-', [850000,899999] => 'B', [900000,949999] => 'B+', [950000,999999] => 'A-', [1000000,1244999] => 'A', [1245000,1600000] => 'A+'}

majors = ['Obliviator','Knight Bus Driver','Magizoologist','Wandmaker','Mediwizard','Dragonologist','Floo Network Regulator','Curse-Breaker','Broom-maker','Arithmancer','Hit Wizard','Auror']

# Generate sample courses
course = Course.create! do |c|
  c.name = "Videogames & Learning"
  c.courseno = "ED222"
  c.year = Date.today.year
  c.semester = "Winter"
  c.total_assignment_weight = 6
  c.max_assignment_weight = 6
  c.default_assignment_weight = 1
  c.max_group_size = 5
  c.min_group_size = 2
  c.team_setting = true
  c.teams_visible = true
  c.group_setting = true
  c.badge_setting = true
  c.badge_use_scope = "Both"
  c.shared_badges = true
  c.badges_value = true
  c.accepts_submissions = true
  c.predictor_setting = true
  c.graph_display = true
  c.tagline = "You Game the Grade"
  c.academic_history_visible = true
  c.media_file = "http://www.youtube.com/watch?v=LOiQUo9nUFM&feature=youtu.be"
  c.media_credit = "<NAME>"
  c.media_caption = "The Greatest Wizard Ever Known"
  c.office = "Room 4121 SEB"
  c.phone = "734-644-3674"
  c.class_email = "<EMAIL>"
  c.twitter_handle = "barryfishman"
  c.twitter_hashtag = "EDUC222"
  c.location = "Whitney Auditorium, Room 1309 School of Education Building"
  c.office_hours = "Tuesdays, 1:30 pm – 3:30 pm"
  c.meeting_times = "Mondays and Wednesdays, 10:30 am – 12:00 noon"
  c.badge_term = "Achievement"
  c.user_term = "Learner"
  c.assignment_term = "Quest"
  c.group_term = "League"
  c.team_term = "Horde"
  c.team_challenges = true
  c.challenge_term = "Battle"
  c.grading_philosophy ="I believe a grading system should put the learner in control of their own destiny, promote autonomy, and reward effort and risk-taking. Whereas most grading systems start you off with 100% and then chips away at that “perfect grade” by averaging in each successive assignment, the grading system in this course starts everyone off at zero, and then gives you multiple ways to progress towards your goals. Different types of assignments are worth differing amounts of points. Some assignments are required of everyone, others are optional. Some assignments can only be done once, others can be repeated for more points. In most cases, the points you earn for an assignment are based on the quality of your work on that assignment. Do poor work, earn fewer points. Do high-quality work, earn more points. You decide what you want your grade to be. Learning in this class should be an active and engaged endeavor."
  c.media_file = "http://upload.wikimedia.org/wikipedia/commons/3/36/Michigan_Wolverines_Block_M.png"
end
puts "Videogames and Learning has been installed"

grade_scheme_hash.each do |range,letter|
  course.grade_scheme_elements.create do |e|
    e.letter = letter
    e.low_range = range.first
    e.high_range = range.last
  end
end
puts "Installed the N.E.W.T. grade scheme"


teams = team_names.map do |team_name|
  course.teams.create! do |t|
    t.name = team_name
  end
end
puts "The Team Competition has begun!"

# Generate sample students
students = user_names.map do |name|
  first_name, last_name = name.split(' ')
  username = name.parameterize.sub('-','.')
  User.create! do |u|
    u.username = username
    u.first_name = first_name
    u.last_name = last_name
    u.email = <EMAIL>"
    u.password = '<PASSWORD>'
    u.courses << course
    u.teams << teams.sample
  end
end
puts "Generated #{students.count} unruly students"

# Generate sample admin
User.create! do |u|
  u.username = 'albus'
  u.first_name = 'Albus'
  u.last_name = 'Dumbledore'
  u.role = 'admin'
  u.email = '<EMAIL>'
  u.password = '<PASSWORD>'
 u.courses << course
end
puts "<NAME> just apparated into Hogwarts"

# Generate sample professor
User.create! do |u|
  u.username = 'severus'
  u.first_name = 'Severus'
  u.last_name = 'Snape'
  u.role = 'professor'
  u.email = '<EMAIL>'
  u.password = '<PASSWORD>'
  u.courses << course
end
puts "<NAME> has been spotted in Slytherin House"

# Generate sample GSI
students << User.create! do |u|
  u.username = 'percy.weasley'
  u.first_name = 'Percy'
  u.last_name = 'Weasley'
  u.role = 'gsi'
  u.email = '<EMAIL>'
  u.password = '<PASSWORD>'
  u.courses << course
end
puts "<NAME> has arrived on campus, on time as usual"

#Create demo academic history content
students.each do |s|
  StudentAcademicHistory.create! do |ah|
    ah.student_id = s.id
    ah.major = majors.sample
    ah.gpa = [1.5, 2.0, 2.25, 2.5, 2.75, 3.0, 3.33, 3.5, 3.75, 4.0, 4.1].sample
    ah.current_term_credits = rand(12)
    ah.accumulated_credits = rand(40)
    ah.year_in_school = [1, 2, 3, 4, 5, 6, 7].sample
    ah.state_of_residence = "Michigan"
    ah.high_school = "Hogwarts School of Witchcraft & Wizardry"
    ah.athlete = [false, true].sample
    ah.act_score = 1 * rand(10)
    ah.sat_score = 100 * rand(10)
  end
end
puts "And gave students some background"

rubric = course.rubrics.create! do |r|
  r.name = "The Rubric"
  r.description = "Test Rubric"
end

criteria = 1.upto(3).map do |n|
  criteria = rubric.criteria.create! do |c|
    c.name = "Criterium #{n}"
    c.category = %w(Category1 Category2 Category3).sample
  end
end

criteria.each do |criterium|
  1.upto(3).each do |n|
    criterium.levels.create! do |l|
      l.name = "Level #{n}"
      l.value = 100 * n
    end
  end
end


badges = badge_names.map do |badge_name|
  course.badges.create! do |b|
    b.name = badge_name
    b.point_total = 100 * rand(10)
    b.icon = File.open(badge_icon_paths.sample)
    b.visible = 1
  end
end
puts "Did someone need motivation? We found these badges in the Room of Requirements..."

badges.each do |badge|
  students.each do |student|
    student.earned_badges.create! do |eb|
      eb.badge = badge
      eb.course = course
    end
  end
end
puts "Earned badges have been awarded"


assignment_types = {}

assignment_types[:attendance] = AssignmentType.create! do |at|
  at.course = course
  at.name = "Attendance"
  at.point_setting = "For All Assignments"
  at.points_predictor_display = "Slider"
  at.resubmission = false
  at.max_value = "120000"
  at.predictor_description = "We will work to build a learning community in EDUC 222, and I want this to be a great learning experience for all. To do this requires that you commit to the class and participate."
  at.universal_point_value = "5000"
  at.due_date_present = true
  at.order_placement = 1
  at.mass_grade = true
  at.mass_grade_type = "Checkbox"<commit_msg>Working sample data<commit_after>user_names = ['<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>','<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>', '<NAME>']

team_names = ['Harm & Hammer', 'Abusement Park','Silver Woogidy Woogidy Woogidy Snakes','<NAME>','Eduception','Operation Unthinkable','Team Wang','The Carpal Tunnel Crusaders','Pwn Depot']

badge_names = ['Dream Interpreter', 'Inner Eye', 'Patronus Producer','Cheerful Charmer','Invisiblity Cloak','Marauders Map','Lumos','Rune Reader','Tea Leaf Guru','Wizard Chess Grand Master','Green Thumb','Gamekeeper','Seeker','Alchemist','Healer','Parseltongue','House Cup']

badge_icons = ['/badges/above_and_beyond.png','/badges/always_learning.png','/badges/awesome_aggregator.png','/badges/concentrator.png','/badges/courageous_failure.png','/badges/early_bird_special.png','/badges/examination_expert.png','/badges/gaining_experience.png','/badges/gamer.png','/badges/great_critic.png','/badges/learning_from_mistakes.png','/badges/level_one.png','/badges/participatory_democrat.png','/badges/personal.png','/badges/practice_makes_perfect.png','/badges/presentation_of_self.png','/badges/public_speaker.png']

# Use stock badge icons
badge_icon_paths = Dir.glob(Rails.root.join('test/support/assets/*'))

grade_scheme_hash = { [0,600000] => 'F', [600000,649000] => 'D+', [650000,699999] => 'C-', [700000,749999] => 'C', [750000,799999] => 'C+', [800000,849999] => 'B-', [850000,899999] => 'B', [900000,949999] => 'B+', [950000,999999] => 'A-', [1000000,1244999] => 'A', [1245000,1600000] => 'A+'}

majors = ['Obliviator','Knight Bus Driver','Magizoologist','Wandmaker','Mediwizard','Dragonologist','Floo Network Regulator','Curse-Breaker','Broom-maker','Arithmancer','Hit Wizard','Auror']

# Generate sample courses
course = Course.create! do |c|
  c.name = "<NAME>"
  c.courseno = "ED222"
  c.year = Date.today.year
  c.semester = "Winter"
  c.total_assignment_weight = 6
  c.max_assignment_weight = 6
  c.default_assignment_weight = 1
  c.max_group_size = 5
  c.min_group_size = 2
  c.team_setting = true
  c.teams_visible = true
  c.group_setting = true
  c.badge_setting = true
  c.badge_use_scope = "Both"
  c.shared_badges = true
  c.badges_value = true
  c.accepts_submissions = true
  c.predictor_setting = true
  c.graph_display = true
  c.tagline = "You Game the Grade"
  c.academic_history_visible = true
  c.media_file = "http://www.youtube.com/watch?v=LOiQUo9nUFM&feature=youtu.be"
  c.media_credit = "Al<NAME>"
  c.media_caption = "The Greatest Wizard Ever Known"
  c.office = "Room 4121 SEB"
  c.phone = "734-644-3674"
  c.class_email = "<EMAIL>"
  c.twitter_handle = "barryfishman"
  c.twitter_hashtag = "EDUC222"
  c.location = "Whitney Auditorium, Room 1309 School of Education Building"
  c.office_hours = "Tuesdays, 1:30 pm – 3:30 pm"
  c.meeting_times = "Mondays and Wednesdays, 10:30 am – 12:00 noon"
  c.badge_term = "Achievement"
  c.user_term = "Learner"
  c.assignment_term = "Quest"
  c.group_term = "League"
  c.team_term = "Horde"
  c.team_challenges = true
  c.challenge_term = "Battle"
  c.grading_philosophy ="I believe a grading system should put the learner in control of their own destiny, promote autonomy, and reward effort and risk-taking. Whereas most grading systems start you off with 100% and then chips away at that “perfect grade” by averaging in each successive assignment, the grading system in this course starts everyone off at zero, and then gives you multiple ways to progress towards your goals. Different types of assignments are worth differing amounts of points. Some assignments are required of everyone, others are optional. Some assignments can only be done once, others can be repeated for more points. In most cases, the points you earn for an assignment are based on the quality of your work on that assignment. Do poor work, earn fewer points. Do high-quality work, earn more points. You decide what you want your grade to be. Learning in this class should be an active and engaged endeavor."
  c.media_file = "http://upload.wikimedia.org/wikipedia/commons/3/36/Michigan_Wolverines_Block_M.png"
end
puts "Videogames and Learning has been installed"

grade_scheme_hash.each do |range,letter|
  course.grade_scheme_elements.create do |e|
    e.letter = letter
    e.low_range = range.first
    e.high_range = range.last
  end
end
puts "Installed the N.E.W.T. grade scheme"


teams = team_names.map do |team_name|
  course.teams.create! do |t|
    t.name = team_name
  end
end
puts "The Team Competition has begun!"

# Generate sample students
students = user_names.map do |name|
  first_name, last_name = name.split(' ')
  username = name.parameterize.sub('-','.')
  User.create! do |u|
    u.username = username
    u.first_name = first_name
    u.last_name = last_name
    u.email = <EMAIL>"
    u.password = '<PASSWORD>'
    u.courses << course
    u.teams << teams.sample
  end
end
puts "Generated #{students.count} unruly students"

# Generate sample admin
User.create! do |u|
  u.username = 'albus'
  u.first_name = 'Albus'
  u.last_name = 'Dumbledore'
  u.role = 'admin'
  u.email = '<EMAIL>'
  u.password = '<PASSWORD>'
 u.courses << course
end
puts "<NAME> just apparated into Hogwarts"

# Generate sample professor
User.create! do |u|
  u.username = 'severus'
  u.first_name = 'Severus'
  u.last_name = 'Snape'
  u.role = 'professor'
  u.email = '<EMAIL>'
  u.password = '<PASSWORD>'
  u.courses << course
end
puts "<NAME> has been spotted in Slytherin House"

# Generate sample GSI
students << User.create! do |u|
  u.username = 'percy.weasley'
  u.first_name = 'Percy'
  u.last_name = 'Weasley'
  u.role = 'gsi'
  u.email = '<EMAIL>'
  u.password = '<PASSWORD>'
  u.courses << course
end
puts "<NAME> has arrived on campus, on time as usual"

#Create demo academic history content
students.each do |s|
  StudentAcademicHistory.create! do |ah|
    ah.student_id = s.id
    ah.major = majors.sample
    ah.gpa = [1.5, 2.0, 2.25, 2.5, 2.75, 3.0, 3.33, 3.5, 3.75, 4.0, 4.1].sample
    ah.current_term_credits = rand(12)
    ah.accumulated_credits = rand(40)
    ah.year_in_school = [1, 2, 3, 4, 5, 6, 7].sample
    ah.state_of_residence = "Michigan"
    ah.high_school = "Hogwarts School of Witchcraft & Wizardry"
    ah.athlete = [false, true].sample
    ah.act_score = 1 * rand(10)
    ah.sat_score = 100 * rand(10)
  end
end
puts "And gave students some background"

rubric = course.rubrics.create! do |r|
  r.name = "The Rubric"
  r.description = "Test Rubric"
end

criteria = 1.upto(3).map do |n|
  criteria = rubric.criteria.create! do |c|
    c.name = "Criterium #{n}"
    c.category = %w(Category1 Category2 Category3).sample
  end
end

criteria.each do |criterium|
  1.upto(3).each do |n|
    criterium.levels.create! do |l|
      l.name = "Level #{n}"
      l.value = 100 * n
    end
  end
end


badges = badge_names.map do |badge_name|
  course.badges.create! do |b|
    b.name = badge_name
    b.point_total = 100 * rand(10)
    b.visible = 1
  end
end
puts "Did someone need motivation? We found these badges in the Room of Requirements..."

badges.each do |badge|
  students.each do |student|
    student.earned_badges.create! do |eb|
      eb.badge = badge
      eb.course = course
    end
  end
end
puts "Earned badges have been awarded"


assignment_types = {}

assignment_types[:attendance] = AssignmentType.create! do |at|
  at.course = course
  at.name = "Attendance"
  at.point_setting = "For All Assignments"
  at.points_predictor_display = "Slider"
  at.resubmission = false
  at.max_value = "120000"
  at.predictor_description = "We will work to build a learning community in EDUC 222, and I want this to be a great learning experience for all. To do this requires that you commit to the class and participate."
  at.universal_point_value = "5000"
  at.due_date_present = true
  at.order_placement = 1
  at.mass_grade = true
  at.mass_grade_type = "Checkbox"
{'fraction_non_alphanumeric': 0.15065515367429502, 'fraction_numerical': 0.030916007487470563, 'mean_word_length': 4.303234069804675, 'pattern_counts': {'":': 0, '<': 150, '<?xml version=': 0, '>': 148, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5123061', 'n_tokens_mistral': 6352, 'n_tokens_neox': 5944, 'n_words': 1554}