diff --git a/view/assets/css/main.css b/view/assets/css/main.css index e7714da..70c4a31 100644 --- a/view/assets/css/main.css +++ b/view/assets/css/main.css @@ -1,5 +1,6 @@ @import url("articulation.css"); @import url("submit-sign.css"); +@import url("teached-signs.css"); /* Main */ body nav.navbar:first-child { diff --git a/view/assets/css/teached-signs.css b/view/assets/css/teached-signs.css new file mode 100644 index 0000000..2dac845 --- /dev/null +++ b/view/assets/css/teached-signs.css @@ -0,0 +1,36 @@ +.teached-signs-msg[type=one] { + display: none; +} + +.teached-signs-msg[type=more] { + display: none; +} + +.col-btn { + padding-right: 5px; + margin-bottom: 10px; +} + +.modal { + top: 100px; +} + +.modal-xlg { + width: 100%; +} + +.modal-content { + background: none; + border: none; + box-shadow: none; +} + +#teached-sign-name { + color: #ffffff; + font-weight: bold; +} + +#teached-sign-video-container video { + height: 100%; + width: 100%; +} \ No newline at end of file diff --git a/view/assets/js/teached-signs.js b/view/assets/js/teached-signs.js new file mode 100644 index 0000000..a34ce22 --- /dev/null +++ b/view/assets/js/teached-signs.js @@ -0,0 +1,108 @@ +(function(teachedSigns, $, undefined) { + + var totalTasks = 0; + var doneTasks = 0; + var userId = -1; + var pybossaUrl = '/'; + var projectname = 'wikilibras'; + var projectId = -1; + + function _getProjectId() { + return $.ajax({ + url : pybossaUrl + 'api/project?short_name=' + projectname + }); + } + + function _getUserProgress() { + return $.ajax({ + url : pybossaUrl + 'api/project/' + projectname + '/userprogress', + cache : false, + dataType : 'json' + }); + } + + function _getAnswers() { + return $.ajax({ + url : pybossaUrl + 'api/taskrun?project_id=' + projectId + + '&user_id=' + userId + }); + } + + function _updateTeachedSignsMessage() { + $(".teached-signs-msg").hide(); + if (doneTasks == 0) { + $(".teached-signs-msg[type=none]").show(); + } else if (doneTasks == 1) { + $(".teached-signs-msg[type=one]").show(); + } else { + $(".teached-signs-msg[type=more] span").text(doneTasks); + $(".teached-signs-msg[type=more]").show(); + } + } + + function _createSigns(answers) { + _updateTeachedSignsMessage(); + for (i = 0; i < answers.length; i++) { + _addSign(answers[i].info); + } + } + + function _addSign(answer) { + var signName = answer.parameter_json.sinal; + var apiUserId = answer.parameter_json.userId; + var videoUrl = wikilibras.getRenderedAvatarUrl(apiUserId, signName); + $("#signs-list-container").append( + '
'); + $("#signs-list-container .col-btn[sign-name=" + signName + "]") + .off("click") + .on( + "click", + function() { + $('#teached-sign-video-container') + .html( + ""); + $('#teached-sign-name').html(signName); + $('#teached-sign-modal').modal('show'); + }); + + } + + function _updateTeachedSignsContainer() { + $("#signs-list-container").html(""); + _getAnswers().done(function(answers) { + _createSigns(answers); + }); + } + + teachedSigns.setup = function() { + _getProjectId().done(function(response) { + console.log(response); + if (typeof response == "undefined" || response.length < 1) { + return; + } + projectId = response[0].id; + _getUserProgress().done(function(response) { + totalTasks = response.total; + doneTasks = response.done; + userId = response.user_id; + _updateTeachedSignsContainer(); + + console.log(totalTasks); + console.log(doneTasks); + console.log(userId); + }); + }); + }; + + teachedSigns.addNewSignal = function(answer) { + doneTasks = doneTasks + 1; + _updateTeachedSignsMessage(); + _addSign(answer); + } + +}(window.teachedSigns = window.teachedSigns || {}, jQuery)); diff --git a/view/assets/js/wikilibras.js b/view/assets/js/wikilibras.js index 8fea826..538119e 100644 --- a/view/assets/js/wikilibras.js +++ b/view/assets/js/wikilibras.js @@ -405,13 +405,10 @@ } function _setupGUI(task, deferred) { - dynengine.load(); - dynworkflow.load(); _clearGUI(); _setupConfigurationPanel(); _setupSelectionPanel(); _setupMainScreen(task, deferred); - submitSign.setup(); } function _createAnswer(task, status) { @@ -450,6 +447,7 @@ function _saveAnswer(task, deferred, answer) { pybossa.saveTask(task.id, answer).done(function() { + teachedSigns.addNewSignal(answer); setTimeout(function() { $("#thanks-screen").hide(); deferred.resolve(); @@ -464,8 +462,16 @@ // It removes the PyBossa default message $(".row .col-md-12 p").remove(); } - + + function _loadMainComponents(task) { + dynengine.load(); + dynworkflow.load(); + submitSign.setup(); + teachedSigns.setup(); + } + pybossa.presentTask(function(task, deferred) { + _loadMainComponents(); if (!$.isEmptyObject(task) && current_task_id != task.id) { _loadTaskInfo(task); _setupGUI(task, deferred) @@ -509,6 +515,10 @@ wikilibras.enableIconCheck = function(container, isHover) { _enableIconCheck(container, isHover); } + + wikilibras.getRenderedAvatarUrl = function(userId, signName) { + return _getRenderedAvatarUrl(userId, signName); + } wikilibras.showTeachContainer = function() { $(".sub-main-container").hide(); diff --git a/view/template.html b/view/template.html index 1e99d97..0142cb2 100755 --- a/view/template.html +++ b/view/template.html @@ -297,7 +297,26 @@
- Sinais ensinados +

Você ainda não ensinou + sinais.

+

+ Você já ensinou 1 sinal de LIBRAS. +

+

+ Você já ensinou x sinais de LIBRAS. +

+
+
Tutorial @@ -306,11 +325,11 @@ - + @@ -326,17 +345,4 @@ + \ No newline at end of file diff --git a/wikilibras.py b/wikilibras.py index f093ada..020b291 100644 --- a/wikilibras.py +++ b/wikilibras.py @@ -34,7 +34,7 @@ class Wikilibras: def __update_project_info(self, project): template = self.env.get_template('template.html') 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']) - project.info['thumbnail'] = self.config['HOST_ENDPOINT'] + "/img/thumbnail.png" + project.info['thumbnail'] = self.config['HOST_STATIC_FILES_ENDPOINT'] + "/img/thumbnail.png" project.info['sched'] = "incremental" project.allow_anonymous_contributors = False #project.published = True -- libgit2 0.21.2