Commit a786e4ad authored by Zac Wood's avatar Zac Wood

More calendar tweaks

parent 31d0222f
......@@ -2,6 +2,7 @@ class CoursesController < ApplicationController
def show
# Load the course with the id passed in the URL.
@course = Course.find_by_id(params[:id])
@rating = @course.rating
@sections = @course.course_sections.where(semester: @semester)
end
end
......@@ -7,6 +7,12 @@ import withSizes from 'react-sizes';
const localizer = BigCalendar.momentLocalizer(moment);
const minTime = new Date();
minTime.setHours(7, 0, 0);
const maxTime = new Date();
maxTime.setHours(23, 0, 0);
const Calendar = props => (
<div className="full-width" style={{ backgroundColor: 'white', padding: '24px' }}>
<BigCalendar
......@@ -25,6 +31,7 @@ const Calendar = props => (
dayRangeHeaderFormat: () => '',
}}
style={{ height: '75vh' }}
min={minTime}
/>
</div>
);
......
......@@ -9,4 +9,16 @@ class Course < ApplicationRecord
def full_name
"#{subject} #{course_number}"
end
def rating(question = 1, sections = self.course_sections)
total = 0
resp = 0
sections.each do |s|
next if s.rating_questions.empty?
resp += s.rating_questions[question]["resp"].to_i
total += s.rating_questions[question]["instr_mean"].to_f * s.rating_questions[0]["resp"].to_i
end
[(total / resp).round(2), resp] unless resp.zero?
end
end
......@@ -2,8 +2,12 @@
<div class="col-12 col-lg">
<h1><%= @course.full_name %></h1>
<h4><%= @course.title %></h4>
<% unless @rating.nil? %>
<%= render partial: 'shared/stars', locals: { percent: @course.rating[0]/5*100 } %>
Average course rating: <%= @course.rating[0] %> / <%= @course.rating[1] %> responses
<% end %>
<div class="d-flex">
<div class="d-flex mt-2">
<div class="attr-list justify-content-start">
<div class="attr">
<div class="icon">
......@@ -20,7 +24,7 @@
</div>
</div>
</div>
<p><%= @course.description %></p>
<p class="mt-3"><%= @course.description %></p>
</div>
<div class="col-12 col-lg">
......
......@@ -8,7 +8,7 @@
</p>
</div>
<div class="row">
<div class="row ">
<div class="col-md-4">
<div class="card">
<div class="card-body">
......
<div class="row">
<div class="col-lg-4 col-12 mb-4">
<h1><%= @instructor.name %></h1>
<% unless @rating[:teaching].nil? %>
<%= render partial: 'shared/stars', locals: { percent: @rating[:teaching][0]/5*100 } %><br>
Average teaching rating: <%= @rating[:teaching][0] %> / <%= @rating[:teaching][1] %> responses
<% end %>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment