Skip to content

Commit

Permalink
Merge pull request #186 from OpenDSA/textbook-fix
Browse files Browse the repository at this point in the history
Textbook creation is on separate page
  • Loading branch information
kwasimbnyarko authored Nov 12, 2024
2 parents 9719c35 + 1a82e3b commit 1468895
Show file tree
Hide file tree
Showing 8 changed files with 654 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MAINTAINER Jihane Najdi <jnajdi@vt.edu>
# Default environment
ARG RAILS_ENV='development'
ARG ODSA_BRANCH='master'
ARG LTI_BRANCH='master'
ARG LTI_BRANCH='staging'

ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Expand Down
410 changes: 410 additions & 0 deletions app/assets/javascripts/textbooks.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions app/controllers/textbooks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class TextbooksController < ApplicationController

def new

end
def create
# Textbooks are CourseOffering with no LMS interaction
# Hence the LMS instance TEXTBOOK is used for all CourseOfferings
Expand Down
69 changes: 36 additions & 33 deletions app/views/courses/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
%small= @term.display_name
- if @course_offerings && @course_offerings.any?
%p
- @course_offerings.each_with_index do |offering, i|
- @course_offerings.filter_map.with_index do |offering, i|
-# - next unless offering.lms_instance.url != "TEXTBOOK"
- if i > 0
%br/
%strong= offering.display_name
Expand Down Expand Up @@ -48,37 +49,39 @@
%tr
%th Book Title
%th Canvas Course
%th Textbook
%tbody#odsa
-# - @inst_book = offering.inst_books
-# = render @inst_book
%td= offering.display_name
%td
%td
- course = Course.find_by(id:offering.course_id)
- organization = Organization.find_by(id:course.organization_id)
- term = Term.find_by(id:offering.term_id)
= ENV["config_api_link"].gsub("/api/configure/","/Books/#{organization.slug}/#{course.slug}/#{term.slug}/#{offering.label}/html/index.html")
%td
- inst_book = InstBook.find_by(course_offering_id:offering.id)
- form_name = 'compile_book_' + inst_book.id.to_s
= form_tag '/inst_books/'+ inst_book.id.to_s , data: {type: "script"}, format: 'js', remote: true, onsubmit: "#{form_name}.disabled = true; #{form_name}.value = 'Please wait...'; Window.ODSA = Window.ODSA || {}; Window.ODSA.inst_book_id = #{inst_book.id}; Window.ODSA.action_type = 'compile_book'; return true;" do
= submit_tag "Compile Textbook", name: form_name, class: "btn btn-primary", title: 'Compile book confirmation.', data: {confirm: "The book compilation process will regenerate the book pages on the OpenDSA server. Assignments due dates and points in Canvas course won't be affected by this action. Do you want to continue?"}
.col-xs-1
%i.fa.fa-info-circle.action{ data: { toggle: 'modal', target: '#generate-course-modal' } }
#generate-course-modal.modal.fade{role: 'dialog', tabindex: '-1' }
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
.modal-content
.modal-header
%p.lead Compile Textbook
.modal-body
%p
When you click this button the OpenDSA book will be generated as an independent resource.
This book will have no LMS ties such as Canvas integration.
-# If this is the first time the course is being generated, all OpenDSA chapters and modules
-# will be created in the course. If you are re-generating the Canvas course, this process
-# will update the assignments points and due dates as well as create new Canvas assignments
-# and modules for any new chapters and modules added to your course offering's OpenDSA book configuration.
%th
%th
%th
- if offering.lms_instance.url != "TEXTBOOK"
%tbody#odsa
- @inst_book = offering.inst_books
= render @inst_book
- else
%tbody#odsa
%td= offering.display_name
%td
%td
- course = Course.find_by(id:offering.course_id)
- organization = Organization.find_by(id:course.organization_id)
- term = Term.find_by(id:offering.term_id)
= ENV["config_api_link"].gsub("/api/configure/","/Books/#{organization.slug}/#{course.slug}/#{term.slug}/#{offering.label}/html/index.html")
%td
- inst_book = InstBook.find_by(course_offering_id:offering.id)
- form_name = 'compile_book_' + inst_book.id.to_s
= form_tag '/inst_books/'+ inst_book.id.to_s , data: {type: "script"}, format: 'js', remote: true, onsubmit: "#{form_name}.disabled = true; #{form_name}.value = 'Please wait...'; Window.ODSA = Window.ODSA || {}; Window.ODSA.inst_book_id = #{inst_book.id}; Window.ODSA.action_type = 'compile_book'; return true;" do
= submit_tag "Compile Textbook", name: form_name, class: "btn btn-primary", title: 'Compile book confirmation.', data: {confirm: "The book compilation process will regenerate the book pages on the OpenDSA server. Assignments due dates and points in Canvas course won't be affected by this action. Do you want to continue?"}
.col-xs-1
%i.fa.fa-info-circle.action{ data: { toggle: 'modal', target: '#generate-course-modal' } }
#generate-course-modal.modal.fade{role: 'dialog', tabindex: '-1' }
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
.modal-content
.modal-header
%p.lead Compile Textbook
.modal-body
%p
When you click this button the OpenDSA book will be generated as an independent resource.
This book will have no LMS ties such as Canvas integration.

