Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/stylesheets/gradesheet.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ td.focus {
padding-right: 15px;
}

#grades .course_number,
#grades .sec,
#grades .lec,
#grades .total,
Expand Down
5 changes: 1 addition & 4 deletions app/assets/stylesheets/instructor_gradebook.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@
font: inherit;
}

#gradebook .slick-header-column.andrew,
#gradebook .slick-header-column.first_name,
#gradebook .slick-header-column.last_name,
#gradebook .slick-cell.andrew,
#gradebook .slick-cell.email,
#gradebook .slick-cell.first_name,
#gradebook .slick-cell.last_name {
text-align: left;
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/assessment/grading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ def statistics
@scores[:all] = all_grouping[1]
end

by_course_number = latest_submissions.group_by { |s| s.course_user_datum.course_number }
@statistics[:course_number] = stats_for_grouping(by_course_number)
@scores[:course_number] = scores_for_grouping(by_course_number)

by_lecture = latest_submissions.group_by { |s| s.course_user_datum.lecture }
@statistics[:lecture] = stats_for_grouping(by_lecture)
@scores[:lecture] = scores_for_grouping(by_lecture)
Expand Down
20 changes: 4 additions & 16 deletions app/controllers/course_user_data_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,33 +242,21 @@ def add_users_breadcrumb
end

