Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing files from previous version
- Loading branch information
Showing
12 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require 'common/workflow' | ||
|
||
class LearningsController < ApplicationController | ||
|
||
include Ptls::Workflow | ||
|
||
before_filter :expose_subject_from_unit, :only => [:new, :create] | ||
before_filter :expose_subject_from_learning, :only => [:edit, :update, :review] | ||
|
||
make_resourceful do | ||
|
||
belongs_to :unit, :subject | ||
actions :edit, :update, :new, :create, :today, :review | ||
|
||
response_for :create, :defer do |wants| | ||
wants.html { redirect_to_next_learning } | ||
end | ||
|
||
response_for :today_complete do |wants| | ||
wants.html do | ||
flash[:notice] = "You've finished going through today's new material" | ||
redirect_to subject_path(@subject) | ||
end | ||
end | ||
end | ||
|
||
def new | ||
@learning = current_user.learnings.new(:unit => @unit) | ||
end | ||
|
||
def create | ||
@learning = current_user.learnings.create(object_parameters) | ||
@learning.deferred? ? response_for(:defer) : response_for(:create) | ||
end | ||
|
||
def review | ||
current_object.update_attributes(object_parameters) | ||
redirect_to today_subject_learnings_path(@subject, :page => (params[:page].to_i + 1)) | ||
end | ||
|
||
# Iterate through today's newly learned items | ||
def today | ||
@learnings = current_user.learnings_for(@subject).paginate(:select => 'learnings.*', :page => params[:page], :per_page => 1) | ||
response_for(@learnings.empty? ? :today_complete : :today) | ||
end | ||
|
||
private | ||
|
||
def parent_object | ||
@parent_object ||= | ||
parent_model == Subject ? | ||
parent_model.find_by_permalink(params["#{parent_name}_id"]) : | ||
parent_model.find(params["#{parent_name}_id"]) | ||
end | ||
|
||
def expose_subject_from_learning | ||
@subject = current_object.subject | ||
end | ||
|
||
def expose_subject_from_unit | ||
@subject = parent_object.subject | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require 'common/workflow' | ||
|
||
class ReviewsController < ApplicationController | ||
|
||
include Ptls::Workflow | ||
|
||
before_filter :expose_subject_from_review, :only => [:edit, :update, :review] | ||
|
||
include ActionView::Helpers::UrlHelper | ||
|
||
make_resourceful do | ||
|
||
belongs_to :subject | ||
|
||
actions :edit, :update, :missed, :shift | ||
|
||
response_for :update do |wants| | ||
wants.html { redirect_to_next_review } | ||
end | ||
|
||
response_for :missed_complete do |wants| | ||
wants.html do | ||
flash[:notice] = "You've finished going through the reviews that you missed during today's review cycle. " + | ||
"<a href=\"#{missed_subject_reviews_path(@subject)}\">Click here</a> if you would like to do so again." | ||
redirect_to subject_path(@subject) | ||
end | ||
end | ||
|
||
response_for :shift do |wants| | ||
wants.html do | ||
flash[:notice] = "Your reviews have been successfully shifted." | ||
redirect_to subjects_path | ||
end | ||
end | ||
end | ||
|
||
def review | ||
current_object.update_attributes(object_parameters) | ||
redirect_to missed_subject_reviews_path(@subject, :page => (params[:page].to_i + 1)) | ||
end | ||
|
||
# Iterate through reviews that were missed during today's review cycle | ||
def missed | ||
@reviews = current_user.missed(@subject).paginate(:select => 'reviews.*', :page => params[:page], :per_page => 1) | ||
response_for(@reviews.empty? ? :missed_complete : :missed) | ||
end | ||
|
||
def shift | ||
current_user.shift_reviews | ||
response_for :shift | ||
end | ||
|
||
# Need to get subject by permalink | ||
def parent_object | ||
@parent_object ||= parent_model.find_by_permalink(params["#{parent_name}_id"]) | ||
end | ||
|
||
private | ||
|
||
def expose_subject_from_review | ||
@subject = current_object.subject | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#association | ||
- if association.new_record? | ||
= render :partial => '/associations/edit', :locals => { :association => association } | ||
- else | ||
= render :partial => '/associations/show', :locals => { :association => association } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- remote_form_for association do |f| | ||
= f.hidden_field :unit_id | ||
= f.text_field :body, :class => :field | ||
= image_submit_tag 'set_hint.png', :class => :button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
%p | ||
= link_to_remote h(association.body), :url => edit_association_path(association), :method => :get, :html => { :key => 'a', :id => 'edit_hint' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
- expanded = false if not defined?(expanded) | ||
|
||
#question_wrapper | ||
%em#progress | ||
= progress | ||
.clear | ||
#question | ||
%p#question_content= render :partial => 'units/show_question', :locals => { :unit => unit } | ||
.clear | ||
#hint{:class => (expanded ? 'expanded' : 'collapsed')} | ||
= hint_bar_for(unit) | ||
.clear | ||
- if current_user.owns?(@subject) | ||
%span#owner_actions | ||
= link_to image_tag('delete_faded.png'), unit_path(unit), :method => :delete, :confirm => "Are you sure you want to delete this item AND all the progress made in relation to it?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- content_for :callout do | ||
|
||
#todays_progress | ||
%h3 Todays highlights | ||
%p.highlight | ||
= todays_review_callout(@subject) | ||
= review_shift_callout | ||
%p.highlight= todays_learning_callout(@subject) | ||
%a.swap{:href => '#overall_progress', :from => '#todays_progress'} see overall highlights | ||
.clear | ||
|
||
#overall_progress.hidden | ||
%h3 Overall highlights | ||
- if current_user.started?(@subject) | ||
%p.highlight= subject_progress(@subject) | ||
- if current_user.reviewing_yet?(@subject) | ||
%p.highlight= subject_retention(@subject) | ||
%a.swap{:href => '#todays_progress', :from => '#overall_progress'} see today's highlights | ||
.clear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- content_for :instructions do | ||
%p | ||
Please both review already learned material and learn new material on a | ||
daily basis. This repetition ensures long term memory retention. | ||
%p | ||
You can always change the number of items you learn per day by adjusting | ||
your | ||
%a{:href => edit_user_path(current_user)} account settings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- remote_form_for unit do |f| | ||
= f.text_field :answer, :class => :field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- remote_form_for unit do |f| | ||
= f.text_field :question, :class => :field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- if current_user.owns?(@subject) | ||
= link_to_remote unit.answer, :url => edit_answer_unit_path(unit), :method => :get, :html => { :id => 'unit_answer' } | ||
- else | ||
= unit.answer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- if current_user.owns?(@subject) | ||
= link_to_remote unit.question, :url => edit_question_unit_path(unit), :method => :get, :html => { :id => 'unit_question' } | ||
- else | ||
= unit.question |