From 885d8a18d06d3d3181a345a3fda2a420824f9896 Mon Sep 17 00:00:00 2001
From: "Abdelouahab (abla)" <abla@odoo.com>
Date: Mon, 8 May 2023 13:49:29 +0000
Subject: [PATCH] [FIX] website_slides: avoid completing slide when not being a
 member

To reproduce
============
- add video to a course
- remove user from course if user is enrolled
- open video in full screen mode and play it
- move nearly to the last part of the video so that is detected as completed
- an error will occure

Problem
=======
- when the video is detected to be completed we want to mark the slide as completed
- as the user is not a member, we can't retreive the current slide which is the source
of this issue

Solution
========
as the use is not a member, marking the slide as **Completed** dosen't make any sense,
so checking if the user is member, should solve the problem.

opw-3295662

closes odoo/odoo#121062

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
---
 .../static/src/js/slides_course_fullscreen_player.js          | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/addons/website_slides/static/src/js/slides_course_fullscreen_player.js b/addons/website_slides/static/src/js/slides_course_fullscreen_player.js
index 6850aee1bd39..b42e54e05d3a 100644
--- a/addons/website_slides/static/src/js/slides_course_fullscreen_player.js
+++ b/addons/website_slides/static/src/js/slides_course_fullscreen_player.js
@@ -114,7 +114,7 @@
                     self.currentVideoTime += 1;
                     if (self.totalVideoTime && self.currentVideoTime > self.totalVideoTime - 30){
                         clearInterval(self.tid);
-                        if (!self.slide.hasQuestion && !self.slide.completed){
+                        if (self.slide.isMember && !self.slide.hasQuestion && !self.slide.completed){
                             self.trigger_up('slide_mark_completed', self.slide);
                         }
                     }
@@ -216,7 +216,7 @@
          */
          _onVideoTimeUpdate: async function (eventData) {
             if (eventData.seconds > (this.videoDuration - 30)) {
-                if (!this.slide.hasQuestion && !this.slide.completed){
+                if (this.slide.isMember && !this.slide.hasQuestion && !this.slide.completed){
                     this.trigger_up('slide_mark_completed', this.slide);
                 }
             }
-- 
GitLab