<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
  css_bundle :quizzes
  js_bundle :quizzes_bundle
  js_env :QUIZZES => {:QUIZ => true}
  provide :page_title, (@quiz.quiz_title || !@quiz.quiz_title.empty? ? @quiz.quiz_title : t(:default_page_title, 'New Quiz'))
%>
<% provide :right_side do %>
  <a href="<%= context_url(@context, :context_quiz_url, @quiz.id) %>" class="btn button-sidebar-wide">
    <i class="icon-arrow-left"></i>
    <%= t('links.back_to_quiz_page', "Back to Quiz Page") %>
  </a>
<% end %>


<h2><%= t('headers.quiz_details', "Quiz Details") %></h2>
<div style="display: none;" id="quiz_urls">
  <a href="<%= context_url(@context, :context_quiz_url, @quiz.id) %>" class="update_quiz_url">&nbsp;</a>
  <a href="<%= context_url(@context, :context_quiz_quiz_questions_url, @quiz.id) %>" class="add_question_url">&nbsp;</a>
  <a href="<%= context_url(@context, :api_v1_context_quiz_reorder_url, @quiz.id) %>" class="reorder_questions_url">&nbsp;</a>
  <a href="<%= context_url(@context, :context_quiz_quiz_groups_url, @quiz.id) %>" class="add_group_url">&nbsp;</a>
</div>


<div style="margin-bottom: 25px;">
  <%= before_label(:quiz_instructions, "Quiz Instructions") %>
  <%= user_content(@quiz.description, @context.asset_string) %>
</div>
<div style="margin-bottom: 5px;">
  <input type="checkbox" id="show_question_details"/> <label for="show_question_details"><%= t('labels.question_details', "Show Question Details") %></label>
</div>
<div id="questions" class="brief">
  <% @quiz.root_entries.each do |question| %>
    <% if question[:entry_type] == "quiz_group" %>
      <%= render :partial => "question_group", :object => question %>
    <% else %>
      <%= render :partial => (@quiz.active_quiz_questions.size > 25 ? "question_teaser" : "display_question"), :object => question, :locals => {:editing => true, :asset_string => "quiz_question_#{question['id']}"} %>
    <% end %>
  <% end %>
</div>

<style>
#questions .question_holder .display_question .move {
  display: none;
}
#questions .question_holder .display_question .links {
  display: none;
}
#questions .group_top .quiz_group_form .links {
  display: none;
}

</style>

<%= render :partial => "question_teaser", :object => nil, :locals => {:editing => true } %>
<%= render :partial => "display_question", :object => nil, :locals => {:editing => true } %>
<%= render :partial => "display_answer", :object => nil %>
<%= render :partial => "form_answer", :object => nil %>
<%= render :partial => "form_question", :object => nil %>
<%= render :partial => "question_group", :object => nil %>
<%= render :partial => "find_question_from_bank" %>
