{% extends "layout.html" %} {% block content %}
<main class="container">
  <div class="row mt-3">
    <section class="col-12">
      <div class="d-flex flex-column">
        <u class="h3 primary-colour align-self-center">Here are a list of significant findings we have found in your data</u>
        {% if count != 0 %}
        <form class="align-self-end" action="{{ url_for('surveys.delete_findings')}}" method="post" onsubmit="return confirm('Are you sure you want to delete all notifications?');">
          <button class="btn btn-danger" type="submit">Delete all</button>
        </form>
        {% endif %}
      </div>
      <p class="lead">Note: please check the assumptions are correct with your data before accepting the result.
      Just because a result does not appear here, it does not mean that it is not significant. If a particular test
      you are looking for does not appear on this list, you can add it on your survey dashboard page.</p>
      {% if count == 0 %}
        <div class="p-4 rounded border bg-white shadow-sm text-center">
          <p class="lead m-0 text-muted">No findings at the moment! Try uploading a file and we will check it for you.</p>
        </div>
      {% else %}
        {% for notification in notifications %}
          <section class="card w-100 mb-4">
            <div class="card-body">
              <form action="{{ url_for('surveys.findings', result_id=notification._id,
                                                          p=notification.result.p_value,
                                                          independent_variable=notification.result.variable_1,
                                                          dependent_variable=notification.result.variable_2,
                                                          survey_id=notification.survey_id,
                                                          test=notification.result.test)}}" method="post">
              {{ form.hidden_tag() }}
              {% if notification.result.variable_2 == "" %}
                {% set f = form.title.process_data("" + notification.result.variable_1 + ": " + notification.result.test) %}
              {% else %}
                {% set f = form.title.process_data("" + notification.result.variable_1 + "/" + notification.result.variable_2 + ": " + notification.result.test) %}
              {% endif %}
              {{ form.title(class="form-control") }}
              <table class="table table-bordered mt-3">
                <thead class="thead-light">
                  <tr>
                    <th class="help" scope="col"data-toggle="tooltip"
                    title="This is the hypothesis that there are NO significant differences of characteristics between specifed populations.">
                    Null Hypothesis</th>
                    <th class="help" scope="col"data-toggle="tooltip"
                    title="This is the type of statistical test used to test the null hypothesis.">
                    Statistical Test</th>
                    <th class="help" scope="col" data-toggle="tooltip" data-placement="left"
                    title="Sometimes called 'Alpha', the significance value is the probability of rejecting the null hypothesis when it is true.
                    It can be though of as a 'cut-off' point; when the p-value is lower you can reject the null hypothesis. We have set this to a default
                    of 0.05 (indicating a 5% risk of no actual difference when concluding that a difference exists).">
                    Significance value</th>
                    <th class="help" scope="col" data-toggle="tooltip" data-placement="left"
                    title="If we assume that the null hypothesis is true, the p-value gives the probability of obtaining the results as extreme as the
                      observed results of the statistical test. This value is compared against the significance value, with a lower p-value meaning we
                      can reject the null hypothesis.">
                    P-Value</th>
                    <th class="help" scope="col" data-toggle='tooltip'
                    title='Whether we should reject or accept the null hypothesis.'>
                    Conclusion</th>
                  </tr>
                </thead>
               <tr class="primary-colour">
                <td>{{ notification.result.null }}</td>
                <td>{{ notification.result.test }}</td>
                <td>0.05</td>
                {% if notification.result.p_value == 0.0 %}
                  <td>&lt;0.001</td>

                {% else %}
                  <td>{{ notification.result.p_value }}</td>
                {% endif %}
                <td>Reject the null hypothesis</td>
               </tr>
              </table>
              <p class="card-text">{{ notification.result.info }}</p>
              <div class="d-flex justify-content-end">
                {{ form.submit(class="btn btn-primary") }}
              </div>
            </form>
            <form class="float-right mt-1" action="{{ url_for('surveys.delete_temp_result', result_id=notification['_id'] )}}" method="post">
              <button class="btn btn-danger" type="submit">Delete result</button>
            </form>
            </div>
          </section>
        {% endfor %}
      {% endif %}
    </section>
  </div>
</main>
<script type="text/javascript">
  // Using Jquery, initialise Popper.js tooltips
  $(function () {
      $("[data-toggle='tooltip']").tooltip();
  });
</script>
{% endblock content %}