-else

%h2 Offerings
Expand Down Expand Up @@ -112,4 +115,4 @@
/ user_path(i) }.to_sentence
/ %td
/ = render partial: 'course_offerings/self_enrollment',
/ locals: { o: o }
/ locals: { o: o }
2 changes: 2 additions & 0 deletions app/views/layouts/_navbar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
- if user_signed_in? && (current_user.global_role.is_instructor? or current_user.global_role.is_admin? or current_user.global_role.is_researcher?)
%li
%strong= link_to 'Create new course', new_course_offerings_path
%li
%strong= link_to 'Create new textbook', new_textbook_path
- if (current_user.global_role.is_instructor? or current_user.global_role.is_admin? or current_user.global_role.is_researcher?)
%li
%a{href: configurations_book_path}
Expand Down
194 changes: 194 additions & 0 deletions app/views/textbooks/_form.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
.row
.col-xs-9.alert-msg#alerts{style: 'display: none;'}
.form-horizontal
.form-group
.col-xs-offset-2.col-xs-3
%h4
View the
%a{href: home_guide_path}
instructor's guide
for more information.
%h4.text-danger All fields are required

.form-group
= label_tag :organization_select, 'Organization:', class: 'control-label col-xs-1'
.col-xs-3
= collection_select nil, nil, Organization.all.order(:name), :id, :name, { prompt: 'Select', selected: nil },
{ id: 'organization-select', class: 'form-control' }
.col-xs-1
= link_to admin_organizations_path, title: "Create new organization", class: 'btn btn-default', :target => "_blank" do
%i.glyphicon.glyphicon-new-window

.form-group
= label_tag :course_select, 'Course:', class: 'control-label col-xs-1'
.col-xs-3
= collection_select nil, nil, Course.all.order(:slug, :name), :id, :display_name, { prompt: 'Select', selected: nil },
{ id: 'course-select', class: 'form-control' }
.col-xs-1
= link_to admin_courses_path, title: "Create new course", class: 'btn btn-default', :target => "_blank" do
%i.glyphicon.glyphicon-new-window

.form-group
= label_tag :term_select, 'Term:', class: 'control-label col-xs-1'
.col-xs-3
= collection_select nil, nil, Term.on_or_future.order(:starts_on), :id, :display_name, { prompt: 'Select', selected: nil },
{ id: 'term-select', class: 'form-control' }
.col-xs-1
= link_to admin_terms_path, title: "Create new term", class: 'btn btn-default', :target => "_blank" do
%i.glyphicon.glyphicon-new-window

