Permalink
Browse files

Added basic student attendance reports

  • Loading branch information...
1 parent 19903b2 commit 5be8c7d7a6afc77050811e753a169ca51f80d849 @dbc-apprentice dbc-apprentice committed Nov 18, 2012
@@ -80,4 +80,8 @@ body {
th.grade{
font-color :black;
background-color: gray;
+}
+
+#student_reports_table {
+ width: 50ex;
}
@@ -10,6 +10,13 @@ def create
end
end
+ def show
+ @start_date = "2012-09-01".to_date
+ @student = Student.find(params[:id])
+ @attendances = @student.attendances
+ end
+
+
def update
Attendance.find(params[:id]).update_attributes(params[:attendance])
@attendance = Attendance.find(params[:id])
View
@@ -4,8 +4,11 @@ class Attendance < ActiveRecord::Base
belongs_to :session
before_create :log_status
+ delegate :date, to: :session
+
scope :on_time, where("status = ?", 'On time')
scope :late, where("status = ?", 'Late')
+ scope :by_date, order("created_at desc")
def log_status
if (Time.zone.now - self.session.start_time) > 5.minutes
View
@@ -64,4 +64,11 @@ def create_current_assignments
student_assignments.create(assignment_id: assignment.id) if assignment.due_date > Time.zone.now.to_date
end
end
+
+ def on_time_percentage
+ end
+
+ def overall_attendance_percentage
+ end
+
end
@@ -0,0 +1,32 @@
+%div
+ %h3
+ = full_name(@student)
+ %h4
+ = "Overall Ontime Percentage: #{@student.overall_assignment_completion_percentage}%"
+ %h4
+ = "Overall Attendance Percentage: #{@student.assignment_completion_percentage_today}"
+ %br
+ %table.table.table-striped{ :cellpadding => "3", :cellspacing => "2" }
+
+ %tr
+ %th Date
+ %th Status
+ - report_date = Time.zone.now.to_date
+ - i = 0
+ - while report_date != @start_date
+ %tr
+ %td
+ = report_date
+ %td
+ - if !@attendances[i].nil? && @attendances[i].date == report_date
+ - if @attendances[i].status == "On time"
+ %span.label.label-success
+ = @attendances[i].status
+ - if @attendances[i].status == "Late"
+ %span.label.label-important
+ = @attendances[i].status
+ - i += 1
+ - else
+ %span.label
+ Absent
+ - report_date -= 1
@@ -5,11 +5,16 @@
%thead
%tr
%th Student
+ %th
%tbody
- StudentReportsHelper.alphabetize_by_last_name(@students).each do |student|
%tr
%th
- = link_to "#{student.first_name} #{student.last_name}", student_report_path(student)
+ = "#{student.first_name} #{student.last_name}"
+ %th
+ = link_to "Assignments", student_report_path(student), class: "btn btn-success btn-small"
+ %th
+ = link_to "Attendance", attendance_path(student.id), class: "btn btn-warning btn-small"
/ %th
/ %span.label.label-success
/ =link_to "Export Report"
View
@@ -4,7 +4,7 @@
devise_for :admins
- resources :attendances, except: [:new, :edit, :index, :show]
+ resources :attendances, except: [:new, :edit, :index]
resources :students, only: [:show, :update]
resources :student_assignments, only: [:update, :destroy]

0 comments on commit 5be8c7d

Please sign in to comment.