Skip to content

Commit

Permalink
Merge pull request MarkUsProject#709 from tobioboye/issue_669_final
Browse files Browse the repository at this point in the history
Issue 669 final
  • Loading branch information
tobioboye committed Mar 31, 2012
2 parents b78f8d7 + 614c2c8 commit d1e15e8
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 167 deletions.
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -12,7 +12,6 @@ source 'http://rubygems.org'
gem "rails"
gem 'exception_notification'
#gem "prototype-rails" Will be needed with Rails3.1
gem "db_populate"
gem "rubyzip"
gem "ya2yaml"
gem "i18n"
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Expand Up @@ -39,7 +39,6 @@ GEM
cgi_multipart_eof_fix (2.5.0)
columnize (0.3.4)
daemons (1.1.4)
db_populate (0.2.6)
dynamic_form (1.1.4)
erubis (2.6.6)
abstract (>= 1.0.0)
Expand Down Expand Up @@ -120,7 +119,6 @@ PLATFORMS
ruby

DEPENDENCIES
db_populate
dynamic_form
exception_notification
faker
Expand Down
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -4,7 +4,6 @@
require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rdoc/task'
require 'db_populate'

# TODO REMOVE THIS FIX WITH RAKE 0.9:0
module ::Markus
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions db/populate/students.csv → db/data/students.csv
Expand Up @@ -214,3 +214,4 @@ c7arnold,Arnold,Malcolm
g5ligeti,Ligeti,Gyorgy
c8menott,Menotti,Gian Carlo
c6stockh,Stockhausen,Karlheinz

6 changes: 0 additions & 6 deletions db/populate/01_admins.rb

This file was deleted.

6 changes: 0 additions & 6 deletions db/populate/02_students.rb

This file was deleted.

9 changes: 0 additions & 9 deletions db/populate/03_tas.rb

This file was deleted.

41 changes: 0 additions & 41 deletions db/populate/04_assignments.rb

This file was deleted.

20 changes: 0 additions & 20 deletions db/populate/05_groups.rb

This file was deleted.

26 changes: 0 additions & 26 deletions db/populate/06_repos.rb

This file was deleted.

23 changes: 0 additions & 23 deletions db/populate/07_criterias.rb

This file was deleted.

23 changes: 0 additions & 23 deletions db/populate/08_annotations.rb

This file was deleted.

152 changes: 152 additions & 0 deletions db/seeds.rb
@@ -0,0 +1,152 @@
# Standard admin
Admin.create(:user_name => 'a', :first_name => 'admin', :last_name => 'admin')

# Reid
Admin.create(:user_name => 'reid', :first_name => 'Karen', :last_name => 'Reid')

STUDENT_CSV = 'db/data/students.csv'

if File.readable?(STUDENT_CSV)
csv_students = File.new(STUDENT_CSV)
User.upload_user_list(Student, csv_students, nil)
end
Ta.create(:user_name => 'c6conley',
:first_name => 'Mike',
:last_name => 'Conley')
Ta.create(:user_name => 'c6gehwol',
:first_name => 'Severin',
:last_name => 'Gehwolf')
Ta.create(:user_name => 'c9varoqu',
:first_name => 'Nelle',
:last_name => 'Varoquaux')
# Assignments
assignment_stat = AssignmentStat.new
rule = NoLateSubmissionRule.new
a = Assignment.create(:short_identifier => "A1",
:description => "Conditionals and Loops",
:message => "Learn to use conditional statements, and loops.",
:group_min => 1,
:group_max => 1,
:student_form_groups => false,
:group_name_autogenerated => true,
:group_name_displayed => false,
:repository_folder => "A1",
:due_date => 1.minute.from_now,
:marking_scheme_type => Assignment::MARKING_SCHEME_TYPE[:rubric],
:allow_web_submits => true,
:display_grader_names_to_students => false)

a.submission_rule = rule
a.assignment_stat = assignment_stat
a.save

rule = NoLateSubmissionRule.new
assignment_stat = AssignmentStat.new
a = Assignment.create(:short_identifier => "A2",
:description => "Cats and Dogs",
:message => "Basic exercise in Object Oriented
Programming. Implement Animal, Cat, and Dog, as
described in class.",
:group_min => 2,
:group_max => 3,
:student_form_groups => true,
:group_name_autogenerated => true,
:group_name_displayed => false,
:repository_folder => "A2",
:due_date => 1.month.from_now,
:marking_scheme_type => Assignment::MARKING_SCHEME_TYPE[:rubric],
:allow_web_submits => true,
:display_grader_names_to_students => false)
a.submission_rule = rule
a.assignment_stat = assignment_stat
a.save
# Let's create groups and groupings !

students = Student.all
a = Assignment.find_by_short_identifier("A1")

