courseware.html 9.23 KB
Newer Older
1
<%! from django.utils.translation import ugettext as _ %>
2
<%! from django.template.defaultfilters import escapejs %>
3
<%! from microsite_configuration import page_title_breadcrumbs %>
4
<%! from edxnotes.helpers import is_feature_enabled as is_edxnotes_enabled %>
5 6
<%inherit file="/main.html" />
<%namespace name='static' file='/static_content.html'/>
7 8 9 10
<%def name="course_name()">
 <% return _("{course_number} Courseware").format(course_number=course.display_number_with_default) %>
</%def>

11
<%block name="bodyclass">courseware ${course.css_class or ''}</%block>
12
<%block name="title"><title>
13
    % if section_title:
14 15 16
${page_title_breadcrumbs(section_title, course_name())}
    % else:
${page_title_breadcrumbs(course_name())}
17
    %endif
18
</title></%block>
19

20 21 22 23 24 25 26
<%block name="header_extras">
% for template_name in ["image-modal"]:
<script type="text/template" id="${template_name}-tpl">
    <%static:include path="js/${template_name}.underscore" />
</script>
% endfor

27 28 29 30 31 32 33
% for template_name in ["search_item", "search_list", "search_loading", "search_error"]:
<script type="text/template" id="${template_name}-tpl">
    <%static:include path="courseware_search/${template_name}.underscore" />
</script>
% endfor

</%block>
34

35
<%block name="headextra">
36 37
<%static:css group='style-course-vendor'/>
<%static:css group='style-course'/>
38 39 40 41
## Utility: Notes
% if is_edxnotes_enabled(course):
<%static:css group='style-student-notes'/>
% endif
42

43
<%block name="nav_skip">${"#seq_content" if section_title else "#course-content"}</%block>
44

45 46
<%include file="../discussion/_js_head_dependencies.html" />

47
  % if show_chat:
48 49 50 51 52 53
    <link rel="stylesheet" href="${static.url('css/vendor/ui-lightness/jquery-ui-1.8.22.custom.css')}" />
    ## It'd be better to have this in a place like lms/css/vendor/candy,
    ## but the candy_res/ folder contains images and other junk, and it
    ## all needs to stay together for the Candy.js plugin to work.
    <link rel="stylesheet" href="${static.url('candy_res/candy_full.css')}" />
  % endif
54
  ${fragment.head_html()}
55 56
</%block>

57
<%block name="js_extra">
58
  <script type="text/javascript" src="${static.url('js/vendor/jquery.scrollTo-1.4.2-min.js')}"></script>
59 60 61 62 63
  <script type="text/javascript" src="${static.url('js/vendor/flot/jquery.flot.js')}"></script>

  ## codemirror
  <script type="text/javascript" src="${static.url('js/vendor/codemirror-compressed.js')}"></script>

64
  <%static:js group='courseware'/>
65
  <%static:js group='discussion'/>
66

Rocky Duan committed
67
  <%include file="../discussion/_js_body_dependencies.html" />
68 69 70
  % if staff_access:
  	<%include file="xqa_interface.html"/>
  % endif
71

72
  <script type="text/javascript">
73
    var $$course_id = "${course.id | escapejs}";
74 75

    $(function(){
76
        $(".ui-accordion-header a, .ui-accordion-content .subtitle").each(function() {
kimth committed
77 78
          var elemText = $(this).text().replace(/^\s+|\s+$/g,''); // Strip leading and trailing whitespace
          var wordArray = elemText.split(" ");
79
          var finalTitle = "";
kimth committed
80
          if (wordArray.length > 0) {
81 82 83 84
            for (i=0;i<=wordArray.length-1;i++) {
              finalTitle += wordArray[i];
              if (i == (wordArray.length-2)) {
                finalTitle += "&nbsp;";
kimth committed
85 86
              } else if (i == (wordArray.length-1)) {
                // Do nothing
87 88 89
              } else {
                finalTitle += " ";
              }
90 91
            }
          }
kimth committed
92
          $(this).html(finalTitle);
93 94
        });
      });
95
  </script>
96

97
% if timer_expiration_duration:
98
  <script type="text/javascript">
99
    var timer = {
100 101 102
      timer_inst : null,
      end_time : null,
      get_remaining_secs : function(endTime) {
103 104 105 106 107 108 109 110 111 112 113 114 115
        var currentTime = new Date();
        var remaining_secs = Math.floor((endTime - currentTime)/1000);
        return remaining_secs;
      },
      get_time_string : function() {
        function pretty_time_string(num) {
          return ( num < 10 ? "0" : "" ) + num;
        }
        // count down in terms of hours, minutes, and seconds:
        var hours = pretty_time_string(Math.floor(remaining_secs / 3600));
        remaining_secs = remaining_secs % 3600;
        var minutes = pretty_time_string(Math.floor(remaining_secs / 60));
        remaining_secs = remaining_secs % 60;
116 117
        var seconds = pretty_time_string(Math.floor(remaining_secs));

118 119 120 121
        var remainingTimeString = hours + ":" + minutes + ":" + seconds;
        return remainingTimeString;
      },
      update_time : function(self) {
122
        remaining_secs = self.get_remaining_secs(self.end_time);
123 124 125 126 127 128
        if (remaining_secs <= 0) {
          self.end(self);
        }
        $('#exam_timer').text(self.get_time_string(remaining_secs));
      },
      start : function() { var that = this;
129 130 131
        // set the end time when the template is rendered.
        // This value should be UTC time as number of milliseconds since epoch.
        this.end_time = new Date((new Date()).getTime() + ${timer_expiration_duration});
132 133 134 135 136
        this.timer_inst = setInterval(function(){ that.update_time(that); }, 1000);
      },
      end : function(self) {
        clearInterval(self.timer_inst);
        // redirect to specified URL:
137
        window.location = "${time_expired_redirect_url}";
138
      }
139 140 141
    }
    // start timer right away:
    timer.start();
