This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
atsebay.t/htdocs/views/survey.html

98 lines
7.0 KiB
HTML

<button class="btn btn-primary ml-1 float-right" ng-click="editSurvey()" ng-if="user.is_admin && !survey.edit"><svg class="bi bi-pencil" width="1em" height="1em" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M13.293 3.293a1 1 0 011.414 0l2 2a1 1 0 010 1.414l-9 9a1 1 0 01-.39.242l-3 1a1 1 0 01-1.266-1.265l1-3a1 1 0 01.242-.391l9-9zM14 4l2 2-9 9-3 1 1-3 9-9z" clip-rule="evenodd"></path><path fill-rule="evenodd" d="M14.146 8.354l-2.5-2.5.708-.708 2.5 2.5-.708.708zM5 12v.5a.5.5 0 00.5.5H6v.5a.5.5 0 00.5.5H7v.5a.5.5 0 00.5.5H8v-1.5a.5.5 0 00-.5-.5H7v-.5a.5.5 0 00-.5-.5H5z" clip-rule="evenodd"></path></svg></button>
<a href="surveys/{{ survey.id }}/responses" class="btn btn-success ml-1 float-right" ng-if="user.is_admin"><svg class="bi bi-documents" width="1em" height="1em" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M5 4h8a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2V6a2 2 0 012-2zm0 1a1 1 0 00-1 1v10a1 1 0 001 1h8a1 1 0 001-1V6a1 1 0 00-1-1H5z" clip-rule="evenodd"></path><path d="M7 2h8a2 2 0 012 2v10a2 2 0 01-2 2v-1a1 1 0 001-1V4a1 1 0 00-1-1H7a1 1 0 00-1 1H5a2 2 0 012-2z"></path></svg></a>
<h2>
{{ survey.title }}
<small>
<survey-badges survey="survey"></survey-badges>
</small>
</h2>
<form ng-submit="saveSurvey()" ng-if="user.is_admin && survey.edit">
<div class="form-group row">
<label for="title" class="col-2 col-form-label col-form-label-sm">Titre du questionnaire</label>
<div class="col-10">
<input type="text" class="form-control form-control-sm" id="title" ng-model="survey.title">
</div>
</div>
<div class="form-group row">
<label for="start_availability" class="col-2 col-form-label col-form-label-sm">Date de début</label>
<div class="col-10">
<input type="text" class="form-control form-control-sm" id="start_availability" ng-model="survey.start_availability">
</div>
</div>
<div class="form-group row">
<label for="end_availability" class="col-2 col-form-label col-form-label-sm">Date de fin</label>
<div class="col-10">
<input type="text" class="form-control form-control-sm" id="end_availability" ng-model="survey.end_availability">
</div>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="shown" ng-model="survey.shown">
<label class="form-check-label" for="shown">
Afficher le questionnaire
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="corrected" ng-model="survey.corrected">
<label class="form-check-label" for="corrected">
Marqué comme corrigé
</label>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Enregistrer</button>
<button type="button" class="btn btn-danger" ng-click="deleteSurvey()">Supprimer</button>
</div>
</div>
</form>
<form class="mb-5" ng-submit="submitAnswers()" ng-controller="QuestionsController" ng-if="survey.id" ng-cloak>
<div class="card mb-2" ng-repeat="(qid,question) in questions">
<div class="card-body">
<button class="btn btn-danger ml-1 float-right" ng-click="deleteQuestion()" ng-if="user.is_admin"><svg class="bi bi-trash-fill" width="1em" height="1em" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.5 3a1 1 0 00-1 1v1a1 1 0 001 1H5v9a2 2 0 002 2h6a2 2 0 002-2V6h.5a1 1 0 001-1V4a1 1 0 00-1-1H12a1 1 0 00-1-1H9a1 1 0 00-1 1H4.5zm3 4a.5.5 0 01.5.5v7a.5.5 0 01-1 0v-7a.5.5 0 01.5-.5zM10 7a.5.5 0 01.5.5v7a.5.5 0 01-1 0v-7A.5.5 0 0110 7zm3 .5a.5.5 0 00-1 0v7a.5.5 0 001 0v-7z" clip-rule="evenodd"></path></svg></button>
<button class="btn btn-success ml-1 float-right" ng-click="saveQuestion()" ng-if="user.is_admin && question.edit"><svg class="bi bi-check" width="1em" height="1em" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M15.854 5.646a.5.5 0 010 .708l-7 7a.5.5 0 01-.708 0l-3.5-3.5a.5.5 0 11.708-.708L8.5 12.293l6.646-6.647a.5.5 0 01.708 0z" clip-rule="evenodd"></path></svg></button>
<button class="btn btn-primary ml-1 float-right" ng-click="editQuestion()" ng-if="user.is_admin && !question.edit"><svg class="bi bi-pencil" width="1em" height="1em" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M13.293 3.293a1 1 0 011.414 0l2 2a1 1 0 010 1.414l-9 9a1 1 0 01-.39.242l-3 1a1 1 0 01-1.266-1.265l1-3a1 1 0 01.242-.391l9-9zM14 4l2 2-9 9-3 1 1-3 9-9z" clip-rule="evenodd"></path><path fill-rule="evenodd" d="M14.146 8.354l-2.5-2.5.708-.708 2.5 2.5-.708.708zM5 12v.5a.5.5 0 00.5.5H6v.5a.5.5 0 00.5.5H7v.5a.5.5 0 00.5.5H8v-1.5a.5.5 0 00-.5-.5H7v-.5a.5.5 0 00-.5-.5H5z" clip-rule="evenodd"></path></svg></button>
<h4 class="card-title" ng-if="!question.edit">{{qid + 1}}. {{ question.title }}</h4>
<div class="card-title form-group row" ng-if="question.edit"><label for="q{{qid}}title" class="col-auto col-form-label font-weight-bold">Titre&nbsp;:</label><div class="col"><input id="q{{qid}}title" class="form-control" ng-model="question.title"></div></div>
<p class="card-text" style="white-space: pre-line" ng-bind-html="question.description" ng-if="!question.edit"></p>
<textarea class="form-control mb-2" ng-if="question.edit" ng-model="question.description" placeholder="Description de la question"></textarea>
<div class="form-group row" ng-if="question.edit">
<label class="col-2 col-form-label" for="q{{qid}}kind">Type de réponse</label>
<div class="col">
<select class="custom-select" id="q{{qid}}kind" ng-model="question.kind">
<option value="text">Texte</option>
<option value="mcq">QCM</option>
</select>
</div>
</div>
<textarea class="form-control" ng-if="!question.edit && question.kind == 'text' && !survey.readonly" rows="6" ng-model="question.value" placeholder="{{ question.placeholder }}"></textarea>
<p class="card-text alert alert-secondary" style="white-space: pre-line" ng-bind="question.value" ng-if="!question.edit && survey.readonly"></p>
<div class="form-group row" ng-if="question.edit && question.kind == 'text'">
<label class="col-2 col-form-label" for="q{{qid}}placeholder">Placeholder</label>
<div class="col">
<input class="form-control" id="q{{qid}}placeholder" ng-model="question.placeholder">
</div>
</div>
<p class="card-text text-center text-danger" ng-if="question.kind == 'mcq'">QCM non implémentés</p>
<p class="card-text alert alert-success" style="white-space: pre-line" ng-if="!question.edit && (question.response.score_explaination || question.response.score)"><strong>{{question.response.score}}&nbsp;:</strong> {{ question.response.score_explaination }}</p>
</div>
</div>
<button type="submit" class="btn btn-primary" ng-disabled="submitInProgress">Soumettre les réponses</button>
<button type="button" class="btn btn-info" ng-click="addQuestion()" ng-if="user.is_admin">Ajouter une question</button>
</form>