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

136 lines
11 KiB
HTML

<button class="btn btn-primary ml-1 float-right" ng-click="editSurvey()" title="Éditer" 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" title="Voir les réponses" 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="promo" class="col-2 col-form-label col-form-label-sm">Promo</label>
<div class="col-10">
<input type="number" step="1" min="0" max="2068" class="form-control form-control-sm" id="promo" ng-model="survey.promo">
</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-if="survey.id" ng-click="deleteSurvey()">Supprimer</button>
<button type="button" class="btn btn-secondary" ng-if="survey.id" ng-click="duplicateSurvey()">Dupliquer avec ces nouveaux paramètres</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" ng-bind-html="question.description" ng-if="!question.edit"></p>
<textarea class="form-control mb-2" ng-if="question.edit" ng-model="question.desc_raw" 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="int">Entier</option>
<option value="ucq">QCU</option>
<option value="mcq">QCM</option>
</select>
</div>
</div>
<textarea class="form-control" ng-if="!question.edit && question.kind == 'text' && (!survey.readonly || user.is_admin)" rows="6" ng-model="question.value" placeholder="{{ question.placeholder }}"></textarea>
<input class="ml-5 col-sm-2 form-control" type="number" ng-if="!question.edit && question.kind == 'int' && !survey.readonly" ng-model="question.value" placeholder="{{ question.placeholder }}">
<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' || question.kind == 'int')">
<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>
<div ng-controller="ProposalsController" ng-if="question.kind == 'ucq' || question.kind == 'mcq'">
<div class="form-group form-check" ng-if="!question.edit && question.kind == 'mcq'" ng-repeat="proposal in proposals">
<input type="checkbox" class="form-check-input" id="p{{proposal.id}}" ng-model="question['p' + proposal.id]" ng-disabled="survey.readonly">
<label class="form-check-label" for="p{{proposal.id}}">{{ proposal.label }}</label>
</div>
<div class="form-group form-check" ng-if="!question.edit && question.kind == 'ucq'" ng-repeat="proposal in proposals">
<input type="radio" class="form-check-input" name="proposals{{question.id}}" id="p{{proposal.id}}" ng-model="question.value" value="{{proposal.id}}" ng-disabled="survey.readonly">
<label class="form-check-label" for="p{{proposal.id}}">{{ proposal.label }}</label>
</div>
<div class="form-group row" ng-if="question.edit" ng-repeat="proposal in proposals">
<div class="col">
<input type="text" class="form-control" id="pi{{proposal.id}}" placeholder="Label" ng-model="proposal.label">
</div>
<div class="col-auto">
<button type="button" class="btn btn-success ml-1" ng-click="saveProposal()" ng-if="question.edit && (question.kind == 'ucq' || question.kind == 'mcq')"><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 type="button" class="btn btn-danger ml-1" ng-click="deleteProposal()" ng-if="question.edit && (question.kind == 'ucq' || question.kind == 'mcq')"><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>
</div>
</div>
<button type="button" class="btn btn-info ml-1" ng-click="addProposal()" ng-if="question.edit && (question.kind == 'ucq' || question.kind == 'mcq')" ng-disabled="!question.id"><svg class="bi bi-plus" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M8 3.5a.5.5 0 01.5.5v4a.5.5 0 01-.5.5H4a.5.5 0 010-1h3.5V4a.5.5 0 01.5-.5z" clip-rule="evenodd"></path><path fill-rule="evenodd" d="M7.5 8a.5.5 0 01.5-.5h4a.5.5 0 010 1H8.5V12a.5.5 0 01-1 0V8z" clip-rule="evenodd"></path></svg> Ajouter des proposals
</button><span ng-show="question.edit && (question.kind == 'ucq' || question.kind == 'mcq') && !question.id" class="ml-2" style="font-style:italic"> Créez la question pour ajouter des propositions</span>
</div>
<div class="ml-3 card-text alert alert-success" ng-if="!question.edit && (question.response.score_explaination || question.response.score)">
<div class="row">
<div class="col-auto">
<strong>{{question.response.score}}&nbsp;%</strong>
</div>
<p class="col mb-0" style="white-space: pre-line">{{ question.response.score_explaination }}</p>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary" ng-disabled="submitInProgress" ng-if="showSubmit">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>