Permalink
Browse files

lates changes

  • Loading branch information...
1 parent 8a56ee0 commit cef621909484b144e2bf37601a492cf830acefd7 @ghaydarov ghaydarov committed Aug 29, 2012
@@ -1,27 +1,20 @@
class ApplicationController < ActionController::Base
- protect_from_forgery
- private
+
+ protect_from_forgery
- def current_student
- @current_student ||= Student.find(session[:student_id]) if session[:student_id]
- end
-
- helper_method :current_student
-
- def authorize
- redirect_to login_url, alert: "Not authorized" if current_student.nil?
- end
+private
+ def current_student
+ @current_student ||= Student.find(session[:student_id]) if session[:student_id]
+ end
+ helper_method :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
+ 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
@@ -3,37 +3,28 @@ class StudentsController < ApplicationController
before_filter :authorize, only: [:show]
before_filter :load_topic
- before_filter :load_signals
-
-
- # GET /students
- # GET /students.json
def index
@students = Student.all
-
+
respond_to do |format|
format.html # index.html.erb
format.json { render json: @students }
end
end
- # GET /students/1
- # GET /students/1.json
def show
if params[:id].nil?
- @student = current_student
+ @student = current_student
else
- @student = Student.find params[:id]
+ @student = Student.find params[:id]
end
-
+ @light = Light.new(:topic_id => @topic.id, :student_id => current_student.id)
respond_to do |format|
- format.html # show.html.erb
+ format.html
format.json { render json: @student }
end
end
- # GET /students/new
- # GET /students/new.json
def new
@student = Student.new
@@ -43,20 +34,14 @@ def new
end
end
- # GET /students/1/edit
def edit
@student = Student.find(params[:id])
end
-
- # POST /students
- # POST /students.json
def create
@student = Student.new(params[:student])
-
respond_to do |format|
if @student.save
session[:student_id] = @student.id
-
redirect_to root_url, notice: "Thank you for signing up!"
else
format.html { render action: "new" }
@@ -72,8 +72,6 @@ def update
end
end
- # DELETE /teachers/1
- # DELETE /teachers/1.json
def destroy
@teacher = Teacher.find(params[:id])
@teacher.destroy
@@ -1,18 +1,13 @@
class TopicsController < ApplicationController
- # GET /topics
- # GET /topics.json
-
def index
@topics = Topic.all
respond_to do |format|
- format.html # index.html.erb
+ format.html
format.json { render json: @topics }
end
end
- # GET /topics/1
- # GET /topics/1.json
def show
@topic = Topic.find(params[:id])
@@ -22,8 +17,6 @@ def show
end
end
- # GET /topics/new
- # GET /topics/new.json
def new
@topic = Topic.new
@@ -33,13 +26,10 @@ def new
end
end
- # GET /topics/1/edit
def edit
@topic = Topic.find(params[:id])
end
- # POST /topics
- # POST /topics.json
def create
@topic = Topic.new(params[:topic])
@@ -54,8 +44,6 @@ def create
end
end
- # PUT /topics/1
- # PUT /topics/1.json
def update
@topic = Topic.find(params[:id])
Topic.where(:current_topic => true).each do |topic|
@@ -69,8 +57,6 @@ def update
end
- # DELETE /topics/1
- # DELETE /topics/1.json
def destroy
@topic = Topic.find(params[:id])
@topic.destroy
View
@@ -17,7 +17,6 @@ def current_topics
def being_taught?
current_topics.present?
-
end
end
@@ -26,7 +26,7 @@
</div>
<div class="container-fluid">
- <%= yield %>
+ <%= yield %>
</div>
</body>
</html>
@@ -1,19 +1,14 @@
- <div class="row-fluid">
- <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 %>
-
-
+<div class="row-fluid">
+ <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 %>
+<% end %>
+
<p>Please use buttons below to let your teacher know your pace</p>
<%= form_for(@light) do |f| %>
@@ -38,10 +33,4 @@
<%= f.submit :type => :image, :src => "/assets/blue.png" %>
<% end %>
-
- <% end %>
- </p>
<%= "You are not logged into any courses yet!" if @student.current_courses.empty? %>
-
-
-
@@ -14,9 +14,6 @@
<p>
<b>Courses Taught:</b>
-
-
-
<ol>
<% @teacher.courses.each do |c| %>
View
@@ -4,6 +4,10 @@
# Examples:
#
+student = Student.create([{ name: "John Doe", email: "johndoe@gmail.com", password: "12345", password_confirmation: "12345"}])
+student = Student.create([{ name: "Steve Coyle", email: "csteve@gmail.com"}])
+
+
course = Course.create([{ title: 'History of USA', section: 'M-F', teacher_id: 1 }])
course = Course.create([{ title: 'History of India', section: 'M-F', teacher_id: 1 }])
course = Course.create([{ title: 'History of Turkmenistan', section: 'M-F', teacher_id: 1 }])

0 comments on commit cef6219

Please sign in to comment.