Commit 7a1e3356ef4ad609fa2a22e5df65111928694c34

Authored by Adabriand Furtado
1 parent 4423508e
Exists in master and in 1 other branch dynamic

Versão inicial da tela de sinais ensinados.

view/assets/css/main.css
1 1 @import url("articulation.css");
2 2 @import url("submit-sign.css");
  3 +@import url("teached-signs.css");
3 4  
4 5 /* Main */
5 6 body nav.navbar:first-child {
... ...
view/assets/css/teached-signs.css 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +.teached-signs-msg[type=one] {
  2 + display: none;
  3 +}
  4 +
  5 +.teached-signs-msg[type=more] {
  6 + display: none;
  7 +}
  8 +
  9 +.col-btn {
  10 + padding-right: 5px;
  11 + margin-bottom: 10px;
  12 +}
  13 +
  14 +.modal {
  15 + top: 100px;
  16 +}
  17 +
  18 +.modal-xlg {
  19 + width: 100%;
  20 +}
  21 +
  22 +.modal-content {
  23 + background: none;
  24 + border: none;
  25 + box-shadow: none;
  26 +}
  27 +
  28 +#teached-sign-name {
  29 + color: #ffffff;
  30 + font-weight: bold;
  31 +}
  32 +
  33 +#teached-sign-video-container video {
  34 + height: 100%;
  35 + width: 100%;
  36 +}
0 37 \ No newline at end of file
... ...
view/assets/js/teached-signs.js 0 → 100644
... ... @@ -0,0 +1,108 @@
  1 +(function(teachedSigns, $, undefined) {
  2 +
  3 + var totalTasks = 0;
  4 + var doneTasks = 0;
  5 + var userId = -1;
  6 + var pybossaUrl = '/';
  7 + var projectname = 'wikilibras';
  8 + var projectId = -1;
  9 +
  10 + function _getProjectId() {
  11 + return $.ajax({
  12 + url : pybossaUrl + 'api/project?short_name=' + projectname
  13 + });
  14 + }
  15 +
  16 + function _getUserProgress() {
  17 + return $.ajax({
  18 + url : pybossaUrl + 'api/project/' + projectname + '/userprogress',
  19 + cache : false,
  20 + dataType : 'json'
  21 + });
  22 + }
  23 +
  24 + function _getAnswers() {
  25 + return $.ajax({
  26 + url : pybossaUrl + 'api/taskrun?project_id=' + projectId
  27 + + '&user_id=' + userId
  28 + });
  29 + }
  30 +
  31 + function _updateTeachedSignsMessage() {
  32 + $(".teached-signs-msg").hide();
  33 + if (doneTasks == 0) {
  34 + $(".teached-signs-msg[type=none]").show();
  35 + } else if (doneTasks == 1) {
  36 + $(".teached-signs-msg[type=one]").show();
  37 + } else {
  38 + $(".teached-signs-msg[type=more] span").text(doneTasks);
  39 + $(".teached-signs-msg[type=more]").show();
  40 + }
  41 + }
  42 +
  43 + function _createSigns(answers) {
  44 + _updateTeachedSignsMessage();
  45 + for (i = 0; i < answers.length; i++) {
  46 + _addSign(answers[i].info);
  47 + }
  48 + }
  49 +
  50 + function _addSign(answer) {
  51 + var signName = answer.parameter_json.sinal;
  52 + var apiUserId = answer.parameter_json.userId;
  53 + var videoUrl = wikilibras.getRenderedAvatarUrl(apiUserId, signName);
  54 + $("#signs-list-container").append(
  55 + '<div class="col-btn col-xs-6 col-sm-3 col-md-2" sign-name="'
  56 + + signName
  57 + + '"><button class="btn btn-danger btn-block">'
  58 + + signName + '</button></div>');
  59 + $("#signs-list-container .col-btn[sign-name=" + signName + "]")
  60 + .off("click")
  61 + .on(
  62 + "click",
  63 + function() {
  64 + $('#teached-sign-video-container')
  65 + .html(
  66 + "<video autoplay loop><source src='"
  67 + + videoUrl
  68 + + "' type='video/webm'>Sem suporte a videos</video>");
  69 + $('#teached-sign-name').html(signName);
  70 + $('#teached-sign-modal').modal('show');
  71 + });
  72 +
  73 + }
  74 +
  75 + function _updateTeachedSignsContainer() {
  76 + $("#signs-list-container").html("");
  77 + _getAnswers().done(function(answers) {
  78 + _createSigns(answers);
  79 + });
  80 + }
  81 +
  82 + teachedSigns.setup = function() {
  83 + _getProjectId().done(function(response) {
  84 + console.log(response);
  85 + if (typeof response == "undefined" || response.length < 1) {
  86 + return;
  87 + }
  88 + projectId = response[0].id;
  89 + _getUserProgress().done(function(response) {
  90 + totalTasks = response.total;
  91 + doneTasks = response.done;
  92 + userId = response.user_id;
  93 + _updateTeachedSignsContainer();
  94 +
  95 + console.log(totalTasks);
  96 + console.log(doneTasks);
  97 + console.log(userId);
  98 + });
  99 + });
  100 + };
  101 +
  102 + teachedSigns.addNewSignal = function(answer) {
  103 + doneTasks = doneTasks + 1;
  104 + _updateTeachedSignsMessage();
  105 + _addSign(answer);
  106 + }
  107 +
  108 +}(window.teachedSigns = window.teachedSigns || {}, jQuery));
