Skip to content

Commit 1468895

Browse files
Merge pull request #186 from OpenDSA/textbook-fix
Textbook creation is on separate page
2 parents 9719c35 + 1a82e3b commit 1468895

File tree

8 files changed

+654
-34
lines changed

8 files changed

+654
-34
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ MAINTAINER Jihane Najdi <[email protected]>
55
# Default environment
66
ARG RAILS_ENV='development'
77
ARG ODSA_BRANCH='master'
8-
ARG LTI_BRANCH='master'
8+
ARG LTI_BRANCH='staging'
99

1010
ENV TZ=America/New_York
1111
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

app/assets/javascripts/textbooks.js

+410
Large diffs are not rendered by default.

app/controllers/textbooks_controller.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
class TextbooksController < ApplicationController
22

3+
def new
4+
5+
end
36
def create
47
# Textbooks are CourseOffering with no LMS interaction
58
# Hence the LMS instance TEXTBOOK is used for all CourseOfferings

app/views/courses/show.html.haml

+36-33
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
%small= @term.display_name
66
- if @course_offerings && @course_offerings.any?
77
%p
8-
- @course_offerings.each_with_index do |offering, i|
8+
- @course_offerings.filter_map.with_index do |offering, i|
9+
-# - next unless offering.lms_instance.url != "TEXTBOOK"
910
- if i > 0
1011
%br/
1112
%strong= offering.display_name
@@ -48,37 +49,39 @@
4849
%tr
4950
%th Book Title
5051
%th Canvas Course
51-
%th Textbook
52-
%tbody#odsa
53-
-# - @inst_book = offering.inst_books
54-
-# = render @inst_book
55-
%td= offering.display_name
56-
%td
57-
%td
58-
- course = Course.find_by(id:offering.course_id)
59-
- organization = Organization.find_by(id:course.organization_id)
60-
- term = Term.find_by(id:offering.term_id)
61-
= ENV["config_api_link"].gsub("/api/configure/","/Books/#{organization.slug}/#{course.slug}/#{term.slug}/#{offering.label}/html/index.html")
62-
%td
63-
- inst_book = InstBook.find_by(course_offering_id:offering.id)
64-
- form_name = 'compile_book_' + inst_book.id.to_s
65-
= 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
66-
= 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?"}
67-
.col-xs-1
68-
%i.fa.fa-info-circle.action{ data: { toggle: 'modal', target: '#generate-course-modal' } }
69-
#generate-course-modal.modal.fade{role: 'dialog', tabindex: '-1' }
70-
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
71-
.modal-content
72-
.modal-header
73-
%p.lead Compile Textbook
74-
.modal-body
75-
%p
76-
When you click this button the OpenDSA book will be generated as an independent resource.
77-
This book will have no LMS ties such as Canvas integration.
78-
-# If this is the first time the course is being generated, all OpenDSA chapters and modules
79-
-# will be created in the course. If you are re-generating the Canvas course, this process
80-
-# will update the assignments points and due dates as well as create new Canvas assignments
81-
-# and modules for any new chapters and modules added to your course offering's OpenDSA book configuration.
52+
%th
53+
%th
54+
%th
55+
- if offering.lms_instance.url != "TEXTBOOK"
56+
%tbody#odsa
57+
- @inst_book = offering.inst_books
58+
= render @inst_book
59+
- else
60+
%tbody#odsa
61+
%td= offering.display_name
62+
%td
63+
%td
64+
- course = Course.find_by(id:offering.course_id)
65+
- organization = Organization.find_by(id:course.organization_id)
66+
- term = Term.find_by(id:offering.term_id)
67+
= ENV["config_api_link"].gsub("/api/configure/","/Books/#{organization.slug}/#{course.slug}/#{term.slug}/#{offering.label}/html/index.html")
68+
%td
69+
- inst_book = InstBook.find_by(course_offering_id:offering.id)
70+
- form_name = 'compile_book_' + inst_book.id.to_s
71+
= 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
72+
= 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?"}
73+
.col-xs-1
74+
%i.fa.fa-info-circle.action{ data: { toggle: 'modal', target: '#generate-course-modal' } }
75+
#generate-course-modal.modal.fade{role: 'dialog', tabindex: '-1' }
76+
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
77+
.modal-content
78+
.modal-header
79+
%p.lead Compile Textbook
80+
.modal-body
81+
%p
82+
When you click this button the OpenDSA book will be generated as an independent resource.
83+
This book will have no LMS ties such as Canvas integration.
84+
8285
-else
8386