15.times do |time|
student = students[time]
group = Group.new
group.group_name = student.user_name
group.save
grouping = Grouping.new
grouping.group = group
grouping.assignment = a
grouping.save
grouping.invite([student.user_name],
StudentMembership::STATUSES[:inviter],
invoked_by_admin=true)
end


# Let's populate students repository with nice data

groups = Group.all
assignment = Assignment.find_by_short_identifier("A1")

file_dir = File.join(File.dirname(__FILE__), 'data')
groups.each do |group|
Dir.foreach(file_dir) do |filename|
unless File.directory?(File.join(file_dir, filename))
file_contents = File.open(File.join(file_dir, filename))
file_contents.rewind
group.access_repo do |repo|
txn = repo.get_transaction(group.grouping_for_assignment(
assignment.id
).inviter.user_name)
path = File.join(assignment.repository_folder,
filename)
txn.add(path,
file_contents.read,
'')
repo.commit(txn)
end
end
end
end

require 'faker'

8.times do |time|
rc = RubricCriterion.create(
:id => time,
:rubric_criterion_name => Faker::Lorem.sentence(1),
:assignment_id => 1,
:position => 1,
:weight => rand(3) + 1,
:level_0_name => Faker::Lorem.words(rand(5) + 1).join(" "),
:level_0_description => Faker::Lorem.sentences(rand(5) + 1).join(" "),
:level_1_name => Faker::Lorem.words(rand(5) + 1).join(" "),
:level_1_description => Faker::Lorem.sentences(rand(5) + 1).join(" "),
:level_2_name => Faker::Lorem.words(rand(5) + 1).join(" "),
:level_2_description => Faker::Lorem.sentences(rand(5) + 1).join(" "),
:level_3_name => Faker::Lorem.words(rand(5) + 1).join(" "),
:level_3_description => Faker::Lorem.sentences(rand(5) + 1).join(" "),
:level_4_name => Faker::Lorem.words(rand(5) + 1).join(" "),
:level_4_description => Faker::Lorem.sentences(rand(5) + 1).join(" ")
)
rc.save
end

5.times do |time|
ca = AnnotationCategory.new(
:id => time,
:assignment_id => 1,
:annotation_category_name => Faker::Lorem.words(
rand(3) + 1
).join(" ")
)
ca.save

(rand(10) + 3).times do |t|
a = AnnotationText.new(
:id => t,
:annotation_category_id => time,
:content => Faker::Lorem.sentences(rand(3) + 1).join(" ")
)
a.save
end
end


4 changes: 2 additions & 2 deletions lib/tasks/markus_general.rake
@@ -1,6 +1,6 @@
namespace :markus do

desc "Resets a MarkUs installation. Useful for developers. This is just a rake repos:drop && rake db:reset && rake db:populate"
desc "Resets a MarkUs installation. Useful for developers. This is just a rake repos:drop && rake db:reset && rake db:seed"
task(:reset => :environment) do
if ENV['environment'].nil?
::Rails.env = 'development'
Expand All @@ -11,7 +11,7 @@ namespace :markus do
Rake::Task['repos:drop'].invoke # drop repositories
Rake::Task['db:reset'].invoke # reset the DB
sleep(2) # need to sleep a little, otherwise the reset doesn't seem to work
Rake::Task['db:populate'].invoke # repopulate DB
Rake::Task['db:seed'].invoke # repopulate DB
puts("Resetting development environment of MarkUs finished!")
end

Expand Down
10 changes: 5 additions & 5 deletions lib/tasks/populate.rake
Expand Up @@ -38,21 +38,21 @@ namespace :markus do
end

desc "Add more student users to the database"
# this task depends on :environment and :populate
task(:add_students => [:environment, :"db:populate"]) do
# this task depends on :environment and :seed
task(:add_students => [:environment, :"db:seed"]) do
puts "Populate database with some additional students"
STUDENT_CSV = File.expand_path(File.join(__FILE__, '..', '..', '..', 'test', 'classlist-csvs', 'new_students.csv'))
if File.readable?(STUDENT_CSV)
csv_students = File.new(STUDENT_CSV)
User.upload_user_list(Student, csv_students.read)
User.upload_user_list(Student, csv_students.read, nil)
else
$stderr.puts "File not found or not readable: #{STUDENT_CSV}"
end
end

desc "Create a setup for usability testing."
# this task depends on :environment and :populate
task(:usability_test_setup => [:environment, :"db:populate"]) do
# this task depends on :environment and :seed
task(:usability_test_setup => [:environment, :"db:seed"]) do
puts "Creating a setup for usability testing"
# modify settings for A1 (solo assignment)
a1 = Assignment.find_by_short_identifier("A1")
Expand Down

0 comments on commit d1e15e8

Please sign in to comment.