forked from autolab/Autolab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:daviddob/Autolab
- Loading branch information
Showing
61 changed files
with
1,162 additions
and
103 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 |
---|---|---|
@@ -1,24 +1,49 @@ | ||
// Initialize all Bootstrap 3 Datetime Pickers on the page | ||
// Initialize all Flatpicker Datetime Pickers on the page | ||
;(function() { | ||
|
||
$(document).ready(function() { | ||
var datetimeElts = $('.datetimepicker'); | ||
|
||
for (var i = 0; i < datetimeElts.length; i++) { | ||
var defaultDate = new Date(moment()) | ||
if ($(datetimeElts[i]).val()) { | ||
defaultDate = new Date(moment($(datetimeElts[i]).val())) | ||
} | ||
|
||
$(datetimeElts[i]).flatpickr({ | ||
enableTime: true, | ||
altInput: true, | ||
defaultDate: new Date(datetimeElts[i].getAttribute("value")) | ||
defaultDate: defaultDate | ||
}) | ||
} | ||
|
||
var dateElts = $('.datepicker'); | ||
|
||
for (var i = 0; i < dateElts.length; i++) { | ||
var defaultDate = new Date(moment()) | ||
if ($(dateElts[i]).val()) { | ||
defaultDate = new Date(moment($(dateElts[i]).val()).format("MMMM D YYYY")) | ||
} | ||
|
||
$(dateElts[i]).flatpickr({ | ||
altInput: true, | ||
defaultDate: moment($(dateElts[i]).val()).format("MMMM D YYYY") | ||
defaultDate: defaultDate | ||
}) | ||
} | ||
|
||
|
||
var timeElements = $('.timepicker'); | ||
for (var i = 0; i < timeElements.length; i++) { | ||
$(timeElements[i]).flatpickr({ | ||
enableTime: true, | ||
noCalendar: true, | ||
enableSeconds: false, | ||
time_24hr: true, | ||
defaultHour: 12, | ||
defaultMinute: 0, | ||
defaultDate: "12:00" | ||
}); | ||
} | ||
}); | ||
|
||
})(); |
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,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
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,3 @@ | ||
// Place all the styles related to the sections controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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
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
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
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
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 @@ | ||
class SectionUserDataController < ApplicationController | ||
|
||
|
||
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,101 @@ | ||
class SectionsController < ApplicationController | ||
|
||
@@days_lookup = {"0" => '2016-05-01',"1" => '2016-05-02',"2" => '2016-05-03',"3" => '2016-05-04',"4" => '2016-05-05',"5" => '2016-05-06',"6" => '2016-05-07'} | ||
def index | ||
end | ||
|
||
action_auth_level :show, :instructor | ||
def show | ||
|
||
end | ||
action_auth_level :users, :instructor | ||
def users | ||
|
||
end | ||
|
||
def create | ||
# check for permission | ||
unless current_user.instructor? | ||
flash[:error] = "Permission denied." | ||
redirect_to(course_assessments_path) && return | ||
end | ||
|
||
data = params["sections"] | ||
|
||
# basic data verifcation | ||
if data['name'] == "" | ||
flash[:error] = "please provide a valid name" | ||
redirect_to(course_sections_path) && return | ||
end | ||
if data['day'] == "" | ||
flash[:error] = "please provide a valid day" | ||
redirect_to(course_sections_path) && return | ||
end | ||
|
||
if data["start time"] >= data["end time"] | ||
flash[:error] = "please make sure the end time is after the start time" | ||
redirect_to(course_sections_path) && return | ||
end | ||
|
||
|
||
# see if we want to delete the record | ||
if(params["commit"] == "Delete") | ||
delete | ||
return | ||
end | ||
|
||
# see if we want to edit an existing record | ||
@old_section = Sections.where("course_id = ? && name = ?", @course.id, data["name"]) | ||
if(@old_section.exists?) | ||
edit | ||
return | ||
end | ||
|
||
# we must want to create one then so do it | ||
|
||
@new_section = Sections.new | ||
@new_section.name = data["name"] | ||
@new_section.course_id = @course.id | ||
@new_section.start = @@days_lookup[data["day"]] + " " + data["start time"] + ":00" | ||
@new_section.end = @@days_lookup[data["day"]] + " " + data["end time"] + ":00" | ||
@new_section.save | ||
|
||
flash[:success] = "saved" | ||
redirect_to(course_sections_path) && return | ||
end | ||
|
||
def manage | ||
end | ||
|
||
def edit | ||
data = params["sections"] | ||
@old_section = @old_section.first | ||
@old_section.start = @@days_lookup[data["day"]] + " " + data["start time"] + ":00" | ||
@old_section.end = @@days_lookup[data["day"]] + " " + data["end time"] + ":00" | ||
@old_section.save | ||
flash[:success] = "edit complete" | ||
redirect_to(course_sections_path) && return | ||
end | ||
|
||
|
||
def delete | ||
data = params["sections"] | ||
Sections.where("course_id = ? && name = ?", @course.id, data["name"]).first.destroy | ||
flash[:success] = "deletion complete" | ||
redirect_to(course_sections_path) && return | ||
end | ||
|
||
action_auth_level :editusers, :instructor | ||
def editusers | ||
user = CourseUserDatum.find(params['id']) | ||
|
||
if params['lecture'] | ||
user.lecture = params["sectionName"] | ||
else | ||
user.section = params["sectionName"] | ||
end | ||
user.save | ||
render :json => { :success => true} | ||
end | ||
|
||
end |
Oops, something went wrong.