mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-21 07:58:22 +02:00
Update questions
This commit is contained in:
@ -102,7 +102,6 @@
|
||||
<button class="btn btn-info" data-toggle="modal" data-target="#displaySolutionModal">{% trans "Display" %}</button>
|
||||
{% endif %}
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
{% if current_phase.phase_number == 2 %}
|
||||
<div class="alert alert-info">
|
||||
@ -113,6 +112,14 @@
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
|
||||
{% for question in participation.questions.all %}
|
||||
<dd class="col-md-9 text-truncate">{{ question.question }}</dd>
|
||||
<dd class="col-md-3">
|
||||
<button class="btn btn-primary" data-toggle="modal" data-target="#updateQuestion{{ forloop.counter }}Modal">{% trans "Change" %}</button>
|
||||
</dd>
|
||||
<hr>
|
||||
{% endfor %}
|
||||
|
||||
{% if user.registration.participates %}
|
||||
<button class="btn btn-success" data-toggle="modal" data-target="#addQuestionModal">
|
||||
<i class="fas fa-plus-circle"></i> {% trans "Add a question" %}
|
||||
@ -132,6 +139,7 @@
|
||||
{% elif current_phase.phase_number == 4 %}
|
||||
{# TODO Send synthesis #}
|
||||
{% endif %}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -171,7 +179,17 @@
|
||||
{% trans "Add question" as modal_title %}
|
||||
{% trans "Add" as modal_button %}
|
||||
{% url "participation:add_question" pk=participation.pk as modal_action %}
|
||||
{% include "base_modal.html" with modal_id="addQuestion" modal_button_type="success" %}
|
||||
{% include "base_modal.html" with modal_id="addQuestion" modal_button_type="success" %}
|
||||
{% for question in participation.questions.all %}
|
||||
{% trans "Update question" as modal_title %}
|
||||
{% trans "Update" as modal_button %}
|
||||
{% url "participation:update_question" pk=question.pk as modal_action %}
|
||||
{% with number_str=forloop.counter|stringformat:"d" %}
|
||||
{% with modal_id="updateQuestion"|add:number_str %}
|
||||
{% include "base_modal.html" %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@ -198,6 +216,14 @@
|
||||
if (!modalBody.html().trim())
|
||||
modalBody.load("{% url "participation:add_question" pk=participation.pk %} #form-content");
|
||||
});
|
||||
|
||||
{% for question in participation.questions.all %}
|
||||
$('button[data-target="#updateQuestion{{ forloop.counter }}Modal"]').click(function() {
|
||||
let modalBody = $("#updateQuestion{{ forloop.counter }}Modal div.modal-body");
|
||||
if (!modalBody.html().trim())
|
||||
modalBody.load("{% url "participation:update_question" pk=question.pk %} #form-content");
|
||||
});
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
$('button[data-target="#uploadSolutionModal"]').click(function() {
|
||||
|
@ -25,7 +25,7 @@ urlpatterns = [
|
||||
path("detail/<int:pk>/send-participation/", SetParticipationSendParticipationView.as_view(),
|
||||
name="participation_send_participation"),
|
||||
path("detail/<int:pk>/add-question/", CreateQuestionView.as_view(), name="add_question"),
|
||||
path("update-question/<int:pk>/", CreateQuestionView.as_view(), name="update_question"),
|
||||
path("update-question/<int:pk>/", UpdateQuestionView.as_view(), name="update_question"),
|
||||
path("calendar/", CalendarView.as_view(), name="calendar"),
|
||||
path("calendar/<int:pk>/", PhaseUpdateView.as_view(), name="update_phase"),
|
||||
path("chat/", TemplateView.as_view(template_name="participation/chat.html"), name="chat")
|
||||
|
@ -417,7 +417,7 @@ class UpdateQuestionView(LoginRequiredMixin, UpdateView):
|
||||
form_class = QuestionForm
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.object = self.get_object(**kwargs)
|
||||
self.object = self.get_object()
|
||||
if not request.user.is_authenticated:
|
||||
return self.handle_no_permission()
|
||||
if request.user.registration.is_admin or \
|
||||
|
Reference in New Issue
Block a user