142 143 144
  </script>
% endif

145
% if show_chat:
146 147
  <script type="text/javascript" src="${static.url('js/vendor/candy_libs/libs.min.js')}"></script>
  <script type="text/javascript" src="${static.url('js/vendor/candy.min.js')}"></script>
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178

  <script type="text/javascript">
    // initialize the Candy.js plugin
    $(document).ready(function() {
      Candy.init("http://${chat['domain']}:5280/http-bind/", {
        core: { debug: true, autojoin: ["${chat['room']}@conference.${chat['domain']}"] },
        view: { resources: "${static.url('candy_res/')}"}
      });
      Candy.Core.connect("${chat['username']}", "${chat['password']}");

      // show/hide the chat widget
      $('#chat-toggle').click(function() {
        var toggle = $(this);
        if (toggle.hasClass('closed')) {
          $('#chat-block').show().animate({height: '400px'}, 'slow', function() {
            $('#chat-open').hide();
            $('#chat-close').show();
          });
        } else {
          $('#chat-block').animate({height: '0px'}, 'slow', function() {
            $('#chat-open').show();
            $('#chat-close').hide();
            $(this).hide(); // do this at the very end
          });
        }
        toggle.toggleClass('closed');
      });
    });
  </script>
% endif

179 180
${fragment.foot_html()}

181
</%block>
pmitros committed
182

183
% if timer_expiration_duration:
184 185 186
<div class="timer-main">
  <div id="timer_wrapper">
    % if timer_navigation_return_url:
187
    <a href="${timer_navigation_return_url}" class="timer_return_url">${_("Return to Exam")}</a>
188
    % endif
189
    <div class="timer_label">Time Remaining:</div> <div id="exam_timer" class="timer_value">&nbsp;</div>
190 191 192 193
  </div>
</div>
% endif

194
<%include file="/dashboard/_dashboard_prompt_midcourse_reverify.html" />
195 196 197
% if default_tab:
  <%include file="/courseware/course_navigation.html" />
% else:
198
  <%include file="/courseware/course_navigation.html" args="active_page='courseware'" />
199
% endif
200

201
<div class="container">
202
  <div class="course-wrapper">
203

Piotr Mitros committed
204
% if disable_accordion is UNDEFINED or not disable_accordion:
205
    <div class="course-index" role="navigation">
206
      <header id="open_close_accordion">
207
        <a href="#">${_("close")}</a>
208
      </header>
209

210
      % if settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH'):
Davorin Sego committed
211 212 213 214 215 216 217 218 219 220
        <div id="courseware-search-bar" class="courseware-search-bar" role="search" aria-label="Course">
          <form>
            <label for="course-search-input" class="sr">${_('Course Search')}</label>
            <input id="course-search-input" type="text" class="search-field"/>
            <button type="submit" class="search-button">
              ${_('search')} <i class="icon fa fa-search" aria-hidden="true"></i>
            </button>
            <button type="button" class="cancel-button" aria-label="${_('Clear search')}">
              <i class="icon fa fa-remove" aria-hidden="true"></i>
            </button>
221 222 223 224
          </form>
        </div>
      % endif

225
      <div id="accordion" style="display: none">
226
        <nav aria-label="${_('Course Navigation')}">
227 228 229 230 231
          % if accordion.strip():
            ${accordion}
          % else:
            <div class="chapter">${_("No content has been added to this course")}</div>
          % endif
232
        </nav>
233
      </div>
234
    </div>
235
% endif
236
    <section class="course-content" id="course-content">
237
      ${fragment.body_html()}
238
    </section>
239 240 241 242
    % if settings.FEATURES.get('ENABLE_COURSEWARE_SEARCH'):
      <section class="courseware-search-results" id="courseware-search-results" data-course-id="${course.id}" data-course-name="${course.display_name_with_default}">
      </section>
    % endif
243
  </div>
244
</div>
Matthew Mongeau committed
245

246 247
<nav class="nav-utilities ${"has-utility-calculator" if course.show_calculator else ""}">
  <h2 class="sr nav-utilities-title">${_('Course Utilities Navigation')}</h2>
248

249 250 251 252
  ## Utility: Chat
  % if show_chat:
    <%include file="/chat/toggle_chat.html" />
  % endif
253

254 255 256 257
  ## Utility: Notes
  % if is_edxnotes_enabled(course):
    <%include file="/edxnotes/toggle_notes.html" args="course=course"/>
  % endif
258

259 260 261 262 263
  ## Utility: Calc
  % if course.show_calculator:
    <%include file="/calculator/toggle_calculator.html" />
  % endif
</nav>
264

265
<%include file="../modal/accessible_confirm.html" />