.form-group
= label_tag :name, 'Label', class: 'control-label col-xs-2'
.col-lg-4.col-md-4.col-xs-4
= text_field_tag :name, nil, id: 'label', class: 'form-control', maxlength: 25,
placeholder: 'e.g. TR 10:00am'
%small.col-xs-11.text.text-warning
Write a label for each course section.

.form-group
= label_tag :inst_book_select, 'Book Instance:', class: 'control-label col-xs-1'
.col-xs-3
= collection_select nil, nil, InstBook.template.order(:title, :created_at), :id, :title_with_created_at, { prompt: 'Select', selected: nil },
{ id: 'inst-book-select', class: 'form-control' }
.col-xs-1
= link_to admin_inst_books_path, title: "Create new late policy", class: 'btn btn-default', :target => "_blank" do
%i.glyphicon.glyphicon-new-window

.form-group
.col-xs-offset-2.col-xs-2
- textbook_lms_instance = LmsInstance.find_by(url: "TEXTBOOK")
%button#btn-gen-textbook.btn.btn-primary{disabled:textbook_lms_instance.blank?} Create Non LMS Textbook
%small.col-xs-11.text.text-warning
= textbook_lms_instance.blank? ? 'Textbook LMS Instance not found' : ''


#lms-instance-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
.modal-content
.modal-header
%p.lead LMS Instances Information
.modal-body
%table.table
%thead
%th Id
%th URL
%tbody
- LmsInstance.all.each do |lms_instance|
%tr
%td
= lms_instance.id
%td
= lms_instance.url

#org-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
.modal-content
.modal-header
%p.lead Organization Information
.modal-body
%table.table
%thead
%th Id
%th Name
%th Abbreviation
%tbody
- Organization.all.each do |org|
%tr
%td
= org.id
%td
= org.name
%td
= org.abbreviation

#course-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
.modal-content
.modal-header
%p.lead Course Information
.modal-body
%table.table
%thead
%th Id
%th Name
%th Organization
%tbody
- Course.all.each do |course|
%tr
%td
= course.id
%td
= course.display_name
%td
= course.organization.name

#term-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
.modal-content
.modal-header
%p.lead Term Information
.modal-body
%table.table
%thead
%th Id
%th Name
%th Starts on
%th Ends on
%tbody
- Term.on_or_future.each do |term|
%tr
%td
= term.id
%td
= term.display_name
%td
= term.starts_on
%td
= term.ends_on

#late-policy-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
.modal-content
.modal-header
%p.lead Late Policy Information
Late days are the number of days (after deadline) during which the penalty percent will be applied.
After late days, student submissions will be recorded but they will not be graded.
.modal-body
%table.table
%thead
%th Id
%th Name
%th Late days
%th Penalty percent
%tbody
- LatePolicy.all.each do |late_policy|
%tr
%td
= late_policy.id
%td
= late_policy.name
%td
= late_policy.late_days
%td
= late_policy.late_percent

#inst-book-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
.modal-content
.modal-header
%p.lead Book Instances Information
.modal-body
%table.table
%thead
%th Id
%th Title
%th Description
%tbody
- InstBook.template.each do |inst_book|
%tr
%td
= inst_book.id
%td
= inst_book.title
%td
= inst_book.desc
7 changes: 7 additions & 0 deletions app/views/textbooks/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
%ol.breadcrumb
%li= link_to 'Home', root_path
%li.active New Textbook

%h1 New Textbook

= render 'form'
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
#textbook routes
post '/textbooks' => 'textbooks#create', as: :create_textbooks
post '/textbooks/compile/:course_offering_id' => 'textbooks#compile', as: :compile_textbooks
get '/textbooks/new' => 'textbooks#new', as: :new_textbook

get '/documentation/hecvat' => 'documentation#hecvat_download', as: :hecvat_download

Expand Down

0 comments on commit 1468895

Please sign in to comment.