{% extends "base.html" %}
{% block title %} actividad | {{super}}{%endblock %}

{% block ver_perfil%}
"{%url ver_perfil informacion.asignatura.slug %}"
{% endblock%}
{%block escoge-asignatura%}
  {{informacion.asignatura.slug}}
{%endblock%}

{% block navbar%}
{%include "app/include/menu.html"%}
{%endblock%}


{% block content %}

      <h1>Tarea {{tarea.actividades.name}} </h1>
      <hr>


<div class="row-fluid">
      <div class="span8" id="cuestionario">
            <div class="cuestionario">
                {%if tarea %}
                  <form action="{%url realizar_tarea informacion.asignatura.slug tarea.actividades.id %}" method='POST' id="tareaForm" enctype="multipart/form-data">
                  {% csrf_token %}
       
                  {% for pregunta in preguntas %}
                  <div class="pregunta">
                      <h2><span class="num">{{ forloop.counter }}</span></h2><h3>{{pregunta.text}}</h3>
                            <p>

                              {% ifequal pregunta.type 1 %}
                                  <p>
                                    <div class="btn-group">
                                          <textarea class="x-large" style="width:100%;"cols="100" rows="10" value="" name="hash[{{pregunta.nr}}]"></textarea>
                                        </div>
                                  </p>
                              {% else %}
                                {%if pregunta.type == 6%}
                                    <input name="hash[{{pregunta.nr}}]" type="file" size="10" accept="image/gif,image/jpg,image/jpeg,image/png,image/bmp" />
                                {%else%}
                                       {% if pregunta.type == 2 or pregunta.type == 4  or pregunta.type == 5%}
                                        <div class="btn-group" data-toggle="buttons-radio">
                                       {%else%}
                                        <div class="btn-group" data-toggle="buttons-checkbox">
                                       {%endif%}
                                        {% for respuesta in pregunta.tarea_eleccion_pregunta.all%}

                                            <label class="btn btn-primary">
                                              {% if respuesta.pregunta.type != 3 %}
                                              <input type="radio" value="{{respuesta.name}}" class="btn btn-primary" style="color:yellow;" name="hash[{{pregunta.nr}}]"/>
                                              {{respuesta.name}}
                                              {%else%}
                                              <input type="checkbox" value="{{respuesta.name}}" class="btn btn-primary" style="color:yellow;" name="hash[{{pregunta.nr}}-{{respuesta.nr}}]"/>
                                              {{respuesta.name}}                                      {%endif%}
                                            </label>
                                        {% empty %}
                                          Sin preguntas
                                        {% endfor%}
                                        </div>
                                      </p>
                                  {%endif%}
                              {%endifequal%}
                        </div>

                {% endfor%}
                {% endif %}
                  </div>
            </div>
          </p></div>

            <a href="#Enviar_tarea" role="button"  class="btn btn-primary btn-large offset2" value="Enviar"  data-toggle="modal">Enviar</a>

            <!-- Modal -->
            <div id="Enviar_tarea" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

            <div class="modal-body">
              <p>¿Esta seguro de enviar la tarea?</p>
              <p class="pull-right">
              <input type="submit" class="btn btn-primary btn-large" value="Si" id="sendButton" />
              <button class="btn btn-primary btn-large" data-dismiss="modal" aria-hidden="true">No</button>
              </p>
            </div>

            </div>


          </form>
          <div id="SUCCESS_FORM"></div>
          </div>

      </div>
</div>
      

{% endblock%}

{% block extra_js%}
<script type="text/javascript">

$(document).ready(function(){



});

$('input:radio').click(function(){
});

$("form").submit(function(event) {
    //event.preventDefault();

    $.ajax({
        type: $(this).attr('method'),
        url: $(this).attr('action'),
        data: $(this).serialize(),
        dataType: "text",
        success: function(response) {
                    $('#SUCCESS_FORM).html(response)');
                }
            });
            return false;
        });
    });
</script>


{%endblock%}