Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions features/step_definitions/teacher_view_average_grade.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Given /^I add all the grades in one class$/ do
class_grade = record_grade(student, grade)(n+1) #Not sure how to write a block that keeps adding a students until you run out of students
end

Given /^the total number of students is added together$/ do
class_total = studets(1..n) #unsure how to add all the students together
end

When /^there is a cummulative class grade and a total number of students$/ do
class_grade = class_grade
class_total = class_total
end

Then /^the I can get the class average by dividing the class grade by number of students$/ do
class_average = class_grade / class_total
end
11 changes: 11 additions & 0 deletions features/teacher_can_view_average_grade.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Feature: Teacher can view average grade

As a teacher
I can view the average grade of the class
So I can see how we're doing as a whole

Scenario: Teacher can view average grade
Given I add all the grades in one class
And the total number if students is added together
When there is a cummulative class grade and a total number of students
Then the I can get the class average by dividing the class grade by number of students
19 changes: 19 additions & 0 deletions lib/teacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,23 @@ def submit_assignment(student, assignment)
def assignment_for_student(student)
@assignments[student]
end

end

class AverageGrade
def initialize(average_grade, class_total, class_grade)
@average_grade = average_grade
@class_total = class_total
@class_grade = class_grade
end

def average
(class_grade / class_total)
end

def class
@class_total = @student * 20
@class_grade = @student.grade * 20
end

end
7 changes: 6 additions & 1 deletion spec/teacher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
subject.assignment_for_student(student).should eq(assignment)
end


describe "should record a grade" do
it "should record the grade" do
student = stub
Expand All @@ -20,3 +19,9 @@
end
end
end

describe AverageGrade do
it "should view average grade for the class" do
AverageGrade.new.average.should eq(class_grade/class_total)
end
end