diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..dd15b5c --- /dev/null +++ b/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import controllers diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..44d2d31 --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + + +{ + 'name': 'Quiz on Live Event Tracks', + 'category': 'Hidden', + 'version': '1.0', + 'summary': 'Bridge module to support quiz features during "live" tracks. ', + 'website': 'https://www.odoo.com/app/events', + 'depends': [ + 'website_event_track_live', + 'website_event_track_quiz', + ], + 'data': [ + 'views/event_track_templates_page.xml', + ], + 'installable': True, + 'auto_install': True, + 'assets': { + 'web.assets_frontend': [ + 'website_event_track_live_quiz/static/src/js/**/*', + 'website_event_track_live_quiz/static/src/xml/**/*', + ], + }, + 'license': 'LGPL-3', +} diff --git a/controllers/__init__.py b/controllers/__init__.py new file mode 100644 index 0000000..b4c6a30 --- /dev/null +++ b/controllers/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import track_live_quiz diff --git a/controllers/track_live_quiz.py b/controllers/track_live_quiz.py new file mode 100644 index 0000000..2827983 --- /dev/null +++ b/controllers/track_live_quiz.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.addons.website_event_track_live.controllers.track_live import EventTrackLiveController + + +class EventTrackLiveQuizController(EventTrackLiveController): + + def _prepare_track_suggestion_values(self, track, track_suggestion): + res = super(EventTrackLiveQuizController, self)._prepare_track_suggestion_values(track, track_suggestion) + res['current_track']['show_quiz'] = bool(track.quiz_id) and not track.is_quiz_completed + return res diff --git a/i18n/ru.po b/i18n/ru.po new file mode 100644 index 0000000..88deae4 --- /dev/null +++ b/i18n/ru.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_event_track_live_quiz +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-10-26 21:56+0000\n" +"PO-Revision-Date: 2024-01-30 15:14+0400\n" +"Last-Translator: \n" +"Language-Team: Russian (https://app.transifex.com/odoo/teams/41243/ru/)\n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n%100>=11 && n%100<=14)? 2 : 3);\n" + +#. module: website_event_track_live_quiz +#. odoo-javascript +#: code:addons/website_event_track_live_quiz/static/src/xml/website_event_track_quiz_templates.xml:0 +#, python-format +msgid "Next Track" +msgstr "Следующий трек" + +#. module: website_event_track_live_quiz +#. odoo-javascript +#: code:addons/website_event_track_live_quiz/static/src/xml/website_event_track_live_templates.xml:0 +#, python-format +msgid "Take the Quiz" +msgstr "Пройдите викторину" diff --git a/i18n/website_event_track_live_quiz.pot b/i18n/website_event_track_live_quiz.pot new file mode 100644 index 0000000..015c6a7 --- /dev/null +++ b/i18n/website_event_track_live_quiz.pot @@ -0,0 +1,30 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_event_track_live_quiz +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-10-26 21:56+0000\n" +"PO-Revision-Date: 2023-10-26 21:56+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: website_event_track_live_quiz +#. odoo-javascript +#: code:addons/website_event_track_live_quiz/static/src/xml/website_event_track_quiz_templates.xml:0 +#, python-format +msgid "Next Track" +msgstr "" + +#. module: website_event_track_live_quiz +#. odoo-javascript +#: code:addons/website_event_track_live_quiz/static/src/xml/website_event_track_live_templates.xml:0 +#, python-format +msgid "Take the Quiz" +msgstr "" diff --git a/static/src/js/event_quiz.js b/static/src/js/event_quiz.js new file mode 100644 index 0000000..8f3b6b6 --- /dev/null +++ b/static/src/js/event_quiz.js @@ -0,0 +1,48 @@ +/** @odoo-module **/ + +import Quiz from "@website_event_track_quiz/js/event_quiz"; + +var WebsiteEventTrackSuggestionQuiz = Quiz.include({ + /** + * @override + */ + willStart: function () { + return Promise.all([ + this._super(...arguments), + this._getTrackSuggestion() + ]); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + _submitQuiz: function () { + var self = this; + return this._super(...arguments).then(function (data) { + if (data.quiz_completed) { + self.$('.o_quiz_js_quiz_next_track') + .removeClass('btn-light') + .addClass('btn-secondary'); + } + + return Promise.resolve(data); + }); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + _getTrackSuggestion: function () { + var self = this; + return this.rpc('/event_track/get_track_suggestion', { + track_id: this.track.id, + }).then(function (suggestion) { + self.nextSuggestion = suggestion; + return Promise.resolve(); + }); + } +}); + +export default WebsiteEventTrackSuggestionQuiz; diff --git a/static/src/js/website_event_track_suggestion.js b/static/src/js/website_event_track_suggestion.js new file mode 100644 index 0000000..d65214f --- /dev/null +++ b/static/src/js/website_event_track_suggestion.js @@ -0,0 +1,28 @@ +/** @odoo-module **/ + +import WebsiteEventTrackSuggestion from "@website_event_track_live/js/website_event_track_suggestion"; + +var WebsiteEventTrackSuggestionLiveQuiz = WebsiteEventTrackSuggestion.include({ + events: Object.assign({}, WebsiteEventTrackSuggestion.prototype.events, { + 'click .owevent_track_suggestion_quiz': '_onQuizClick' + }), + + init: function (parent, options) { + this._super(...arguments); + this.currentTrack.showQuiz = options.current_track.show_quiz; + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * If the user takes the quiz, stop the next suggestion timer + */ + _onQuizClick: function () { + clearInterval(this.timerInterval); + this.$('.owevent_track_suggestion_timer_text_wrapper').remove(); + } +}); + +export default WebsiteEventTrackSuggestionLiveQuiz; diff --git a/static/src/xml/website_event_track_live_templates.xml b/static/src/xml/website_event_track_live_templates.xml new file mode 100644 index 0000000..b91629f --- /dev/null +++ b/static/src/xml/website_event_track_live_templates.xml @@ -0,0 +1,14 @@ + + + + + + + Take the Quiz + + + + + diff --git a/static/src/xml/website_event_track_quiz_templates.xml b/static/src/xml/website_event_track_quiz_templates.xml new file mode 100644 index 0000000..86a8395 --- /dev/null +++ b/static/src/xml/website_event_track_quiz_templates.xml @@ -0,0 +1,14 @@ + + + + + + + Next Track + + + + + diff --git a/views/event_track_templates_page.xml b/views/event_track_templates_page.xml new file mode 100644 index 0000000..7bd968a --- /dev/null +++ b/views/event_track_templates_page.xml @@ -0,0 +1,12 @@ + + + + + +