Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
Conflicts:
	Gemfile.lock
	db/migrate/20141130031816_remove_type_error.rb
	db/schema.rb
  • Loading branch information
grahamcracker committed Feb 19, 2015
1 parent c18fee3 commit ac54b2c
Show file tree
Hide file tree
Showing 46 changed files with 345 additions and 217 deletions.
1 change: 1 addition & 0 deletions .capistrano/metrics
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
full
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ gem "friendly_id", ">=5.0.0"
# Active admin for admin panel
gem "activeadmin", github: "gregbell/active_admin"

gem 'react-rails', :git => '[email protected]:grahamcracker/react-rails.git', :branch => '0.12'
# react for rails
gem 'react-rails', '~> 1.0.0.pre', github: 'reactjs/react-rails'

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
Expand Down
27 changes: 13 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/gregbell/active_admin.git
revision: 41043fa9aecc47f04eefc6322eea89a7bd4b0876
revision: 3f916d6bee73393e379aa57aa4b46b0baf803b9e
specs:
activeadmin (1.0.0.pre)
arbre (~> 1.0, >= 1.0.2)
Expand All @@ -17,15 +17,15 @@ GIT
sass-rails

GIT
remote: [email protected]:grahamcracker/react-rails.git
revision: 359cfbb7479ef1e5627561297e0dfaa991a8c679
branch: 0.12
remote: git://github.com/reactjs/react-rails.git
revision: d0d62c5dd35108e258b8e50d749499269997186d
specs:
react-rails (1.0.0.pre)
coffee-script-source (= 1.8.0)
connection_pool
execjs
rails (>= 3.1)
react-source (= 0.12)
react-source (~> 0.12)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -105,7 +105,7 @@ GEM
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.9.0)
coffee-script-source (1.8.0)
colorize (0.7.5)
compass (1.0.3)
chunky_png (~> 1.2)
Expand Down Expand Up @@ -136,8 +136,8 @@ GEM
warden (~> 1.2.3)
diff-lcs (1.2.5)
erubis (2.7.0)
eventmachine (1.0.6)
excon (0.44.1)
eventmachine (1.0.7)
excon (0.44.2)
execjs (2.3.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
Expand All @@ -154,7 +154,7 @@ GEM
activerecord (>= 4.0.0)
globalid (0.3.2)
activesupport (>= 4.1.0)
has_scope (0.6.0.rc)
has_scope (0.6.0)
actionpack (>= 3.2, < 5)
activesupport (>= 3.2, < 5)
hike (1.2.3)
Expand All @@ -178,7 +178,7 @@ GEM
railties (>= 3.2.16)
json (1.8.2)
jwt (1.2.1)
kaminari (0.16.2)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
loofah (2.0.1)
Expand Down Expand Up @@ -206,7 +206,7 @@ GEM
multi_xml (~> 0.5)
rack (~> 1.2)
orm_adapter (0.5.0)
passenger (4.0.58)
passenger (4.0.59)
daemon_controller (>= 1.2.0)
rack
rake (>= 0.8.1)
Expand Down Expand Up @@ -255,8 +255,7 @@ GEM
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rdoc (4.2.0)
json (~> 1.4)
react-source (0.12.0)
react-source (0.12.2)
responders (2.1.0)
railties (>= 4.2.0, < 5)
rspec-core (3.2.0)
Expand Down Expand Up @@ -361,7 +360,7 @@ DEPENDENCIES
pickadate-rails
rails (= 4.2.0)
rails_config
react-rails!
react-rails (~> 1.0.0.pre)!
rspec-rails
sass-rails
sdoc
Expand Down
17 changes: 17 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ $("document").ready(function(){

});

/*
disable file uploads until file selected
*/
$upload_input = $("#document_file");
$upload_button = $("#document_file_button");

$upload_button.attr('disabled',true);
$upload_input.change(
function(){
if ($(this).val()){
$upload_button.removeAttr('disabled');
}
else {
$upload_button.attr('disabled',true);
}
});

/*
slide reveal
*/
Expand Down
37 changes: 21 additions & 16 deletions app/assets/javascripts/grades.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
$(document).ready(function(){

$(".grade-update").on("click", function(){

$(".grade-update").on("click", function() {
var $parent = $(this).parent().parent();
var points = parseFloat($parent.find("input.points").val());

// perform the grade update operation
var assignment_id = $parent.data("assignment-id");
var user_id = $parent.data("user-id");
var comments = $parent.find("textarea.comments").val();
var points = parseFloat($parent.find("input.points").val());
if(!$.isNumeric(points)){
alert("Point value must be a number!");
}else{
var form_data = new FormData();
form_data.append('assignment_id', $parent.data("assignment-id"));
form_data.append('user_id', $parent.data("user-id"));
form_data.append('comments', $parent.find("textarea.comments").val());
form_data.append('points', points);

jQuery.each($('.documents-uploader')[0].files, function(i, file) {
form_data.append('documents[document][]', file);
});

if ($.isNumeric(points)) {
// premptively show the user a success message
$parent.children("h6.green").show();
$parent.children("h6.yellow").hide();

$.ajax({ type: "POST", url: window.location, data: {
points: points,
comments: comments,
assignment_id: assignment_id,
user_id: user_id
}});

$.ajax({
type: "POST",
processData: false,
contentType: false,
url: window.location,
data: form_data
});
} else {
alert("Point value must be a number!");
}
});

Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/assignments.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ section.course h4.under-back-button{
button{
@extend .button;
}
span.assignment-controls{
display:inline-block;
margin-left: .5em;
}

div.assignment-form-container{
width: 75%;
Expand Down
7 changes: 6 additions & 1 deletion app/assets/stylesheets/courses.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ span.instructing{

}

div.instructor-edit-notify{
@include panel($padding: .5em);
text-align: center;
}

section.course {
@include grid-row();
Expand Down Expand Up @@ -118,6 +122,7 @@ section.course {
@media #{$medium} {@include grid-column(12);}
p.description{
color: $grey-text-color;
white-space: pre-wrap;
}
h2, h3{
margin-top: 0em;
Expand Down Expand Up @@ -398,4 +403,4 @@ div.manage{
color: #fff;
}
}
}
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ div.main-content{
.page-header-container {
background-color: $topbar-bg-color;
padding: 1rem 0;
margin-bottom: 2rem;
margin-bottom: 1rem;
@media #{$medium}{padding: 2rem 0;}
}

Expand Down
10 changes: 10 additions & 0 deletions app/assets/stylesheets/grades.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ h6.yellow{
h6.green{
color: green;
}

@for $i from 1 through 100 {
.grade-coloring-#{$i} {
@if $i < 40 { color: red; }
@else if $i < 66 { color: darken(red, 10%); }
@else if $i < 80 { color: darken(red, 20%); }
@else if $i < 90 { color: blue; }
@else { color: green; }
}
}
8 changes: 3 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class ApplicationController < ActionController::Base
protected

def configure_permitted_parameters

# place permitted fields for registration here
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:name, :email, :password, :password_confirmation)
Expand All @@ -26,7 +25,6 @@ def configure_permitted_parameters
devise_parameter_sanitizer.for(:account_update) do |u|
u.permit(:name, :email, :password, :password_confirmation, :current_password)
end

end

def get_course
Expand Down Expand Up @@ -110,9 +108,9 @@ def hide_sidebar

def process_multiple_documents(container)
if params[:documents]
params[:documents][:document].each { |doc|
container.documents.create(file: doc)
}
params[:documents][:document].each do |doc|
container.documents.build(file: doc)
end
end
end

Expand Down
2 changes: 0 additions & 2 deletions app/controllers/assignment_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ class AssignmentTypesController < ApplicationController
before_filter :authenticate_user!, :get_course, :hide_sidebar

def index

@current_types = @course.assignment_types

if request.xhr?
render json: @current_types
end

end

def create
Expand Down
13 changes: 5 additions & 8 deletions app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ def edit

def show
@submissions = @assignment.submissions.where(user_id: current_user.id).order("created_at DESC")
@grade = @assignment.grades.where(user_id: current_user.id).last
end

def create

authorize! :manage, @course

@assignment = @course.assignments.new(assignment_params)
process_multiple_documents(@assignment)

if @assignment.valid?
@assignment.save
process_multiple_documents(@assignment)
if @assignment.save
send_assignment_email(@course, @assignment)
flash[:success] = "The assignment was created!"
redirect_to course_assignments_path(@course)
Expand All @@ -42,7 +41,6 @@ def create
end

def update

authorize! :manage, @course

if @assignment.update_attributes(assignment_params)
Expand All @@ -51,7 +49,6 @@ def update
end

redirect_to edit_course_assignment_path(@course, @assignment)

end

def destroy
Expand All @@ -61,14 +58,14 @@ def destroy
redirect_to course_assignments_path(@course)
end

private
private

def assignment_params
params.require(:assignment).permit(:name, :description, :assignment_type_id, :points, :documents, :reveal_day, :due_day)
end

def send_assignment_email(course, assignment)
if(params[:send_email])
if params[:send_email]
UserMailer.new_assignment(course, assignment).deliver_now
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def create
@course = current_user.instructed_courses.build(course_params)
authorize! :create, @course
if @course.save
@first_type = @course.assignment_types.new(name: 'Assignment', drops_lowest: false, default_point_value: 100)
@first_type.save
flash[:success] = "Course created!"
redirect_to @course
else
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ def destroy
@document = Document.find(params[:id])
authorize! :delete, @document
name = @document[:file]
assignment = @document.assignment ? @document.assignment : nil
@document.destroy
flash[:success] = "#{name} was deleted!"
if assignment
redirect_to edit_course_assignment_path(assignment.course, assignment)
if @document.assignment
redirect_to edit_course_assignment_path(@document.assignment.course, @document.assignment)
elsif @document.grade
redirect_to course_assignment_grades_path(@document.grade.assignment.course, @document.grade.assignment)
else
redirect_to course_manage_path(@document.course)
end
Expand All @@ -55,16 +56,15 @@ def get_owners

private
def get_container
# TODO: these should be changed to the correct hash to reveal on redirect
if @lecture
@container = @lecture
@redirect = course_capsule_lecture_path(@course, @capsule, @lecture)
@redirect = course_manage_path(@lecture.capsule.course)
elsif @capsule
@container = @capsule
@redirect = course_capsule_path(@course, @capsule)
@redirect = course_manage_path(@capsule.course)
elsif @course
@container = @course
@redirect = course_path(@course)
@redirect = course_manage_path(@course)
end
end

Expand Down
Loading

0 comments on commit ac54b2c

Please sign in to comment.