<%inherit file="base.html" />
<%namespace name='static' file='static_content.html'/>

<%!
  from django.core.urlresolvers import reverse
  from django.utils.translation import ugettext as _
  import json
%>
<%block name="title">${_("Course Export")}</%block>
<%block name="bodyclass">is-signedin course tools view-export</%block>

<%block name="jsextra">
  % if in_err:
  <script type='text/javascript'>
var hasUnit = ${json.dumps(bool(unit))},
    editUnitUrl = "${edit_unit_url or ""}",
    courseHomeUrl = "${course_home_url or ""}",
    errMsg = "${raw_err_msg or ""}";

require(["domReady!", "gettext", "js/views/feedback_prompt"], function(doc, gettext, PromptView) {
  var dialog;
  if(hasUnit) {
    dialog = new PromptView({
      title: gettext('There has been an error while exporting.'),
      message: gettext("There has been a failure to export to XML at least one component. It is recommended that you go to the edit page and repair the error before attempting another export. Please check that all components on the page are valid and do not display any error messages."),
      intent: "error",
      actions: {
        primary: {
          text: gettext('Correct failed component'),
          click: function(view) {
            view.hide();
            document.location = editUnitUrl;
          }
        },
        secondary: {
          text: gettext('Return to Export'),
          click: function(view) {
            view.hide();
          }
        }
      }
    });
  } else {
    var msg = "<p>" + gettext("There has been a failure to export your course to XML. Unfortunately, we do not have specific enough information to assist you in identifying the failed component. It is recommended that you inspect your courseware to identify any components in error and try again.") + "</p><p>" + gettext("The raw error message is:") + "</p>" + errMsg;
    dialog = new PromptView({
      title: gettext('There has been an error with your export.'),
      message: msg,
      intent: "error",
      actions: {
        primary: {
          text: gettext('Yes, take me to the main course page'),
          click: function(view) {
            view.hide();
            document.location = courseHomeUrl;
          }
        },
        secondary: {
          text: gettext('Cancel'),
          click: function(view) {
            view.hide();
          }
        }
      }
    });
  }

  // The CSS animation for the dialog relies on the 'js' class
  // being on the body. This happens after this JavaScript is executed,
  // causing a "bouncing" of the dialog after it is initially shown.
  // As a workaround, add this class first.
  $('body').addClass('js');
  dialog.show();

});
  </script>
  %endif
</%block>

<%block name="content">
<div class="wrapper-mast wrapper">
  <header class="mast has-subtitle">
    <h1 class="page-header">
      <small class="subtitle">${_("Tools")}</small>
      <span class="sr">&gt; </span>${_("Course Export")}
    </h1>
  </header>
</div>

<div class="wrapper-content wrapper">
  <section class="content">
    <article class="content-primary" role="main">

      <div class="introduction">
        <h2 class="title">${_("About Exporting Courses")}</h2>
        <div class="copy">
          ## Translators: ".tar.gz" is a file extension, and should not be translated

          <p>${_("You can export this course to edit it outside of Studio. Select the Export Course Content button below to download a .{em_start}tar.gz{em_end} file that contains the course content.").format(em_start='<strong>', em_end="</strong>")}</p>
        </div>
      </div>

      <div class="export-controls">
        <h2 class="title">${_("Export a Copy of My Course Data")}</h2>

        <ul class="list-actions">
          <li class="item-action">
            <a class="action action-export action-primary" href="${export_url}">
              <i class="icon-download"></i>
              <span class="copy">${_("Export Course Content")}</span>
            </a>
          </li>
        </ul>
      </div>

      <div class="export-contents">
        <div class="export-includes">
          <h3 class="title-3">${_("Data {em_start}exported with{em_end} your course:").format(em_start='<strong>', em_end="</strong>")}</h3>
          <ul class="list-details list-export-includes">
            <li class="item-detail">${_("Course Content (all Sections, Sub-sections, and Units)")}</li>
            <li class="item-detail">${_("Course Structure")}</li>
            <li class="item-detail">${_("Individual Problems")}</li>
            <li class="item-detail">${_("Static Pages")}</li>
            <li class="item-detail">${_("Course Assets")}</li>
            <li class="item-detail">${_("Course Settings")}</li>
          </ul>
        </div>

        <div class="export-excludes">
          <h3 class="title-3">${_("Data {em_start}not exported{em_end} with your course:").format(em_start='<strong>', em_end="</strong>")}</h3>
          <ul class="list-details list-export-excludes">
            <li class="item-detail">${_("User Data")}</li>
            <li class="item-detail">${_("Course Team Data")}</li>
            <li class="item-detail">${_("Forum/discussion Data")}</li>
            <li class="item-detail">${_("Certificates")}</li>
          </ul>
        </div>
      </div>
    </article>

    <aside class="content-supplementary" role="complimentary">
      <div class="bit">
        <h3 class="title-3">${_("Why export my course?")}</h3>

        <ul class="list-details">
          <li class="item-detail">${_("Edit the course XML directly, then import the modified course.")}</li>
          <li class="item-detail">${_("Store a backup of your course in its current state.")}</li>
          <li class="item-detail">${_("Import the course into another course instance, to create a customized version of your course.")}</li>
        </ul>
      </div>

      <div class="bit">
        <h3 class="title-3">${_("Opening the downloaded file")}</h3>

        <p>${_("Extract the .tar.gz with an archive program on your computer.  Extracted data includes the course.xml file, as well as subfolders containing course content.")}</p>
      </div>

      <div class="bit">
        ## Translators: ".tar.gz" is a file extension, and should not be translated
        <h3 class="title-3">${_("Course Team Data")}</h3>

        <p>${_("Note that course team data is not exported, and that course team data is not changed when importing a course.")}</p>
      </div>
    </aside>
  </section>
</div>
</%block>
