Skip to content

Commit

Permalink
Learning Targets -> Concepts. Closes #65. Closes #67.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachlatta committed Oct 5, 2013
1 parent d30ddf8 commit f439866
Show file tree
Hide file tree
Showing 45 changed files with 217 additions and 181 deletions.
Binary file modified app/assets/images/logo_large.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/assets/images/logo_large@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
Binary file modified app/assets/stylesheets/output.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/units.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

.lt-heading{
.concept-heading{
line-height: 200%;
}
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
class LearningTargetsController < ApplicationController
class ConceptsController < ApplicationController
def new
@lt = LearningTarget.new
@concept = Concept.new
end

def create
@lt = current_unit.learning_targets.build(lt_params)
if @lt.save
@concept = current_unit.concepts.build(concept_params)
if @concept.save
redirect_to root_path
end
end

def show
@lt = LearningTarget.find(params[:id])
@concept = Concept.find(params[:id])
end

def lt_params
params.require(:learning_target).permit(:description)
def concept_params
params.require(:concept).permit(:description)
end

def new_progress
enrollment = Enrollment.where("student_id = ? AND course_id = ?",
current_student.id, @lt.unit.course.id).first
current_student.id, @concept.unit.course.id).first

progress = LearningTargetProgress.new(enrollment_id: enrollment.id,
learning_target_id: @lt.id)
concept_id: @concept.id)

redirect_to @lt if progress.save
redirect_to @concept if progress.save
end

def modify_level
@lt = LearningTarget.find(params[:lt_id])
@concept = Concept.find(params[:concept_id])

if student_signed_in?

enrollment = Enrollment.where("student_id = ? AND course_id = ?",
current_student.id, @lt.unit.course.id).first
current_student.id, @concept.unit.course.id).first

progress = LearningTargetProgress.where("learning_target_id = ? AND
progress = LearningTargetProgress.where("concept_id= ? AND
enrollment_id = ?",
@lt.id,enrollment.id).first
@concept.id,enrollment.id).first

comment = Comment.create(content: params[:comment],
commenter_name: current_student.full_name)

elsif teacher_signed_in?

enrollment = Enrollment.where("student_id = ? AND course_id = ?",
params[:student_id], @lt.unit.course.id).first
params[:student_id], @concept.unit.course.id).first

progress = LearningTargetProgress.where("learning_target_id = ? AND
progress = LearningTargetProgress.where("concept_id= ? AND
enrollment_id = ?",
@lt.id,enrollment.id).first
@concept.id,enrollment.id).first

comment = Comment.create(content: params[:comment],
commenter_name: current_teacher.full_name)
Expand All @@ -59,7 +59,7 @@ def modify_level
progress.add_comment(comment)
progress.change_level(params[:level])

redirect_to @lt if progress.save
redirect_to @concept if progress.save
end

helper_method :new_progress
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/units_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def show
@unit = Unit.find(params[:id])
end

def add_lt
@lt = LearningTarget.new(unit_id: params[:current_unit], description: params[:lt_desc], number: params[:lt_number])
def add_concept
@concept = Concept.new(unit_id: params[:current_unit], description: params[:concept_desc], number: params[:concept_number])

@lt.save
@concept.save

redirect_to unit_path(params[:current_unit])
end
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/concepts_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ConceptsHelper
end
2 changes: 0 additions & 2 deletions app/helpers/learning_targets_helper.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/learning_target.rb → app/models/concept.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class LearningTarget < ActiveRecord::Base
class Concept < ActiveRecord::Base

belongs_to :unit
has_many :learning_target_progresses, dependent: :destroy
Expand Down
2 changes: 1 addition & 1 deletion app/models/learning_target_progress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LearningTargetProgress < ActiveRecord::Base
after_initialize :init

belongs_to :enrollment
belongs_to :learning_target
belongs_to :concept
has_many :comments

validates_presence_of :level
Expand Down
2 changes: 1 addition & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Task < ActiveRecord::Base

belongs_to :learning_target
belongs_to :concept

validates_presence_of :status, :content
end
2 changes: 1 addition & 1 deletion app/models/unit.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Unit < ActiveRecord::Base

belongs_to :course
has_many :learning_targets
has_many :concepts