... ...
view/assets/js/wikilibras.js
... ... @@ -405,13 +405,10 @@
405 405 }
406 406  
407 407 function _setupGUI(task, deferred) {
408   - dynengine.load();
409   - dynworkflow.load();
410 408 _clearGUI();
411 409 _setupConfigurationPanel();
412 410 _setupSelectionPanel();
413 411 _setupMainScreen(task, deferred);
414   - submitSign.setup();
415 412 }
416 413  
417 414 function _createAnswer(task, status) {
... ... @@ -450,6 +447,7 @@
450 447  
451 448 function _saveAnswer(task, deferred, answer) {
452 449 pybossa.saveTask(task.id, answer).done(function() {
  450 + teachedSigns.addNewSignal(answer);
453 451 setTimeout(function() {
454 452 $("#thanks-screen").hide();
455 453 deferred.resolve();
... ... @@ -464,8 +462,16 @@
464 462 // It removes the PyBossa default message
465 463 $(".row .col-md-12 p").remove();
466 464 }
467   -
  465 +
  466 + function _loadMainComponents(task) {
  467 + dynengine.load();
  468 + dynworkflow.load();
  469 + submitSign.setup();
  470 + teachedSigns.setup();
  471 + }
  472 +
468 473 pybossa.presentTask(function(task, deferred) {
  474 + _loadMainComponents();
469 475 if (!$.isEmptyObject(task) && current_task_id != task.id) {
470 476 _loadTaskInfo(task);
471 477 _setupGUI(task, deferred)
... ... @@ -509,6 +515,10 @@
509 515 wikilibras.enableIconCheck = function(container, isHover) {
510 516 _enableIconCheck(container, isHover);
511 517 }
  518 +
  519 + wikilibras.getRenderedAvatarUrl = function(userId, signName) {
  520 + return _getRenderedAvatarUrl(userId, signName);
  521 + }
512 522  
513 523 wikilibras.showTeachContainer = function() {
514 524 $(".sub-main-container").hide();
... ...
view/template.html
... ... @@ -297,7 +297,26 @@
297 297 </form>
298 298 </div>
299 299 <div id="teached-signs-container" class="sub-main-container">
300   - <span>Sinais ensinados</span>
  300 + <h4 class="teached-signs-msg" type="none">Você ainda não ensinou
  301 + sinais.</h4>
  302 + <h4 class="teached-signs-msg" type="one">
  303 + Você já ensinou 1 sinal de LIBRAS.
  304 + </h4>
  305 + <h4 class="teached-signs-msg" type="more">
  306 + Você já ensinou <span>x</span> sinais de LIBRAS.
  307 + </h4>
  308 + <div id="signs-list-container" class="row"></div>
  309 + <div id="teached-sign-modal" class="modal fade" tabindex="-1"
  310 + role="dialog" aria-labelledby="modalUserSignal">
  311 + <div class="modal-dialog" role="document">
  312 + <div class="modal-content">
  313 + <div class="modal-body">
  314 + <div id="teached-sign-video-container"></div>
  315 + <p id="teached-sign-name" class="text-center"></p>
  316 + </div>
  317 + </div>
  318 + </div>
  319 + </div>
301 320 </div>
302 321 <div id="tutorial-container" class="sub-main-container">
303 322 <span>Tutorial</span>
... ... @@ -306,11 +325,11 @@
306 325  
307 326 <script src="{{ server }}/assets/js/jquery.scrollTo.js"></script>
308 327 <script src="{{ server }}/assets/js/js.cookie.js"></script>
309   -
310 328 <script src="{{ server }}/assets/js/jquery.ui.widget.js"></script>
311 329 <script src="{{ server }}/assets/js/jquery.iframe-transport.js"></script>
312 330 <script src="{{ server }}/assets/js/jquery.fileupload.js"></script>
313 331  
  332 +<script src="{{ server }}/assets/js/teached-signs.js"></script>
314 333 <script src="{{ server }}/assets/js/submit-sign.js"></script>
315 334 <script src="{{ server }}/assets/js/facial.js"></script>
316 335 <script src="{{ server }}/assets/js/movement.js"></script>
... ... @@ -326,17 +345,4 @@
326 345 <script type="text/javascript">
327 346 wikilibras.run("{{ server }}", "{{ server_backend }}",
328 347 "{{ app_shortname }}", "{{ api_host }}");
329   - $(document).ready(function() {
330   - // Make it possible the elements trigger the show or hide event
331   - (function($) {
332   - $.each([ 'show', 'hide' ], function(i, ev) {
333   - var el = $.fn[ev];
334   - $.fn[ev] = function() {
335   - this.trigger(ev);
336   - el.apply(this, arguments);
337   - return el;
338   - };
339   - });
340   - })(jQuery);
341   - });
342   -</script>
  348 +</script>
343 349 \ No newline at end of file
... ...
wikilibras.py
... ... @@ -34,7 +34,7 @@ class Wikilibras:
34 34 def __update_project_info(self, project):
35 35 template = self.env.get_template('template.html')
36 36 project.info['task_presenter'] = template.render(server=self.config['HOST_STATIC_FILES_ENDPOINT'], server_backend=self.config['HOST_ENDPOINT'], app_shortname=self.config['PYBOSSA_APP_SHORT_NAME'], api_host=self.config['API_HOST'])
37   - project.info['thumbnail'] = self.config['HOST_ENDPOINT'] + "/img/thumbnail.png"
  37 + project.info['thumbnail'] = self.config['HOST_STATIC_FILES_ENDPOINT'] + "/img/thumbnail.png"
38 38 project.info['sched'] = "incremental"
39 39 project.allow_anonymous_contributors = False
40 40 #project.published = True
... ...