diff --git a/features/step_definitions/teacher_view_average_grade.rb b/features/step_definitions/teacher_view_average_grade.rb new file mode 100644 index 0000000..4649bfe --- /dev/null +++ b/features/step_definitions/teacher_view_average_grade.rb @@ -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 diff --git a/features/teacher_can_view_average_grade.feature b/features/teacher_can_view_average_grade.feature new file mode 100644 index 0000000..9864f84 --- /dev/null +++ b/features/teacher_can_view_average_grade.feature @@ -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 diff --git a/lib/teacher.rb b/lib/teacher.rb index d68ffe9..f99eaff 100644 --- a/lib/teacher.rb +++ b/lib/teacher.rb @@ -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 \ No newline at end of file diff --git a/spec/teacher_spec.rb b/spec/teacher_spec.rb index 66894cc..7c9ee85 100644 --- a/spec/teacher_spec.rb +++ b/spec/teacher_spec.rb @@ -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 @@ -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 \ No newline at end of file