8487
%h2 Offerings
@@ -112,4 +115,4 @@
112115
/ user_path(i) }.to_sentence
113116
/ %td
114117
/ = render partial: 'course_offerings/self_enrollment',
115-
/ locals: { o: o }
118+
/ locals: { o: o }

app/views/layouts/_navbar.html.haml

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
- if user_signed_in? && (current_user.global_role.is_instructor? or current_user.global_role.is_admin? or current_user.global_role.is_researcher?)
2626
%li
2727
%strong= link_to 'Create new course', new_course_offerings_path
28+
%li
29+
%strong= link_to 'Create new textbook', new_textbook_path
2830
- if (current_user.global_role.is_instructor? or current_user.global_role.is_admin? or current_user.global_role.is_researcher?)
2931
%li
3032
%a{href: configurations_book_path}

app/views/textbooks/_form.html.haml

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
.row
2+
.col-xs-9.alert-msg#alerts{style: 'display: none;'}
3+
.form-horizontal
4+
.form-group
5+
.col-xs-offset-2.col-xs-3
6+
%h4
7+
View the
8+
%a{href: home_guide_path}
9+
instructor's guide
10+
for more information.
11+
%h4.text-danger All fields are required
12+
13+
.form-group
14+
= label_tag :organization_select, 'Organization:', class: 'control-label col-xs-1'
15+
.col-xs-3
16+
= collection_select nil, nil, Organization.all.order(:name), :id, :name, { prompt: 'Select', selected: nil },
17+
{ id: 'organization-select', class: 'form-control' }
18+
.col-xs-1
19+
= link_to admin_organizations_path, title: "Create new organization", class: 'btn btn-default', :target => "_blank" do
20+
%i.glyphicon.glyphicon-new-window
21+
22+
.form-group
23+
= label_tag :course_select, 'Course:', class: 'control-label col-xs-1'
24+
.col-xs-3
25+
= collection_select nil, nil, Course.all.order(:slug, :name), :id, :display_name, { prompt: 'Select', selected: nil },
26+
{ id: 'course-select', class: 'form-control' }
27+
.col-xs-1
28+
= link_to admin_courses_path, title: "Create new course", class: 'btn btn-default', :target => "_blank" do
29+
%i.glyphicon.glyphicon-new-window
30+
31+
.form-group
32+
= label_tag :term_select, 'Term:', class: 'control-label col-xs-1'
33+
.col-xs-3
34+
= collection_select nil, nil, Term.on_or_future.order(:starts_on), :id, :display_name, { prompt: 'Select', selected: nil },
35+
{ id: 'term-select', class: 'form-control' }
36+
.col-xs-1
37+
= link_to admin_terms_path, title: "Create new term", class: 'btn btn-default', :target => "_blank" do
38+
%i.glyphicon.glyphicon-new-window
39+
40+
.form-group
41+
= label_tag :name, 'Label', class: 'control-label col-xs-2'
42+
.col-lg-4.col-md-4.col-xs-4
43+
= text_field_tag :name, nil, id: 'label', class: 'form-control', maxlength: 25,
44+
placeholder: 'e.g. TR 10:00am'
45+
%small.col-xs-11.text.text-warning
46+
Write a label for each course section.
47+
48+
.form-group
49+
= label_tag :inst_book_select, 'Book Instance:', class: 'control-label col-xs-1'
50+
.col-xs-3
51+
= collection_select nil, nil, InstBook.template.order(:title, :created_at), :id, :title_with_created_at, { prompt: 'Select', selected: nil },
52+
{ id: 'inst-book-select', class: 'form-control' }
53+
.col-xs-1
54+
= link_to admin_inst_books_path, title: "Create new late policy", class: 'btn btn-default', :target => "_blank" do
55+
%i.glyphicon.glyphicon-new-window
56+
57+
.form-group
58+
.col-xs-offset-2.col-xs-2
59+
- textbook_lms_instance = LmsInstance.find_by(url: "TEXTBOOK")
60+
%button#btn-gen-textbook.btn.btn-primary{disabled:textbook_lms_instance.blank?} Create Non LMS Textbook
61+
%small.col-xs-11.text.text-warning
62+
= textbook_lms_instance.blank? ? 'Textbook LMS Instance not found' : ''
63+
64+
65+
#lms-instance-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
66+
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
67+
.modal-content
68+
.modal-header
69+
%p.lead LMS Instances Information
70+
.modal-body
71+
%table.table
72+
%thead
73+
%th Id
74+
%th URL
75+
%tbody
76+
- LmsInstance.all.each do |lms_instance|
77+
%tr
78+
%td
79+
= lms_instance.id
80+
%td
81+
= lms_instance.url
82+
83+
#org-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
84+
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
85+
.modal-content
86+
.modal-header
87+
%p.lead Organization Information
88+
.modal-body
89+
%table.table
90+
%thead
91+
%th Id
92+
%th Name
93+
%th Abbreviation
94+
%tbody
95+
- Organization.all.each do |org|
96+
%tr
97+
%td
98+
= org.id
99+
%td
100+
= org.name
101+
%td
102+
= org.abbreviation
103+
104+
#course-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
105+
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
106+
.modal-content
107+
.modal-header
108+
%p.lead Course Information
109+
.modal-body
110+
%table.table
111+
%thead
112+
%th Id
113+
%th Name
114+
%th Organization
115+
%tbody
116+
- Course.all.each do |course|
117+
%tr
118+
%td
119+
= course.id
120+
%td
121+
= course.display_name
122+
%td
123+
= course.organization.name
124+
125+
#term-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
126+
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
127+
.modal-content
128+
.modal-header
129+
%p.lead Term Information
130+
.modal-body
131+
%table.table
132+
%thead
133+
%th Id
134+
%th Name
135+
%th Starts on
136+
%th Ends on
137+
%tbody
138+
- Term.on_or_future.each do |term|
139+
%tr
140+
%td
141+
= term.id
142+
%td
143+
= term.display_name
144+
%td
145+
= term.starts_on
146+
%td
147+
= term.ends_on
148+
149+
#late-policy-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
150+
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
151+
.modal-content
152+
.modal-header
153+
%p.lead Late Policy Information
154+
Late days are the number of days (after deadline) during which the penalty percent will be applied.
155+
After late days, student submissions will be recorded but they will not be graded.
156+
.modal-body
157+
%table.table
158+
%thead
159+
%th Id
160+
%th Name
161+
%th Late days
162+
%th Penalty percent
163+
%tbody
164+
- LatePolicy.all.each do |late_policy|
165+
%tr
166+
%td
167+
= late_policy.id
168+
%td
169+
= late_policy.name
170+
%td
171+
= late_policy.late_days
172+
%td
173+
= late_policy.late_percent
174+
175+
#inst-book-help-modal.modal.fade{role: 'dialog', tabindex: '-1' }
176+
.modal-dialog.modal-md{ style: 'overflow-y: scroll; max-height:85% margin-top: 50px; margin-bottom:50px;' }
177+
.modal-content
178+
.modal-header
179+
%p.lead Book Instances Information
180+
.modal-body
181+
%table.table
182+
%thead
183+
%th Id
184+
%th Title
185+
%th Description
186+
%tbody
187+
- InstBook.template.each do |inst_book|
188+
%tr
189+
%td
190+
= inst_book.id
191+
%td
192+
= inst_book.title
193+
%td
194+
= inst_book.desc

app/views/textbooks/new.html.haml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
%ol.breadcrumb
2+
%li= link_to 'Home', root_path
3+
%li.active New Textbook
4+
5+
%h1 New Textbook
6+
7+
= render 'form'

config/routes.rb

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
#textbook routes
114114
post '/textbooks' => 'textbooks#create', as: :create_textbooks
115115
post '/textbooks/compile/:course_offering_id' => 'textbooks#compile', as: :compile_textbooks
116+
get '/textbooks/new' => 'textbooks#new', as: :new_textbook
116117

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

0 commit comments

Comments
 (0)