Commit cf0c6559 authored by ericksho-ipre's avatar ericksho-ipre

falta la seguridad, el flujo del alumno y profe para llegar y falta evitar que...

falta la seguridad, el flujo del alumno y profe para llegar y falta evitar que haga mil clicks sobre Preguntar
parent 6b6a7f51
...@@ -4,21 +4,13 @@ ...@@ -4,21 +4,13 @@
<h1>Evento {{ event.name }}</h1> <h1>Evento {{ event.name }}</h1>
<div id="questions"> <div id="questions">
{% for question in questions %}
<div data-sort="{{ question.dataSort() }}" id="q{{ question.id }}" class="question-div">
<h5>{{ question.question }}</h5>
<p>{% if question.asked %}{{ question.asked|date('Y-m-d') }}{% endif %}
<button type="button" class="btn btn-default btn-xs" qid="{{question.id}}" onclick="upvote(this)"><div class="n-lovers">{{ question.nLovers }}</div><span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span></button>
<button type="button" class="btn btn-default btn-xs" qid="{{question.id}}" onclick="downvote(this)"><div class="n-haters">{{ question.nhaters }}</div><span class="glyphicon glyphicon-thumbs-down" aria-hidden="true"></span></button>
</p>
</div>
{% endfor %}
</div> </div>
<form> <form>
<div class="form-group"> <div class="form-group">
<label for="exampleInputEmail1">Nueva pregunta</label> <label for="exampleInputEmail1">Nueva pregunta</label>
<input type="text" class="form-control" id="new_question"> <textarea class="form-control" rows="3" id="new_question"></textarea>
</div> </div>
<input type="button" class="btn btn-primary" value="Preguntar" onclick="submitQuestion()"> <input type="button" class="btn btn-primary" value="Preguntar" onclick="submitQuestion()">
</form> </form>
...@@ -27,11 +19,18 @@ ...@@ -27,11 +19,18 @@
{% block javascripts %} {% block javascripts %}
{{ parent() }} {{ parent() }}
<script type="text/javascript"> <script type="text/javascript">
setInterval(function() {
updateQuestions; window.onload = function() {
}, 3000); updateQuestions();
};
// window.setInterval(function(){
// /// call your function here
// updateQuestions();
// }, 3000);
var allQuestions = null; var allQuestions = null;
function updateQuestions() function updateQuestions()
{ {
$.post("{{ path('question_get', { 'id': event.id }) }}", $.post("{{ path('question_get', { 'id': event.id }) }}",
{question: null}, {question: null},
...@@ -40,13 +39,17 @@ ...@@ -40,13 +39,17 @@
$.each(response, function(index, value){ $.each(response, function(index, value){
if($('#q'+index).length == 0) if($('#q'+index).length == 0)
{ {
$('#questions').append('<div data-sort="'+value[2]+'" id="q'+index+'" class="question-div">'+ $('#questions').append(''+
'<h5>'+value[3]+'</h5>'+ '<div data-sort="'+value[2]+'" id="q'+index+'" class="question-div panel panel-info">'+
'<p>'+value[4]+ '<div class="inline-ble">'+
'<button type="button" class="btn btn-default btn-xs" qid="'+index+'" onclick="upvote(this)"><div class="n-lovers">'+value[0]+'</div><span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span></button>'+ '<div class="date-asked left-col"><small>'+value[4]+'</small></div>'+
'<button type="button" class="btn btn-default btn-xs" qid="'+index+'" onclick="downvote(this)"><div class="n-haters">'+value[1]+'</div><span class="glyphicon glyphicon-thumbs-down" aria-hidden="true"></span></button>'+ '<div class="buttons right-col">'+
'</p>'+ '<button type="button" class="btn btn-default btn-xs likes-button" qid="'+index+'" onclick="upvote(this)"><div class="n-lovers">'+value[0]+'</div><span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span></button>'+
'</div>'); '</div>'+
'</div>'+
'<h5>'+value[3]+'</h5>'+
'</div>'
);
} }
else else
{ {
...@@ -64,8 +67,13 @@ ...@@ -64,8 +67,13 @@
function submitQuestion() function submitQuestion()
{ {
//disable
$('form :input').prop("disabled", true);
var question = $('#new_question').val(); var question = $('#new_question').val();
if(question)
$.post("{{ path('question_ask', { 'id': event.id }) }}", $.post("{{ path('question_ask', { 'id': event.id }) }}",
{question: question}, {question: question},
function(response) function(response)
...@@ -74,6 +82,9 @@ ...@@ -74,6 +82,9 @@
$('#new_question').val(null); $('#new_question').val(null);
}, },
"json"); "json");
//enable all
$('form :input').prop("disabled", false);
} }
function upvote(question) function upvote(question)
......
...@@ -371,4 +371,18 @@ table { ...@@ -371,4 +371,18 @@ table {
.half-width > tbody > tr > th { .half-width > tbody > tr > th {
width: 50% width: 50%
}
.n-lovers, .n-haters {
display: inline-block;
margin-right: 5px;
}
.question-div {
padding: 5px;
}
.likes-button {
float: right;
margin-left: 3px;
} }
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment