Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Converted to Rails 2.3.5 (finally)

  • Loading branch information...
commit 363109f75f304bee6738d28cfb06bedc99923c0a 1 parent 3e31e0d
@rnhurt authored
View
0  app/controllers/application.rb → app/controllers/application_controller.rb
File renamed without changes
View
45 app/models/course_term.rb
@@ -18,27 +18,42 @@ class CourseTerm < ActiveRecord::Base
delegate :grading_scale, :to => :course
delegate :students, :to => :course
+ named_scope :active, :include => :term,
+ :conditions => ["date_ranges.active = ?", true]
+
+ named_scope :sorted, :order => "date_ranges.end_date ASC"
+
# Calculate a students current grade for a particular course & term.
def calculate_grade(student_id)
# Set up some variables
- points_earned = 0.0
- possible_points = 0.0
-
- # Loop through the assignments for computing the grade as we go
- self.assignment_evaluations.all(:conditions => { :student_id => student_id}).each do |evaluation|
- valid_points = evaluation.points_earned_as_number
- if valid_points
- points_earned += valid_points.to_f
- possible_points += evaluation.assignment.possible_points.to_f
+ points_earned = 0.0
+ possible_points = 0.0
+
+ cached_points = Rails.cache.read("#{self.id}|#{student_id}")
+
+ # FIXME: I'm not sure this is what I want here.
+ if !cached_points
+
+ # Loop through the assignments for computing the grade as we go
+ self.assignment_evaluations.all(:conditions => { :student_id => student_id}).each do |evaluation|
+ valid_points = evaluation.points_earned_as_number
+ if valid_points
+ points_earned += valid_points.to_f
+ possible_points += evaluation.assignment.possible_points.to_f
+ end
+ logger.debug " **** points earned: #{valid_points} out of #{evaluation.assignment.possible_points}"
end
- logger.debug " **** points earned: #{valid_points} out of #{evaluation.assignment.possible_points}"
- end
- logger.debug " **** final! #{points_earned} out of #{possible_points}"
- # Sanitize the score & grade so that we don't try to divide by zero or anything stupid
- final_score = possible_points > 0 ? ((points_earned/possible_points)*100).round(2) : -1
- letter_grade = final_score > 0 ? self.course.grading_scale.calculate_letter_grade(final_score) : 'n/a'
+ logger.debug " **** final! #{points_earned} out of #{possible_points}"
+ # Sanitize the score & grade so that we don't try to divide by zero or anything stupid
+ final_score = possible_points > 0 ? ((points_earned/possible_points)*100).round(2) : -1
+ Rails.cache.write("#{self.id}|#{student_id}", final_score)
+ else
+ final_score = cached_points
+ end
+
+ letter_grade = final_score > 0 ? self.course.grading_scale.calculate_letter_grade(final_score) : 'n/a'
return {:letter => letter_grade, :score => final_score }
end
View
14 config/boot.rb
@@ -24,9 +24,8 @@ def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
- # FIXME : Ruby 1.9
def preinitialize
- load(preinitializer_path) if File.exists?(preinitializer_path)
+ load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
@@ -44,6 +43,7 @@ def run
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+ Rails::Initializer.run(:install_gem_spec_stubs)
end
end
@@ -67,7 +67,7 @@ def load_rails_gem
class << self
def rubygems_version
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
+ Gem::RubyGemsVersion rescue nil
end
def gem_version
@@ -82,14 +82,14 @@ def gem_version
def load_rubygems
require 'rubygems'
-
- unless rubygems_version >= '0.9.4'
- $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
+ min_version = '1.3.1'
+ unless rubygems_version >= min_version
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
- $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
View
2  config/environment.rb
@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.2.3' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
View
3  script/dbconsole
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../config/boot'
+require 'commands/dbconsole'
Please sign in to comment.
Something went wrong with that request. Please try again.