Permalink
Browse files

done alot of stuff

  • Loading branch information...
1 parent 70d2941 commit c66542cfac6e15fd8f3152eb5bff7d43128b58b7 @ghaydarov ghaydarov committed Aug 29, 2012
@@ -1,69 +0,0 @@
-body {
- background-color: #fff;
- color: #333;
- font-family: verdana, arial, helvetica, sans-serif;
- font-size: 13px;
- line-height: 18px;
-}
-
-p, ol, ul, td {
- font-family: verdana, arial, helvetica, sans-serif;
- font-size: 13px;
- line-height: 18px;
-}
-
-pre {
- background-color: #eee;
- padding: 10px;
- font-size: 11px;
-}
-
-a {
- color: #000;
- &:visited {
- color: #666;
- }
- &:hover {
- color: #fff;
- background-color: #000;
- }
-}
-
-div {
- &.field, &.actions {
- margin-bottom: 10px;
- }
-}
-
-#notice {
- color: green;
-}
-
-.field_with_errors {
- padding: 2px;
- background-color: red;
- display: table;
-}
-
-#error_explanation {
- width: 450px;
- border: 2px solid red;
- padding: 7px;
- padding-bottom: 0;
- margin-bottom: 20px;
- background-color: #f0f0f0;
- h2 {
- text-align: left;
- font-weight: bold;
- padding: 5px 5px 5px 15px;
- font-size: 12px;
- margin: -7px;
- margin-bottom: 0px;
- background-color: #c00;
- color: #fff;
- }
- ul li {
- font-size: 12px;
- list-style: square;
- }
-}
@@ -1,3 +1,3 @@
-// Place all the styles related to the courses controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
+.span6{
+ margin-top: 30px;
+}
@@ -11,5 +11,17 @@ def current_student
def authorize
redirect_to login_url, alert: "Not authorized" if current_student.nil?
end
+
+
+
+private
+def load_topic
+ @topic = Topic.where(:current_topic => true).first
+end
+
+private
+def load_signals
+ @light = Light.new(:topic_id => @topic.id, :student_id => current_student.id)
+end
end
@@ -1,5 +1,6 @@
class LightsController < ApplicationController
before_filter :authorize, only: [:edit, :update]
+ before_filter :load_topic, only: :new
# GET /lights
# GET /lights.json
@@ -25,7 +26,7 @@ def show
# GET /lights/new
# GET /lights/new.json
def new
- @light = Light.new
+ @light = Light.new(:topic_id => @topic.id, :student_id => current_student.id)
respond_to do |format|
format.html # new.html.erb
format.json { render json: @light }
@@ -40,11 +41,12 @@ def edit
# POST /lights
# POST /lights.json
def create
- @light = Light.new(params[:light])
+ # raise params.inspect
+ @light = Light.new(params[:light])
respond_to do |format|
if @light.save
- format.html { redirect_to @light, notice: 'Light was successfully created.' }
+ format.html { redirect_to :action=>"show", :controller=>"students" }
format.json { render json: @light, status: :created, location: @light }
else
format.html { render action: "new" }
@@ -1,6 +1,9 @@
class StudentsController < ApplicationController
before_filter :authorize, only: [:show]
+ before_filter :load_topic
+
+ before_filter :load_signals
# GET /students
@@ -22,6 +25,7 @@ def show
else
@student = Student.find params[:id]
end
+
respond_to do |format|
format.html # show.html.erb
format.json { render json: @student }
@@ -88,4 +92,7 @@ def destroy
format.json { head :no_content }
end
end
+
+
+
end
View
@@ -5,4 +5,19 @@ class Course < ActiveRecord::Base
has_many :students, :through => :enrollments
has_many :topics
# has_many :lights, :through => :topics
+
+
+ def current_topics
+ current = []
+ topics.each do |topic|
+ current << topic if topic.current_topic == true
+ end
+ current
+ end
+
+ def being_taught?
+ current_topics.present?
+
+ end
+
end
View
@@ -1,6 +1,12 @@
class Light < ActiveRecord::Base
+
attr_accessible :color, :topic_id, :student_id, :enrollment_id
+
+
belongs_to :topic
belongs_to :student
belongs_to :enrollments
+
+
+
end
View
@@ -8,4 +8,13 @@ class Student < ActiveRecord::Base
has_many :courses, :through => :enrollments
has_many :topics, :through => :courses
has_many :lights, :through => :topics
+
+ def current_courses
+ current = []
+ courses.each do |course|
+ current << course if course.being_taught?
+ end
+ current
+ end
+
end
View
@@ -2,6 +2,9 @@ class Topic < ActiveRecord::Base
attr_accessible :course_id, :name, :current_topic
belongs_to :course
has_many :lights
-
-end
+ def active_courses
+ Topic.course_topic == true
+ end
+
+end
@@ -12,9 +12,8 @@
<div class="navbar-inner">
<%= link_to "Learning Signal", root_url, :class => "brand"%>
<ul class="nav">
- <li class="active"><a href="#">Home</a></li>
- <li><a href="/lights/new?student_id=1&topic_id=1">Signals</a></li>
- <li><a href="/teachers/1">test teacher</a></li>
+ <li class="active"><a href="/">Home</a></li>
+ <li><a href="/teachers">Teacher Page</a></li>
<% if current_student %>
<li><a>Logged in as <%= current_student.email %> </a> </li><li><%= link_to "Log Out", logout_path %></li>
@@ -1,5 +1,23 @@
<h1>How is it going?</h1>
-<%= link_to image_tag("red.png"), lights_url(:light => {:color => "red", :topic_id => params[:topic_id], :enrollment_id => params[:enrollment_id], :student_id => params[:student_id] }), :method => 'post' %><br/>
-<%= link_to image_tag("green.png"), lights_url(:light => {:color => "green", :topic_id => params[:topic_id]}), :method => 'post' %><br/>
-<%= link_to image_tag("blue.png"), lights_url(:light => {:color => "blue", :topic_id => params[:topic_id]}), :method => 'post' %><br/>
+<%= form_for(@light) do |f| %>
+ <%= f.hidden_field :topic_id %>
+ <%= f.hidden_field :color, :value => 'red' %>
+ <%= f.hidden_field :student_id %>
+ <%= f.submit :type => :image, :src => "/assets/red.png" %>
+<% end %>
+
+<%= form_for(@light) do |f| %>
+ <%= f.hidden_field :topic_id %>
+ <%= f.hidden_field :color, :value => 'green' %>
+ <%= f.hidden_field :student_id %>
+ <%= f.submit :type => :image, :src => "/assets/green.png" %>
+<% end %>
+
+
+<%= form_for(@light) do |f| %>
+ <%= f.hidden_field :topic_id %>
+ <%= f.hidden_field :color, :value => 'blue' %>
+ <%= f.hidden_field :student_id %>
+ <%= f.submit :type => :image, :src => "/assets/blue.png" %>
+<% end %>
@@ -1,35 +1,47 @@
<div class="row-fluid">
- <div class="span4">
- <h3>My Profile</h3>
- <p>
- <b>Name:</b>
- <%= @student.name %>
- </p>
-
- <p>
- <b>Email:</b>
- <%= @student.email %>
- </p>
- <%= link_to 'Edit your profile', edit_student_path(@student) %>
- <p>
- <h3>Courses Enrolled In:</h3>
- <% @student.enrollments.each do |e| %>
- <ul>
- <li><%= e.course.title %></li>
- <% e.lights.each do |l| %>
- <%= image_tag l.color + '.png', size: '20x20' %>
+ <div class="span6">
+
+
+ <p>Hi <%= @student.email %></p>
+
+ <% @student.current_courses.each do |course| %>
+ <p>You are currently in
+
+ <b><%= course.title %></b> Course.
+ <p>Now current topic is
+ <% course.current_topics.each do |t| %>
+ <b><%= t.name %></b>
<% end %>
- </ul>
- <% end %>
- </p>
+
+ <p>Please use buttons below to let your teacher know your pace</p>
- </div>
- <div class="span8">
- <p id="notice"><%= notice %></p>
+ <%= form_for(@light) do |f| %>
+ <%= f.hidden_field :topic_id %>
+ <%= f.hidden_field :color, :value => 'red' %>
+ <%= f.hidden_field :student_id %>
+ <%= f.submit :type => :image, :src => "/assets/red.png", size: "30x30" %>
+ <% end %>
- </div>
- </div>
+ <%= form_for(@light) do |f| %>
+ <%= f.hidden_field :topic_id %>
+ <%= f.hidden_field :color, :value => 'green' %>
+ <%= f.hidden_field :student_id %>
+ <%= f.submit :type => :image, :src => "/assets/green.png" %>
+ <% end %>
+ <%= form_for(@light) do |f| %>
+ <%= f.hidden_field :topic_id %>
+ <%= f.hidden_field :color, :value => 'blue' %>
+ <%= f.hidden_field :student_id %>
+ <%= f.submit :type => :image, :src => "/assets/blue.png" %>
+ <% end %>
+
+
+ <% end %>
+ </p>
+ <%= "You are not logged into any courses yet!" if @student.current_courses.empty? %>
+
+

0 comments on commit c66542c

Please sign in to comment.