Display survey responses

This commit is contained in:
Pierre HUBERT 2019-01-14 21:19:06 +01:00
parent 4a24d5249c
commit 0e3aee13bd
3 changed files with 51 additions and 1 deletions

View File

@ -145,8 +145,28 @@
</div>
<!-- All survey responses -->
<div id="survey-responses" class="category container">
Loading survey responses
<h1>All your responses to surveys</h1>
<table id="all-survey-responses">
<thead>
<tr>
<th>Response number</th>
<th>Survey Number</th>
<th>Choice number</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<!-- Survey responses will go here -->
</tbody>
</table>
</div>
<div id="movies" class="category container">
@ -172,6 +192,7 @@
<script src="assets/js/categories/posts.js"></script>
<script src="assets/js/categories/comments.js"></script>
<script src="assets/js/categories/likes.js"></script>
<script src="assets/js/categories/survey.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>

View File

@ -0,0 +1,28 @@
/**
* Surveys category
*
* @author Pierre HUBERT
*/
/**
* Apply all survey responses
*/
function ApplySurveyResponses(){
let target = document.querySelector("#all-survey-responses tbody");
data.survey_responses.forEach(response => {
createElem2({
appendTo: target,
type: "tr",
innerHTML:
"<td>"+response.id+"</td>" +
"<td>"+response.surveyID+"</td>" +
"<td>"+response.choiceID+"</td>" +
"<td>"+timeToStr(response.time_sent)+"</td>"
})
});
}

View File

@ -78,6 +78,7 @@ xhr.onload = function(){
ApplyPosts();
ApplyCommentsList();
ApplyUserLikes();
ApplySurveyResponses();
}
xhr.send(null);