Permalink
Browse files

some work done

  • Loading branch information...
1 parent 0cc8095 commit 971fa118d7755d913106e8bb12629598dec95fc8 Student committed Sep 4, 2012
View
12 app/controllers/application_controller.rb
@@ -17,8 +17,18 @@ def load_topic
end
def enrolled_students
+ @students = Student.where(:current_courses == true)
+ end
+
+ def current_lights
@students = Student.where(:current_courses == true)
-
+ cl = []
+ @students.each do |student|
+ cl << student.current_light
+ end
+ puts cl
end
+
+
end
View
6 app/controllers/lights_controller.rb
@@ -42,7 +42,11 @@ def edit
# POST /lights.json
def create
# raise params.inspect
- @light = Light.new(params[:light])
+ @light = Light.new(params[:light])
+ s = @light.student
+ s.current_light = @light.color
+ s.save
+
respond_to do |format|
if @light.save
View
4 app/controllers/students_controller.rb
@@ -19,6 +19,10 @@ def show
@student = Student.find params[:student_id]
end
@light = Light.new(:topic_id => @topic.id, :student_id => current_student.id)
+
+ s = @light.student
+ s.current_light = @light.color
+ s.save
respond_to do |format|
format.html
format.json { render json: @student }
View
2 app/controllers/teachers_controller.rb
@@ -1,6 +1,7 @@
class TeachersController < ApplicationController
before_filter :enrolled_students
+ before_filter :current_lights
def index
@teachers = Teacher.all
@@ -15,6 +16,7 @@ def show
@teacher = Teacher.find(params[:id])
@course = Course.new
+
# @topics = (@teacher.courses[1]).topics
respond_to do |format|
format.html # show.html.erb
View
2 app/models/student.rb
@@ -1,7 +1,7 @@
class Student < ActiveRecord::Base
has_secure_password
- attr_accessible :email, :name, :password, :password_confirmation
+ attr_accessible :email, :name, :password, :password_confirmation, :current_light
validates_uniqueness_of :email
has_many :enrollments
View
40 app/views/teachers/show.html.erb
@@ -27,12 +27,44 @@
<% end %>
<% if t.current_topic == true %>
- <%= link_to "unselect", "#{niller_topic_url(t.id)}?teacher_id=#{@teacher.id}", :method => "put" %>
+ <br/>
+
+ <% red = 0 %>
+ <% green = 0 %>
+ <% blue = 0 %>
+ <% nilval = 0 %>
+ <% total_students = 0 %>
+
+ <% @students.each do |l| %>
+
+ <% if l.current_light = "red"%>
+ <% red += 1 %>
+ <% elsif l.current_light = "green"%>
+ <% green += 1 %>
+ <% elsif l.current_light = "blue"%>
+ <% blue += 1 %>
+ <% else %>
+ <% nilval += 1%>
+ <% end %>
+ <% end %>
+
+ <% total_students = red + green + blue + nilval %>
+
+ <% %>
+ Slow Down <%= image_tag("red.png", :size => "15x15") %>: <%= red/total_students*100 %>%<br/>
+ Perfect Pace <%= image_tag("green.png", :size => "15x15") %>: <%= green/total_students*100 %>%<br/>
+ Speed Up! <%= image_tag("blue.png", :size => "15x15") %>: <%= blue/total_students*100 %>%<br/>
+ No Response/Asleep: <%= nilval/total_students*100 %>%
+ <br/>
+
<% end %>
-
+
<br/>
- <% t.lights.each do |l| %>
- <%= image_tag("#{l.color}.png", :size => "20x20") %>
- <% end %>
+
+
+ <%# t.lights.each do |l| %>
+ <%#= image_tag("#{l.color}.png", :size => "20x20") %>
+ <%# end %>
</li>
<% end %>
</ol>
View
5 db/migrate/20120904170445_add_current_light_to_student.rb
@@ -0,0 +1,5 @@
+class AddCurrentLightToStudent < ActiveRecord::Migration
+ def change
+ add_column :students, :current_light, :string
+ end
+end
View
3 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120825225142) do
+ActiveRecord::Schema.define(:version => 20120904170445) do
create_table "courses", :force => true do |t|
t.string "title"
@@ -44,6 +44,7 @@
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "password_digest"
+ t.string "current_light"
end
create_table "teachers", :force => true do |t|

0 comments on commit 971fa11

Please sign in to comment.