validates_presence_of :name, :number
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_tag learning_targets_modify_level_path, id:"levelForm",
<%= form_tag concepts_modify_level_path, id:"levelForm",
method: 'post' do%>
<fieldset>
<div class="form-group">
Expand All @@ -10,7 +10,7 @@
<%= select_tag :level,
options_for_select([1,2,3,4]),
class: "form-control" %>
<%= hidden_field_tag 'lt_id', params[:id] %>
<%= hidden_field_tag 'concept_id', params[:id] %>
<%= hidden_field_tag 'student_id', params[:student_id]%>
</div>
<%= button_tag "Change Level",
Expand All @@ -30,4 +30,4 @@ $('#levelButton').click(function() {
$('#levelForm').submit();
}
});
</script>
</script>
File renamed without changes.
21 changes: 21 additions & 0 deletions app/views/concepts/_student_progress.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<tr>
<% if current_student.current_progress(@concept.unit.course).nil? %>
<% new_progress %>
<% else %>
<td><%= current_student.current_progress(@concept.unit.course).level%></td>
<td>
<%= current_student.current_progress(@concept.unit.course).comments.last.content if !current_student.current_progress(@concept.unit.course).comments.last.nil? %>
</td>
<td>
<%= current_student.current_progress(@concept.unit.course).
comments.last.commenter_name if !current_student.current_progress(
@concept.unit.course).comments.last.nil? %>
</td>
<% end %>
<td>
<%= link_to "Change Level", '#levelModal',
:class => "btn btn-primary btn-sm changebutton",
:data => { :toggle => "modal" },
:id => current_student.id %>
</td>
</tr>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<th>Commented By</th>
<th>Level Up?</th>
</tr>
<% if @lt.unit.course.enrollments.empty? %>
<% if @concept.unit.course.enrollments.empty? %>

<div class="no-courses text-center">
There are currently no students enrolled.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% @lt.unit.course.enrollments.each do |e| %>
<% @concept.unit.course.enrollments.each do |e| %>
<% e.learning_target_progresses.each do |p| %>
<tr id=<%= e.student.id %> >
<td><%= e.student.full_name %></td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<% provide(:title, "LT #{ @lt.number }") %>
<% provide(:title, "Concept #{ @concept.number }") %>
<%= render 'modify_level_modal' %>

<div class="page-header">
<dl>
<dt><h1><%= "Learning Target #{ @lt.number }" %></h1></dt>
<dd><%= @lt.description %></dd>
<dt><h1><%= "Concept #{ @concept.number }" %></h1></dt>
<dd><%= @concept.description %></dd>
</dl>
</div>

Expand Down
21 changes: 0 additions & 21 deletions app/views/learning_targets/_student_progress.html.erb

This file was deleted.

19 changes: 19 additions & 0 deletions app/views/teachers/_concept_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%= form_tag units_add_concept_path, method: 'post' do %>
<fieldset>
<div class="form-group">
<%= label_tag :concept_number %>
<%= text_field_tag :concept_number, nil,
class: "form-control",
placeholder: "Concept Number"%><br>

<%= label_tag :concept_description %>
<%= text_area_tag :concept_desc, nil,
class: "form-control",
rows: "5",
placeholder: "Concept Description" %><br>
<%= hidden_field_tag :current_unit, @unit.id %>

</div>
<%= submit_tag "Add Concept", class: "btn btn-default" %>
</fieldset>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="modal fade" id="ltModal">
<div class="modal fade" id="conceptModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Create Your Learning Target</h4>
<h4 class="modal-title">Create Concept</h4>
</div>
<div class="modal-body">
<%= render 'teachers/lt_form' %>
<%= render 'teachers/concept_form' %>
</div>
</div>
</div>
</div>
</div>
19 changes: 0 additions & 19 deletions app/views/teachers/_lt_form.html.erb

This file was deleted.

25 changes: 25 additions & 0 deletions app/views/units/_concept_list.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div class="panel">
<div class="panel-heading concept-heading clearfix">Concepts
<% if teacher_signed_in? %>
<a data-toggle="modal" href="#conceptModal">
<button type="button" class="btn btn-default btn-sm pull-right">
New Concept
</button>
</a>
<% end %>
</div>
<table class="table" data-provides="rowlink">
<tr>
<th>Concept</th>
<th>Description</th>
<th>View more</th>
</tr>
<% @unit.concepts.each do |concept| %>
<tr>
<td><%= concept.number %></td>
<td><%= concept.description %></td>
<td><%= link_to "View more", concept %></td>
</tr>
<% end %>
</table>
</div>
23 changes: 0 additions & 23 deletions app/views/units/_learning_target_list.html.erb

This file was deleted.

2 changes: 1 addition & 1 deletion app/views/units/_student_view.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render 'learning_target_list' %>
<%= render 'concept_list' %>
22 changes: 13 additions & 9 deletions app/views/units/_teacher_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<div class="tab-pane active fade in" id="<%= @unit.name %>" >
<% if @unit.learning_targets.first.nil? %>
<div class="tab-pane active fade in" id="<%= @unit.name %>">

<% if @unit.concepts.first.nil? %>

<div class="tab-content">
<div class="no-courses text-center">
Would you like to <a data-toggle="modal" href="#ltModal">add a learning target</a> for <%= @unit.name %>?
Would you like to <a data-toggle="modal" href="#conceptModal">add a
concept</a> for <%= @unit.name %>?
</div>
</div>
<% else %>

<% else %>

<div class="tab-content">
<%= render 'learning_target_list' %>
<%= render 'concept_list' %>
</div>

<% end %>

<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/units/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% provide(:title, @unit.name) %>
<%= render 'teachers/lt_modal' %>
<%= render 'teachers/concept_modal' %>

<div class="page-header">
<h1><%= "Unit #{ @unit.number } - #{ @unit.name }" %></h1>
Expand Down

0 comments on commit f439866

Please sign in to comment.