def cud_params
if @cud.administrator?
params.require(:course_user_datum).permit(:school, :major, :year,
if @cud.administrator? || @cud.instructor?
params.require(:course_user_datum).permit(:school, :major, :year, :course_number,
:lecture, :section, :instructor, :dropped,
:nickname, :course_assistant,
user_attributes: %i[first_name last_name email],
tweak_attributes: %i[_destroy kind value])
elsif @cud.instructor?
params.require(:course_user_datum).permit(:school, :major, :year,
:lecture, :section, :instructor, :dropped,
:nickname, :course_assistant,
user_attributes: %i[email first_name last_name],
tweak_attributes: %i[_destroy kind value])
else
params.require(:course_user_datum).permit(:nickname) # ,
# user_attributes: [:first_name, :last_name])
end
end

def edit_cud_params
if @cud.administrator?
params.require(:course_user_datum).permit(:school, :major, :year,
:lecture, :section, :instructor, :dropped,
:nickname, :course_assistant,
user_attributes: %i[id email first_name last_name],
tweak_attributes: %i[_destroy kind value])
elsif @cud.instructor?
params.require(:course_user_datum).permit(:school, :major, :year,
if @cud.administrator? || @cud.instructor?
params.require(:course_user_datum).permit(:school, :major, :year, :course_number,
:lecture, :section, :instructor, :dropped,
:nickname, :course_assistant,
user_attributes: %i[id email first_name last_name],
Expand Down
60 changes: 34 additions & 26 deletions app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,13 @@ def write_cuds(cuds)
if !user.nil?
cud = @course.course_user_data.new
cud.user = user
params = ActionController::Parameters.new(section: new_cud["section"],
grade_policy: new_cud[:grade_policy],
lecture: new_cud[:lecture])
Rails.logger.debug params
cud.assign_attributes(params.permit(:lecture, :section, :grade_policy))
params = ActionController::Parameters.new(
course_number: new_cud[:course_number],
lecture: new_cud[:lecture],
section: new_cud[:section],
grade_policy: new_cud[:grade_policy]
)
cud.assign_attributes(params.permit(:course_number, :lecture, :section, :grade_policy))

# Save without validations
cud.save(validate: false)
Expand Down Expand Up @@ -722,10 +724,13 @@ def write_cuds(cuds)
new_cud.delete(:year)

# assign attributes
params = ActionController::Parameters.new(section: new_cud["section"],
grade_policy: new_cud[:grade_policy],
lecture: new_cud[:lecture])
existing.assign_attributes(params.permit(:lecture, :section, :grade_policy))
params = ActionController::Parameters.new(
course_number: new_cud[:course_number],
lecture: new_cud[:lecture],
section: new_cud[:section],
grade_policy: new_cud[:grade_policy]
)
existing.assign_attributes(params.permit(:course_number, :lecture, :section, :grade_policy))
existing.dropped = false
existing.save(validate: false) # Save without validations.
end
Expand Down Expand Up @@ -787,7 +792,7 @@ def parse_roster_csv
major: row[5].to_s.chomp(" "),
year: row[6].to_s.chomp(" "),
grade_policy: row[7].to_s.chomp(" "),
# Ignore courseNumber (row[8])
course_number: row[8].to_s.chomp(" "),
lecture: row[9].to_s.chomp(" "),
section: row[10].to_s.chomp(" ")
}
Expand Down Expand Up @@ -818,16 +823,19 @@ def parse_roster_csv
cud.instructor? || cud.user.administrator? || cud.course_assistant?
end
@currentCUDs.each do |cud| # These are the drops
new_cud = { email: cud.user.email,
last_name: cud.user.last_name,
first_name: cud.user.first_name,
school: cud.school,
major: cud.major,
year: cud.year,
grade_policy: cud.grade_policy,
lecture: cud.lecture,
section: cud.section,
color: "red" }
new_cud = {
email: cud.user.email,
last_name: cud.user.last_name,
first_name: cud.user.first_name,
school: cud.school,
major: cud.major,
year: cud.year,
grade_policy: cud.grade_policy,
course_number: cud.course_number,
lecture: cud.lecture,
section: cud.section,
color: "red"
}
@cuds << new_cud
end
end
Expand Down Expand Up @@ -860,7 +868,7 @@ def parse_roster_csv
# map[5]: major
# map[6]: year
# map[7]: grade_policy
# map[8]: course (unused)
# map[8]: course
# map[9]: lecture
# map[10]: section
# rubocop:disable Lint/UselessAssignment
Expand All @@ -873,7 +881,7 @@ def detect_and_convert_roster(roster)
case parsedRoster[0].length
when ROSTER_COLUMNS_F20 # 34 fields
# In CMU S3 roster. Columns are:
# Semester(0 - skip), Course(1 - skip), Section(2), Lecture(3), Mini(4 - skip),
# Semester(0 - skip), Course(1), Section(2), Lecture(3), Mini(4 - skip),
# Last Name(5), Preferred/First Name(6), MI(7 - skip), Andrew ID(8),
# Email(9 - skip), College(10), Department(11 - skip), Major(12),
# Class(13), Graduation Semester(14 - skip), Units(15 - skip), Grade Option(16)
Expand All @@ -882,11 +890,11 @@ def detect_and_convert_roster(roster)
# Default Grade(21), Time Zone Code(22), Time Zone Description(23), Added By(24),
# Added On(25), Confirmed(26), Waitlist Position(27), Units Carried/Max Units(28),
# Waitlisted By(29), Waitlisted On(30), Dropped By(31), Dropped On(32), Roster As Of Date(33)
map = [-1, 8, 5, 6, 10, 12, 13, 16, -1, 3, 2]
map = [-1, 8, 5, 6, 10, 12, 13, 16, 1, 3, 2]
select_columns = ROSTER_COLUMNS_F20
when ROSTER_COLUMNS_F16 # 32 fields
# In CMU S3 roster. Columns are:
# Semester(0 - skip), Course(1 - skip), Section(2), Lecture(3), Mini(4 - skip),
# Semester(0 - skip), Course(1), Section(2), Lecture(3), Mini(4 - skip),
# Last Name(5), Preferred/First Name(6), MI(7 - skip), Andrew ID(8),
# Email(9 - skip), College(10), Department(11), Major(12),
# Class(13), Graduation Semester(14 - skip), Units(15 - skip), Grade Option(16)
Expand All @@ -895,7 +903,7 @@ def detect_and_convert_roster(roster)
# Default Grade(21), Added By(22), Added On(23), Confirmed(24), Waitlist Position(25),
# Units Carried/Max Units(26), Waitlisted By(27), Waitlisted On(28), Dropped By(29),
# Dropped On(30), Roster As Of Date(31)
map = [-1, 8, 5, 6, 10, 12, 13, 16, -1, 3, 2]
map = [-1, 8, 5, 6, 10, 12, 13, 16, 1, 3, 2]
select_columns = ROSTER_COLUMNS_F16
when ROSTER_COLUMNS_S15 # 29 fields
# In CMU S3 roster. Columns are:
Expand All @@ -907,7 +915,7 @@ def detect_and_convert_roster(roster)
else
# No header row. Columns are:
# Semester(0 - skip), Email(1), Last Name(2), First Name(3), School(4),
# Major(5), Year(6), Grade Policy(7), Course(8 - skip), Lecture(9),
# Major(5), Year(6), Grade Policy(7), Course(8), Lecture(9),
# Section(10)
return parsedRoster
end
Expand Down
49 changes: 25 additions & 24 deletions app/form_builders/form_builder_with_date_time_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class FormBuilderWithDateTimeInput < ActionView::Helpers::FormBuilder
options = args.extract_options!

# DEPRECATED: add form-control class (for Bootstrap styling) and pass on to Rails
options[:class] = "#{options[:class]}"
options[:class] = (options[:class]).to_s

unless options.include?(:placeholder)
options[:placeholder] = ""
options[:placeholder] = ""
end

field = super name, *(args + [options])
Expand All @@ -28,7 +28,7 @@ def score_adjustment_input(name, *args)
options = args.extract_options!

fields = fields_for name do |f|
(f.vanilla_text_field :value, class: "score-box", placeholder: "10") +
(f.vanilla_text_field :value, class: "score-box", placeholder: "10") +
(@template.content_tag :div, class: "" do
f.select(:kind, { "points" => "points", "%" => "percent" }, {},
class: "carrot")
Expand All @@ -50,21 +50,22 @@ def check_box(name, *args)
options = args.extract_options!

display_name = options[:display_name].nil? ? name : options[:display_name]
display_span = "<span>" + display_name.to_s.humanize + "</span>"

display_span = "<span>#{display_name.to_s.humanize}</span>"
# Materalize requires the label to be in a span
field = super name, *(args + [options])

if (options[:default])
return field
end
if options[:default]
return field
end

@template.content_tag :div do
if options.include?(:help_text)
label(name, field + display_span.html_safe, class: "control-label") + help_text(name, options[:help_text])
label(name, field + display_span.html_safe,
class: "control-label") + help_text(name, options[:help_text])
else
label(name, field + display_span.html_safe, class: "control-label")
end
label(name, field + display_span.html_safe, class: "control-label")
end
end
end

Expand Down Expand Up @@ -112,28 +113,28 @@ def date_helper(name, options, strftime, date_format, alt_format)
existing_time = nil
end

if existing_time.present?
formatted_datetime = existing_time.strftime(strftime)
else
formatted_datetime = ""
end
formatted_datetime = if existing_time.present?
existing_time.strftime(strftime)
else
""
end
field = vanilla_text_field(
name,
:value => formatted_datetime,
:class => "#{options[:picker_class]}",
:"data-date-format" => date_format,
:"data-alt-format" => alt_format,
:"data-date-less-than" => options[:less_than],
:"data-date-greater-than" => options[:greater_than])

value: formatted_datetime,
class: (options[:picker_class]).to_s,
"data-date-format": date_format,
"data-alt-format": alt_format,
"data-date-less-than": options[:less_than],
"data-date-greater-than": options[:greater_than]
)

wrap_field name, field, options[:help_text]
end

def wrap_field(name, field, help_text = nil, display_name = nil)
@template.content_tag :div, class: "input-field" do
label(name, display_name, class: "control-label") +
field + help_text(name, help_text)
field + help_text(name, help_text)
end
end

Expand Down
20 changes: 13 additions & 7 deletions app/helpers/gradebook_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ def gradebook_columns(matrix, course)
columns = [
{ id: "number", name: "#", field: "", width: 50 },
{ id: "email", name: "Email", field: "email",
sortable: true, width: 100, cssClass: "email",
sortable: true, width: 200, cssClass: "email",
headerCssClass: "email" },
{ id: "first_name", name: "First", field: "first_name",
sortable: true, width: 100, cssClass: "first_name",
headerCssClass: "first_name" },
{ id: "last_name", name: "Last", field: "last_name",
sortable: true, width: 100, cssClass: "last_name",
headerCssClass: "last_name" },
{ id: "section", name: "Sec", field: "section",
sortable: true, width: 50 },
{ id: "grace_days", name: "Grace Days Used", field: "grace_days",
sortable: true, width: 50},
{ id: "course_number", name: "Course &#8470;", field: "course_number",
sortable: true, width: 100 },
{ id: "lecture", name: "Lecture", field: "lecture",
sortable: true, width: 100 },
{ id: "section", name: "Section", field: "section",
sortable: true, width: 100 },
{ id: "grace_days", name: "Grace Days", field: "grace_days",
sortable: true, width: 100 },
{ id: "late_days", name: "Penalty Late Days", field: "late_days",
sortable: true, width: 50}
sortable: true, width: 100 }
]

course.assessment_categories.each do |cat|
Expand Down Expand Up @@ -48,7 +52,7 @@ def gradebook_columns(matrix, course)
headerCssClass: "course_average" }

columns << { id: "email_right", name: "Email", field: "email",
sortable: true, width: 100, cssClass: "email right",
sortable: true, width: 200, cssClass: "email right",
headerCssClass: "email right" }

columns
Expand Down Expand Up @@ -77,6 +81,8 @@ def gradebook_rows(matrix, course, section = nil, lecture = nil)
row["student_gradebook_link"] = sgb_link
row["first_name"] = CGI.escapeHTML cud.user.first_name
row["last_name"] = CGI.escapeHTML cud.user.last_name
row["course_number"] = cud.course_number
row["lecture"] = cud.lecture
row["section"] = cud.section

# TODO: formalize score render stack, consolidate with computed score
Expand Down
Loading