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 @@
<h1>Evento {{ event.name }}</h1>
<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>
<form>
<div class="form-group">
<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>
<input type="button" class="btn btn-primary" value="Preguntar" onclick="submitQuestion()">
</form>
......@@ -27,11 +19,18 @@
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
setInterval(function() {
updateQuestions;
}, 3000);
window.onload = function() {
updateQuestions();
};
// window.setInterval(function(){
// /// call your function here
// updateQuestions();
// }, 3000);
var allQuestions = null;
function updateQuestions()
function updateQuestions()
{
$.post("{{ path('question_get', { 'id': event.id }) }}",
{question: null},
......@@ -40,13 +39,17 @@
$.each(response, function(index, value){
if($('#q'+index).length == 0)
{
$('#questions').append('<div data-sort="'+value[2]+'" id="q'+index+'" class="question-div">'+
'<h5>'+value[3]+'</h5>'+
'<p>'+value[4]+
'<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>'+
'<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>'+
'</p>'+
'</div>');
$('#questions').append(''+
'<div data-sort="'+value[2]+'" id="q'+index+'" class="question-div panel panel-info">'+
'<div class="inline-ble">'+
'<div class="date-asked left-col"><small>'+value[4]+'</small></div>'+
'<div class="buttons right-col">'+
'<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>'+
'<h5>'+value[3]+'</h5>'+
'</div>'
);
}
else
{
......@@ -64,8 +67,13 @@
function submitQuestion()
{
//disable
$('form :input').prop("disabled", true);
var question = $('#new_question').val();
if(question)
$.post("{{ path('question_ask', { 'id': event.id }) }}",
{question: question},
function(response)
......@@ -74,6 +82,9 @@
$('#new_question').val(null);
},
"json");
//enable all
$('form :input').prop("disabled", false);
}
function upvote(question)
......
......@@ -371,4 +371,18 @@ table {
.half-width > tbody > tr > th {
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