{#
 # ExoOnLine
 # Copyright or © or Copr. Université Jean Monnet (France), 2012
 # dsi.dev@univ-st-etienne.fr
 #
 # This software is a computer program whose purpose is to [describe
 # functionalities and technical features of your software].
 #
 # This software is governed by the CeCILL license under French law and
 # abiding by the rules of distribution of free software.  You can  use,
 # modify and/ or redistribute the software under the terms of the CeCILL
 # license as circulated by CEA, CNRS and INRIA at the following URL
 # "http://www.cecill.info".
 #
 # As a counterpart to the access to the source code and  rights to copy,
 # modify and redistribute granted by the license, users are provided only
 # with a limited warranty  and the software's author,  the holder of the
 # economic rights,  and the successive licensors  have only  limited
 # liability.
 #
 # In this respect, the user's attention is drawn to the risks associated
 # with loading,  using,  modifying and/or developing or reproducing the
 # software by the user in light of its specific status of free software,
 # that may mean  that it is complicated to manipulate,  and  that  also
 # therefore means  that it is reserved for developers  and  experienced
 # professionals having in-depth computer knowledge. Users are therefore
 # encouraged to load and test the software's suitability as regards their
 # requirements in conditions enabling the security of their systems and/or
 # data to be ensured and,  more generally, to use and operate it in the
 # same conditions as regards security.
 #
 # The fact that you are presently reading this means that you have had
 # knowledge of the CeCILL license and that you accept its terms.
#}

{% set layout = "ClarolineCoreBundle:Workspace:layout.html.twig" %}

{% if isDesktop() %}
    {% set layout = "ClarolineCoreBundle:Desktop:layout.html.twig" %}
{% endif %}

{% extends layout %}

{% block stylesheets %}
    {{ parent() }}
    <link href="{{ asset('bundles/ujmexo/css/tableLayout.css') }}" type="text/css" rel="stylesheet"/>
{% endblock %}

{% block title %} {{ 'exercise' | trans }} : {{ entity.title }} {% endblock %}

{% block section_content %}

    <div class="panel-heading">
        <h3 class="panel-title">{{ 'exercise'|trans }} : {{ entity.title }}</h3>
    </div>
    <div class="panel-body">
        {% if isDesktop() %}
            <a class="btn btn-primary" href="{{ path('claro_desktop_open_tool', { 'toolName': 'resource_manager', 'workspaceId': workspace.getId() }) ~ "#resources/" ~ _resource.getResourceNode().getParent().getId() }}">
                <i class="fa fa-arrow-left"></i> {{ 'back' | trans }}
            </a>
        {% else %}
            <a class="btn btn-primary" href="{{ path('claro_workspace_open_tool', { 'toolName': 'resource_manager', 'workspaceId': workspace.getId() }) ~ "#resources/" ~ _resource.getResourceNode().getParent().getId() }}">
                <i class="fa fa-arrow-left"></i> {{ 'back' | trans }}
            </a>
        {% endif %}
    </div>

    <div id='divPublish' class="alert alert-info" style='display:none'>
        {% if is_granted('EDIT', _resource) %}
            {{ 'infoExerciseNoPuplished'|trans }} : 
            <a id="btPublish" class="btn btn-primary" onclick="publish('{{ path('ujm_exercise_publish') }}', {{ entity.id }})">
                <i class="fa fa-check"></i> {{ 'publish' | trans }}
            </a>
        {% else %}
            {{ 'infoExerciseNoPuplished2'|trans }}
        {% endif %}
    </div>

    <div class="list-group">
        <div class="list-group-item">
            <table class="record_properties table table-striped table-bordered table-condensed">
                <tbody>
                    <tr>
                        <th class="classic">{{ 'title' | trans }}</th>
                        <td class="classic">{{ entity.title }}</td>
                    </tr>
                    <tr>
                        <th class="classic">{{ 'description' | trans }}</th>
                        <td class="classic">
                            {% if entity.description is not empty %}
                                {{ entity.description|raw }}
                            {% else %}
                                -
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <th class="classic">{{ 'start date' | trans }}</th>
                        <td class="classic">{{ entity.startdate|date('d/m/Y \\- H\\hi\\ms\\s') }}</td>
                    </tr>
                    <tr>
                        <th class="classic">{{ 'use date of end' | trans }}</th>
                        <td class="classic">
                            {% if entity.useDateEnd == 0 %}
                                <i class="fa fa-times-circle"></i>
                            {% else %}
                                <i class="fa fa-check-circle"></i>
                            {% endif %}
                        </td>
                    </tr>
                    {% if entity.useDateEnd != 0 %}
                        <tr>
                            <th class="classic">{{ 'end date' | trans }}</th>
                            <td class="classic">{{ entity.enddate|date('d/m/Y \\- H\\hi\\ms\\s') }}</td>
                        </tr>
                    {% endif %}

                    {% if is_granted('EDIT', _resource) %}
                        <tr class="hiddencells">
                            <th class="classic">{{ 'random order of questions' | trans }}</th>
                            <td class="classic">
                                {% if entity.shuffle == 0 %}
                                    <i class="fa fa-times-circle"></i>
                                {% else %}
                                    <i class="fa fa-check-circle"></i>
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'number of questions to draw' | trans }}</th>
                            <td class="classic">
                                {% if entity.nbQuestion != 0 %}
                                    {{ entity.nbQuestion }}
                                {% else %}
                                    {{ 'allQuestion'|trans }}
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'Exercise.keepSameQuestion' | trans }}</th>
                            <td class="classic">
                                {% if entity.keepSameQuestion == 0 %}
                                    <i class="fa fa-times-circle"></i>
                                {% else %}
                                    <i class="fa fa-check-circle"></i>
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'creationDate' | trans }}</th>
                            <td class="classic">{{ entity.dateCreate|date('d/m/Y \\- H\\hi\\ms\\s') }}</td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'duration' | trans }}</th>
                            <td class="classic">
                                {% if entity.duration != 0 %}
                                    {{ entity.duration }}
                                {% else %}
                                    {{ 'noOne'|trans }}
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'print paper' | trans }}</th>
                            <td class="classic">
                                {% if entity.doprint == 0 %}
                                    <i class="fa fa-times-circle"></i>
                                {% else %}
                                    <i class="fa fa-check-circle"></i>
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'maximum number of tries' | trans }}</th>
                            <td class="classic">
                                {% if entity.maxAttempts != 0 %}
                                    {{ entity.maxAttempts }}
                                {% else %}
                                    {{ 'infiny'|trans }}
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'availability of correction' | trans }}</th>
                            <td class="classic">
                                {% if(entity.correctionMode == 1) %}
                                    {{ 'at the end of assessment' | trans }}
                                {% elseif (entity.correctionMode == 2) %}
                                    {{ 'after the last attempt' | trans }}
                                {% elseif (entity.correctionMode == 3) %}
                                    {{ 'from' | trans }} : {{ entity.dateCorrection|date('d/m/Y \\- H\\hi\\ms\\s') }}
                                {% elseif (entity.correctionMode == 4) %}
                                    {{ 'never' | trans }}
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'availability of score' | trans }}</th>
                            <td class="classic">
                                {% if(entity.markMode == 1) %}
                                    {{ 'at the same time that the correction' | trans }}
                                {% else %}
                                    {{ 'at the end of assessment' | trans }}
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'test exit' | trans }}</th>
                            <td class="classic">
                                {% if  entity.dispButtonInterrupt == 0 %}
                                    <i class="fa fa-times-circle"></i>
                                {% else %}
                                    <i class="fa fa-check-circle"></i>
                                {% endif %}
                            </td>
                        </tr>
                        <tr class="hiddencells">
                            <th class="classic">{{ 'lock attempt' | trans }}</th>
                            <td class="classic">
                                {% if  entity.lockAttempt == 0 %}
                                    <i class="fa fa-times-circle"></i>
                                {% else %}
                                    <i class="fa fa-check-circle"></i>
                                {% endif %}
                            </td>
                        </tr>
                    {% endif %}
                </tbody>
            </table>
            {% if is_granted('EDIT', _resource) %}
                <button type="button" id="more" class="btn btn-primary" onclick="moreInformation();">
                    <i class="fa fa-plus"></i> {{ 'moreInformation' | trans }}
                </button>
                <button type="button" id="less" class="btn btn-primary" onclick="lessInformation();">
                    <i class="fa fa-minus"></i> {{ 'lessInformation' | trans }}
                </button>
            {% endif %}
        </div>
        <div class="text-center panel-footer">
            {% if allowToCompose == 1 and nbQuestion > 0 %}
                {% if nbUserPaper == 0 %}
                    <a class="btn btn-primary" href="{{ path('ujm_exercise_paper', { 'id': entity.id }) }}">
                        <i class="fa fa-check-square-o"></i> {{ 'compose' | trans }}
                    </a>
                {% else %}
                    <a class="btn btn-primary" href="{{ path('ujm_paper_list', { 'exoID': entity.id }) }}">
                        <i class="fa fa-check-square-o"></i> {{ 'compose' | trans }}
                    </a>
                {% endif %}
            {% endif %}
            {% if is_granted('EDIT', _resource) %}
                <a class="btn btn-primary" href="{{ path('ujm_exercise_edit', { 'id': entity.id }) }}">
                    <i class="fa fa-pencil"></i> {{ 'edit' | trans }}
                </a>
                <a class="btn btn-primary" href="{{ path('ujm_exercise_questions', { 'id': entity.id }) }} " >
                    <i class="fa fa-question"></i> {{ 'list of question' | trans }}
                </a>
                <span id='spanUnpublish' style='display:none'><a id="btUnpublish" class="btn btn-primary" onclick="unpublish('{{ path('ujm_exercise_unpublish') }}', {{ entity.id }})">
                    <i class="fa fa-times"></i> {{ 'unpublish' | trans }}
                    </a></span>
            {% endif %}
            <a class="btn btn-primary" href="{{ path('ujm_paper_list', { 'exoID': entity.id }) }}">
                <i class="fa fa-list"></i> {{ 'result' | trans }}
            </a>
        </div>
    </div>
{% endblock %}

{% block javascripts %}
    {{ parent() }}

    <script type="text/javascript" src="{{ asset('bundles/ujmexo/js/exercise.js') }}"></script>
    
        {% if published == false %}
            <script language="JavaScript">displayBtPublish();</script>
        {% else %}
            <script language="JavaScript">hideBtPublish();</script>
        {% endif %}
    
        {% if nbPapers == 0 and published == true %}
             <script language="JavaScript">displayBtUnpublish();</script>
        {% else %}
             <script language="JavaScript">hideBtUnpublish();</script>
        {% endif %}

    <script language="JavaScript">
        $('#less').css({"display" : "none"});
        lessInformation();

        function moreInformation() {
            $('.hiddencells').show();
            $('#less').css({"display" : "block"});
            $('#more').css({"display" : "none"});
        }

        function lessInformation() {
            $('.hiddencells').hide();
            $('#more').css({"display" : "block"});
            $('#less').css({"display" : "none"});
        }
    </script>
{% endblock %}