Add a joyride tip, fix a couple bugs with quiz generation
[oweals/karmaworld.git] / karmaworld / templates / notes / note_base.html
1 {% extends "base.html" %}
2 {% load url from future %}
3 {% load compress %}
4
5 {% block title %}
6   {{ note.name }}
7 {% endblock %}
8
9 {% block pagestyle %}
10   {% compress css %}
11     <link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/note_course_pages.css">
12     <link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/annotator.min.css" />
13   {% endcompress %}
14 {% endblock %}
15
16 {% block pagescripts %}
17   <script type="text/javascript">
18     var note_id = {{ note.id }};
19     var note_thank_url = "{% url 'thank_note' note.id %}"
20     var note_flag_url = "{% url 'flag_note' note.id %}"
21     var edit_note_tags_url = "{% url 'edit_note_tags' note.id %}"
22     var note_downloaded_url = "{% url 'downloaded_note' note.id %}"
23     var note_contents_url = "{{ S3_URL }}{{ note.get_relative_s3_path }}"
24     var pdfControls = {% if pdf_controls %} true {% else %} false {% endif %};
25     var csrf_token = "{{ csrf_token }}";
26     var annotator_js_url = "{{ STATIC_URL }}js/annotator-full.min.js";
27     var annotator_css_url = "{{ STATIC_URL }}css/annotator.min.css";
28     var setup_ajax_url = "{{ STATIC_URL }}js/setup-ajax.js";
29     var user_authenticated = {% if user.is_authenticated %}true{% else %}false{% endif %};
30   </script>
31   {% compress js %}
32     <script src="{{ STATIC_URL }}js/setup-ajax.js"></script>
33     <script src="{{ STATIC_URL }}js/note-detail.js" ></script>
34     <script src="{{ STATIC_URL }}js/pxem.jQuery.js"></script>
35     <script src="{{ STATIC_URL }}js/marked.js" ></script>
36     <script src="{{ STATIC_URL }}js/annotator-full.min.js"></script>
37   {% endcompress %}
38   <script>
39     {% if show_note_container %}
40       $(function() {
41         $(document).foundation('joyride', 'start');
42         initNoteContentPage();
43       });
44     {% endif %}
45
46     {% if show_keywords %}
47       $(function() {
48         initNoteKeywordsPage();
49       });
50     {% endif %}
51
52     {% if show_quiz %}
53       $(function() {
54         initQuizPage();
55       });
56     {% endif %}
57   </script>
58 {% endblock %}
59
60 {% block raw_content %}
61   <section id="note_content">
62
63     <div class="return-to-course show-for-large-up">
64       <div class="row">
65         <div class="small-12 columns">
66           <a href="{{ note.course.get_absolute_url }}" class="inherit-color">
67             <i class="fa fa-angle-double-left"></i> See all notes for {{ note.course.name }}
68           </a>
69         </div>
70       </div>
71     </div>
72
73     <div id="note_header">
74
75       <div class="row header-byline">
76         <div class="small-12 columns">
77           <strong>Lecture note for {{ note.course.name }} </strong>
78           at
79           {% if note.course.department.school %}
80             {{ note.course.department.school.name }}
81           {% else %}
82             {{ note.course.school.name }}
83           {% endif %}
84           &nbsp;&nbsp;
85           <span style="display: inline;"><span class="show-for-large-up"><i class="fa fa-thumbs-up"></i> <span id="thank-number">{{ note.thanks }}</span> Thank{{ note.thanks|pluralize }}</span></span>
86         </div>
87       </div>
88
89       <div class="row museo700">
90         <div class="small-12 columns header-title-row">
91           <span class="header-title">{{ note.name }} </span>
92           <span style="display: inline;">
93             <span class="show-for-large-up">
94               {% if user.is_authenticated %}
95                 {% if already_thanked %}
96                   <button id="thank-button-disabled" class="modify-button disabled opentip"
97                           data-ot="You've already thanked this note"
98                            {% include 'partial/opentip_settings.html' %}>
99                     <i class="fa fa-thumbs-up"></i> Thank Note</button>
100                 {% else %}
101                   <button id="thank-button" class="modify-button"><i class="fa fa-thumbs-up"></i> Thank Note</button>
102                   <button id="thank-button-disabled" class="modify-button disabled opentip hide"
103                           data-ot="You've already thanked this note"
104                            {% include 'partial/opentip_settings.html' %}>
105                     <i class="fa fa-thumbs-up"></i> Thank Note</button>
106                 {% endif %}
107               {% else %}
108                 <button id="thank-button-disabled" class="modify-button disabled opentip"
109                           data-ot="Log in to thank this note"
110                            {% include 'partial/opentip_settings.html' %}>
111                     <i class="fa fa-thumbs-up"></i> Thank Note</button>
112               {% endif %}
113
114               {% if user.is_authenticated %}
115                 {% if already_flagged %}
116                   <button id="flag-button-disabled" class="modify-button disabled opentip"
117                           data-ot="You've already reported this note"
118                            {% include 'partial/opentip_settings.html' %}>
119                     <i class="fa fa-flag"></i> Report Note</button>
120                 {% else %}
121                   <button id="flag-button" class="modify-button"><i class="fa fa-flag"></i> Report Note</button>
122                   <button id="flag-button-disabled" class="modify-button disabled opentip hide"
123                           data-ot="You've already reported this note"
124                            {% include 'partial/opentip_settings.html' %}>
125                     <i class="fa fa-flag"></i> Report Note</button>
126                 {% endif %}
127               {% else %}
128                 <button id="flag-button-disabled" class="modify-button disabled opentip"
129                           data-ot="Log in to report this note"
130                            {% include 'partial/opentip_settings.html' %}>
131                     <i class="fa fa-flag"></i> Report Note</button>
132               {% endif %}
133
134               {% if user.is_authenticated %}
135                 <a href="{{ note.get_fp_url }}">
136                   <button id="note-download-button" class="modify-button opentip"
137                           data-ot="It costs 2 karma points to download a note"
138                           {% include 'partial/opentip_settings.html' %}>
139                     <i class="fa fa-download"></i> Download Note</button></a>
140               {% else %}
141                 <button id="note-download-button-disabled" class="modify-button disabled opentip"
142                           data-ot="Log in to download this note"
143                            {% include 'partial/opentip_settings.html' %}>
144                   <i class="fa fa-download"></i> Download Note</button>
145               {% endif %}
146
147               {% if user.get_profile.can_edit_items and note.user != user %}
148                 <button id="edit-note-tags" class="modify-button" data-reveal-id="note-tag-dialog">
149                   <i class="fa fa-pencil-square-o"></i> Edit Tags
150                 </button>
151               {% endif %}
152
153               {% if note.user == request.user %}
154                 <button id="edit-button" data-reveal-id="note-edit-dialog" class="modify-button"> <i class="fa fa-edit"></i> Edit This Note</button>&nbsp;&nbsp;
155               {% endif %}
156
157               {% if note.license %}
158                 {{ note.license.html|safe }} {% if note.upstream_link %}<a href="{{ note.upstream_link }}" target="_blank">{{ note.upstream_link|slice:":80" }}</a>{% endif %}
159               {% endif %}
160             </span>
161           </span>
162         </div>
163       </div>
164
165       {% if note.category %}
166       <div id="note-category" class="row show-for-large-up">
167         <div class="small-12 columns">
168           <em>{{ note.get_category_display }}</em>
169         </div>
170       </div>
171       {% endif %}
172
173       <div id="note-tags" class="row show-for-large-up">
174         <div class="small-12 columns">
175           <strong>Tags: </strong>
176           <span class="tags">
177             {% if note.tags.all %}
178               {% for tag in note.tags.all %}
179                 <span class="tag-span">
180                   {{ tag.name }}{% if not forloop.last %}, {% endif %}
181                 </span>
182               {% endfor %}
183             {% else %}
184               <em class="light">(none defined yet)</em>
185             {% endif %}
186           </span>
187         </div><!-- /note_tags -->
188       </div>
189
190       <div id="note-tag-dialog" class="reveal-modal" data-reveal>
191         <a class="close-reveal-modal">&#215;</a>
192         <div class="row">
193           <div class="small-12 columns">
194             <h3>Edit this note's tags</h3>
195             <input id="note_tags_input" type="text" value="{% for tag in note.tags.all %}{{ tag.name }}{% if not forloop.last %}, {% endif %}{% endfor %}">
196             <button id="save_note_tags" type="submit" value="tags-form"><i class="fa fa-save"></i> Save</button>
197           </div>
198         </div>
199       </div>
200
201       <div id="note-edit-dialog" class="reveal-modal" data-reveal>
202         <a class="close-reveal-modal">&#215;</a>
203         <div class="row">
204           <div class="small-8 columns">
205             <h3>Edit Your Note</h3>
206           </div>
207           <div class="small-4 columns text-right">
208             <form method="POST" action="{% url 'note_delete' %}">
209               {% csrf_token %}
210               {{ note_delete_form }}
211               <button id="delete-note-button" type="submit" class="scary"><i class="fa fa-trash-o"></i> Delete Note</button>
212             </form>
213           </div>
214         </div>
215         <div class="row">
216           <form method="POST" action="{{ note.get_absolute_url }}">
217             {% csrf_token %}
218             <div class="small-12 large-6 columns">
219               {% with note_edit_form.name as field %}
220                 {{ field.errors|safe }}
221                 <label for="{{ field.id_for_label }}">{{ field.label }}:</label>
222                 {{ field }}
223                 <p>{{ field.help_text }}</p>
224               {% endwith %}
225             </div>
226             <div class="small-12 large-6 columns">
227               {% with note_edit_form.tags as field %}
228                 {{ field.errors|safe }}
229                 <label for="{{ field.id_for_label }}">{{ field.label }}:</label>
230                 {{ field }}
231                 <p>{{ field.help_text }}</p>
232               {% endwith %}
233             </div>
234             <div class="small-12 columns text-center">
235               <button type="submit"><i class="fa fa-save"></i> Save</button>
236             </div>
237           </form>
238         </div>
239       </div>
240
241     </div><!-- /note header -->
242
243     <div class="row">
244       <div id="tabs" class="small-12 columns">
245         <dl class="tabs">
246           <dd id="note-tab-button" class="{% if show_note_container %}active{% endif %}">
247             <a href="{{ note.get_absolute_url }}">Note</a>
248           </dd>
249           <dd id="keywords-tab-button" class="{% if show_keywords %}active{% endif %}">
250             <a href="{{ note.get_absolute_keywords_url }}">Key Terms & Definitions</a>
251           </dd>
252           <dd id="quiz-tab-button" class="{% if show_quiz %}active{% endif %}">
253             <a href="{{ note.get_absolute_quiz_url }}">Quiz Questions</a>
254           </dd>
255         </dl>
256         <div class="tabs-content">
257         </div>
258         {% if show_note_container %}
259           {% include 'notes/note_detail.html' %}
260         {% endif %}
261         {% if show_keywords %}
262           {% include 'notes/note_keywords.html' %}
263         {% endif %}
264         {% if show_quiz %}
265           {% include 'notes/note_quiz.html' %}
266         {% endif %}
267       </div>
268     </div>
269
270   </section><!--/note_content-->
271
272   <ol class="joyride-list" data-joyride
273         data-options="cookie_monster: true; cookie_name: note_detail_joyride">
274     <li data-id="note-content-wrapper" data-text="Awesome!" data-options="tip_location: top">
275       <p>You can highlight important words or phrases in this note to add definitions for them.</p>
276     </li>
277     <li data-id="keywords-tab-button" data-text="Awesome!" data-options="tip_location: top">
278       <p>Keywords you define will appear here, and you can define new ones here too.</p>
279     </li>
280     {% if note.thanks < 3 %}
281       <li data-id="thank-number" data-text="Awesome!" data-options="tip_location: top">
282         <p>Keywords and quizzes are automatically generated when a note gets {{ note.total_thanks_for_mturk }} thanks. This note needs {{ note.remaining_thanks_for_mturk }} more!</p>
283       </li>
284     {% endif %}
285   </ol>
286
287 {% endblock %}
288
289