{% extends "manage.html" %}

{% block subtitle %}Edit Question{% endblock %}

{% block css %}
<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/question_quiz.css" type="text/css" />
<link rel="stylesheet" media="all" type="text/css" href="{{ URL_ROOT }}/static/yaksh/css/autotaggit.css" />
{% endblock %}
{% block script %}
<script src="{{ URL_ROOT }}/static/yaksh/js/edit_question.js"></script>
<script src="/static/yaksh/js/jquery-1.4.2.min.js" type="text/javascript"></script>
{% endblock %}

{% block onload %} onload = 'javascript:textareaformat();' {% endblock %}

{% block manage %}
<form name='frm' action="{{URL_ROOT}}/exam/manage/editquestion/" method="post" onSubmit="return autosubmit()" onKeyPress='javascript:render_question(frm);'>
  {% csrf_token %}
<center><p>Click on the Question links to edit the question.</p></center>

<table>

    {% for question, test in data_list %}
        
  <tr><td height=10><a id='a{{forloop.counter}}' onClick="data('contentDiv{{forloop.counter}}','myContent{{forloop.counter}}','a{{forloop.counter}}','{{question.summary.value}}');" style='cursor:pointer;'>{{question.summary.value}}</a>
  
        <div id="contentDiv{{forloop.counter}}" style="display:none;">
           <div id="myContent{{forloop.counter}}" style="display: none;">
        
        <center><table class=span1>
                 <tr><td><b>Summary:</b> <td>{{ question.summary }}{{ question.summary.errors }}
     <tr><td><b> Language: </b><td> {{question.language}}{{question.language.errors}} 
     <tr><td><b> Active: </b><td>&nbsp; {{ question.active }}{{question.active.errors}} &nbsp; Type: &nbsp;{{ question.type }}{{question.type.errors}}
     <tr><td><b>Points:<td><button class="btn-mini" name={{forloop.counter}} type="button" onClick="increase(frm,{{forloop.counter}});">+</button>{{ question.points }}<button class="btn-mini" type="button" onClick="decrease(frm,{{forloop.counter}});">-</button>{{ question.points.errors }}
                 <tr><td><strong>Rendered: </strong><td><p id='my{{forloop.counter}}'></p>
                 <tr><td><b>Description: <td>{{ question.description }}  
                 {{question.description.errors}} <tr><td><b>Test: <td>
                 {{ question.test }}{{question.test.errors}}
                 <tr><td><b>Snippet: <td>{{ question.snippet }}{{ question.snippet.errors }}
                 </td></b></td></tr>
     <tr><td><b>Tags: </b><td>{{ question.tags }}
     <tr><td id='label_option{{forloop.counter}}'><b>Options:<td>{{ question.options }}  
     {{question.options.errors}} {{question.options.helptext}}
              </table></center>
        <center><table class=span1>
                  {{ test }}              
              </table></center>
           </div>
        </div>
    {% endfor %}
</table></center>


{% for i in data %}
    <input type=hidden name='questions' value="{{ i }}" /> 
{% endfor %}

  <center><button class="btn" type="submit" name="savequestion">Save</button>
  <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/questions/");'>Cancel</button> </center>
</form>
{% endblock %}
