From a4aa358beb227be856c8750ab53ad23290032c89 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:36:35 +0200 Subject: [PATCH 01/44] Rename vimeoactivity/LICENSE.txt to LICENSE.txt --- vimeoactivity/LICENSE.txt => LICENSE.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename vimeoactivity/LICENSE.txt => LICENSE.txt (100%) diff --git a/vimeoactivity/LICENSE.txt b/LICENSE.txt similarity index 100% rename from vimeoactivity/LICENSE.txt rename to LICENSE.txt From 64695ae81e579fffa6bc5a1fa9f575d867cc385e Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:36:55 +0200 Subject: [PATCH 02/44] Rename vimeoactivity/view.php to view.php --- vimeoactivity/view.php => view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename vimeoactivity/view.php => view.php (99%) diff --git a/vimeoactivity/view.php b/view.php similarity index 99% rename from vimeoactivity/view.php rename to view.php index 15277bf..20de6ba 100644 --- a/vimeoactivity/view.php +++ b/view.php @@ -87,4 +87,4 @@ echo(''."\n"); echo(''); -} \ No newline at end of file +} From dd31debca8534819b33c740d2765f671e143d36c Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:37:15 +0200 Subject: [PATCH 03/44] Rename vimeoactivity/version.php to version.php --- vimeoactivity/version.php => version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename vimeoactivity/version.php => version.php (98%) diff --git a/vimeoactivity/version.php b/version.php similarity index 98% rename from vimeoactivity/version.php rename to version.php index 3c73223..6220ea2 100644 --- a/vimeoactivity/version.php +++ b/version.php @@ -31,4 +31,4 @@ $plugin->maturity = MATURITY_BETA; $plugin->requires = 2016052311; $plugin->dependencies = []; -$plugin->cron = 0; \ No newline at end of file +$plugin->cron = 0; From 152e6b4fda881cd17771696bcb7af1ca537a4454 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:39:16 +0200 Subject: [PATCH 04/44] Rename vimeoactivity/style.css to style.css --- vimeoactivity/style.css => style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename vimeoactivity/style.css => style.css (99%) diff --git a/vimeoactivity/style.css b/style.css similarity index 99% rename from vimeoactivity/style.css rename to style.css index e2d66a6..d51d397 100644 --- a/vimeoactivity/style.css +++ b/style.css @@ -116,4 +116,4 @@ .mod-vimeoactivity-video iframe { height: 160px; } -} \ No newline at end of file +} From 4ed0402b6e4a84f88fb06d6a10b1f76467c3e530 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:39:32 +0200 Subject: [PATCH 05/44] Rename vimeoactivity/script.js to script.js --- vimeoactivity/script.js => script.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename vimeoactivity/script.js => script.js (100%) diff --git a/vimeoactivity/script.js b/script.js similarity index 100% rename from vimeoactivity/script.js rename to script.js From 24c2c96c66c021d3f136c9a77a0d8d0641130dec Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:39:50 +0200 Subject: [PATCH 06/44] Rename vimeoactivity/ping.php to ping.php --- vimeoactivity/ping.php => ping.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename vimeoactivity/ping.php => ping.php (100%) diff --git a/vimeoactivity/ping.php b/ping.php similarity index 100% rename from vimeoactivity/ping.php rename to ping.php From 7684b5218ea06e2304a18a1778413e6b9d786896 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:40:21 +0200 Subject: [PATCH 07/44] Rename vimeoactivity/mod_form.php to mod_form.php --- vimeoactivity/mod_form.php => mod_form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename vimeoactivity/mod_form.php => mod_form.php (99%) diff --git a/vimeoactivity/mod_form.php b/mod_form.php similarity index 99% rename from vimeoactivity/mod_form.php rename to mod_form.php index 2eeec12..59685df 100644 --- a/vimeoactivity/mod_form.php +++ b/mod_form.php @@ -185,4 +185,4 @@ public function validation($data, $files) { // array as this function result. return($errors); } -} \ No newline at end of file +} From 5316bcff92914c556a568382295e67742dedd0da Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:40:38 +0200 Subject: [PATCH 08/44] Rename vimeoactivity/locallib.php to locallib.php --- vimeoactivity/locallib.php => locallib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename vimeoactivity/locallib.php => locallib.php (99%) diff --git a/vimeoactivity/locallib.php b/locallib.php similarity index 99% rename from vimeoactivity/locallib.php rename to locallib.php index 87e11da..1451597 100644 --- a/vimeoactivity/locallib.php +++ b/locallib.php @@ -693,4 +693,4 @@ function vimeoactivity_delete_progress($userid, $videoid) { // database and returning a boolean value // as this function result. return((boolean)$DB->delete_records('vimeoactivity_progress', ['user' => $userid, 'video' => $videoid])); -} \ No newline at end of file +} From 8dc3646a909fb4998040e78563982e91b234a514 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:40:56 +0200 Subject: [PATCH 09/44] Rename vimeoactivity/lib.php to lib.php --- vimeoactivity/lib.php => lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename vimeoactivity/lib.php => lib.php (99%) diff --git a/vimeoactivity/lib.php b/lib.php similarity index 99% rename from vimeoactivity/lib.php rename to lib.php index dc62582..c6d977c 100644 --- a/vimeoactivity/lib.php +++ b/lib.php @@ -457,4 +457,4 @@ function vimeoactivity_grade_item_delete(stdclass $video) { // grades, returning a false boolean // value as this function result. return(false); -} \ No newline at end of file +} From 65752ce0ca0d4069e702307f13918e59805c6793 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:41:12 +0200 Subject: [PATCH 10/44] Rename vimeoactivity/index.php to index.php --- vimeoactivity/index.php => index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename vimeoactivity/index.php => index.php (99%) diff --git a/vimeoactivity/index.php b/index.php similarity index 99% rename from vimeoactivity/index.php rename to index.php index 1326d67..2555bf9 100644 --- a/vimeoactivity/index.php +++ b/index.php @@ -25,4 +25,4 @@ defined('MOODLE_INTERNAL') || exit(0); // Nothing to be done here! -exit(0); \ No newline at end of file +exit(0); From df5c3bc34aae0bf9140d7a966fc6aeb69cca977c Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:41:33 +0200 Subject: [PATCH 11/44] Delete icon.png --- vimeoactivity/pix/icon.png | Bin 3285 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 vimeoactivity/pix/icon.png diff --git a/vimeoactivity/pix/icon.png b/vimeoactivity/pix/icon.png deleted file mode 100644 index 0032378ed66eceeac7399a5514a3878d4fbbb1e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3285 zcmV;`3@Y=9P)cBXKA9RX##I|^&txQK4bQC8+jNB|DFc~abKn0aRqLGWc2?V)C zLbBQKJpB;@?Du_p%|>}<&W~izd2io2?|IKT?<*wHnHY*!Gt8!@v7{6L;w6x+Krex8 z2)qCQA|ODWh6Dtt0~iotwb8Zfu0xo2xijUH&M?3o&1?GUkd%NZf#4nho+L>%gV+th z7UklW&piuHrczEIg$C%4bskS+s1%Tg01Qb9Q9BL;T;JTywfbv3+?)!69X5cV%qY6} z-FyPe0r*lOR2=XNu)M0rkJb{i%#IN1kO7J=teZ~3Qy>O)M2MszI4Z=_s-6$Ol{ATD z3~>8}*KtRBP1W-BmlR@N&iDb zT(gh#oO>csT@p4x;rUmKp|KG_-{_Qa2pSa{Qc=_A!H*La3;+h6eQlTmr$S*Wh@mmM zpMk=RW4-3>O@v261}JEFZ9YW)1t2{#MU*RY+0i}^9!o@!SQvEnwL&ej0>sQH-GU$= zt0YgfV>DGH$s<+FK;ns#4>`4#VG$Y zpC#2)Qo-6ZRV8SQ_`a0~fSOz8YzB=HnyS)CHd0N^Kh0-j(TQq++XChDVag(EfwgH< z*7WjU7+;e$t08r2C5D=;Sq;7X7shK-);P%sQx@G8D4!pVM#Lp>TU}W(w0a+QhZmw? zVXb$@>J;gb666OqmJ0D40GH*bAe0{WRrV~$-NDfS`E_sQ!o>gJwAE1_tIe5qQz_q$ z{8O7sA$-ZA)aFcEO|8~A$laGAV}sKe zn*s7pyfYmdqd-AegH-lzIP+L6A#zW?J+A-p&5?GDPDh)JQfZT4V^rRWccxqWhZ#Un zW`OdPgGW8#3Z~CIFnmF4ECG}@atOSg_x0wT{l40IM=F(z2M2~PXmthCXOilKRS!^} z5|kNX^4|DI?$;Ufq17O0g&P|wkJk*C7@xN{jka-AH)0=<$j$JwkupSK>y==Jk(fD3c?zs@!Y0y710} z2h&ohXH=Z%U$U8yN}E0!%ljYSbM1oWngPsUODVPTSsjQru_PhRb_WD%)sv>Ns-b(s zXF1jHPD-Jk(M2(_#6cFH8Eh$S?{ni4c*yEF2$Y{1I4SYi-s*tb=}`&=vbA6Jf41k< z>?}%!lF@K#;G~ZTl-nIT9%}ES0Kj)-XFpO6v4y%C%M#{l8ct!UwcTfG9?m)T-t)Pi zZS9pZjUAvhmO1br;ybdlAJ9GnL`rN^h3b&M@VJxf5^!oRYV|wQ<*D&iy7KQ>XfM zh*lLg{dm;?S%-IIkm?@W^cN;)060$h4HPvEG-@L)3sC(8+SuXyV$VA{Rh0u%X#g#( zaNv1Q*5Mr)%7A+;wRkKisc-y6W0ShZGELY|Wg74ojd{C^yXkgl^(3`4I-TCGwkbNq zFMNmh{Po8NclJny0sKW{Kc<#%EPOl$++&rd6rk-3TyI*oCC|=)jUL;Ucg=u_E&joy zp9vW(pjK-^MSEWbQl$~b6P`48jrX&?3nY$vi{ z%bDB9)YlFDmWE7+avjO~WZz#hKlq?qB4P<#0SB61 zMJ?G@M`Y^cXMm#<48aM%4oE|pnPljm>qLw$JI7v56^`vsUs{8K$XuiaC6ICc8Yk#j+HH>nOpi6*lE^-AV}1N-|PJXjo) za7#Kz(q;`kbzWsf1^Vtel4TnDX+j>3 zF+CbYxa?f<;C~agfHE;?l}`zmLx_Njlxhd-ci`H}aQNbF^kw^(?p_%!3!!8wsGpy$uuj?cfCyewfdOtMZ*lGU#C7IRl~dRnuDXL8-zb63@{3uB8CKM|S=gxv}D z+EaCZ&#wF%wTdyjxLGTC;^OF{nuK{rK+j!O!$e6~wh4h|PcXDg)lV358Bn{eL4t@R z{kY)}w9F>eCTb%;QedNLd_fZv&X2kMSE*DU07S(0x(%q^^%I6%R&4^y7W)OJO3nb< zaJuzzN4XLDmRcUWbhcpVg>gmirBd;BkZP*K1??8#>V9RIt}PBHrJ>z-A1h3hS=(74 zt~`5 z-i`?{`O<{`6C20pR;5%?2lUu+d?Y9{9pqTw-shSD8r`y*+J0%Esa7V$)oBS(UC^d1 zYV3V(@Wp%cJ8<2W7&O&Nho$Flbj!6T{%Z!{n7n4~^fst5I%E6EDRDD}apQPX6aSRf z^nu?^%zKW*hsS(fP8Bk?pPWLC(YEV3jpZDZcP-C2ENE}KoVylU9ksryidHXn+g_g; z7iW$3aqo+kpI)Ar``b$;*=JL$UUYQZUY{viz3A{de6;CuZdeXsm;pEoriQW9!Exm> zq{}6q*WI?ez5BnLeCzne$vK~=Shtvvg9pzF_HnlqA;6N5+RMeL`jky_+QBhw? ztrj@QeMYy+Y^O01)8x8tYAB}AIZckTuz6bMO_eO=+0;-fLdP^Yp^R&qmKlGVTsyjK zYM2kmD~>-BYnspYd5jD2y?J&g$Qq=1`kZ|U;xz36fR9|6mKia5I%cl0XXDww0}>%g zS}N0YaAxDItREy>v|CwyW~)js2N)r7nyZ>;^!YEmmF7xDNtdU{s#bPi9M1tOp@NC@Hyh^zj9M^3k#a+@ta(=Acd2r+q1T# zH%Tcgot1U)D5Iqm?Bvo};d*VlSMy=q9Hq04L|;Weu(jlBDq6>ir-9uRZh@q2;XK^D z#nTZPyowB%=2(anfZ7X@Y!F_6*$}x}KF Date: Sun, 5 Mar 2023 13:41:52 +0200 Subject: [PATCH 12/44] Rename vimeoactivity/pix/icon.svg to pix/icon.svg --- {vimeoactivity/pix => pix}/icon.svg | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {vimeoactivity/pix => pix}/icon.svg (100%) diff --git a/vimeoactivity/pix/icon.svg b/pix/icon.svg similarity index 100% rename from vimeoactivity/pix/icon.svg rename to pix/icon.svg From c406399415a699bc12a8ca17b1dbb3c4ee299f25 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:42:16 +0200 Subject: [PATCH 13/44] Rename vimeoactivity/lang/en/vimeoactivity.php to lang/en/vimeoactivity.php --- {vimeoactivity/lang => lang}/en/vimeoactivity.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {vimeoactivity/lang => lang}/en/vimeoactivity.php (100%) diff --git a/vimeoactivity/lang/en/vimeoactivity.php b/lang/en/vimeoactivity.php similarity index 100% rename from vimeoactivity/lang/en/vimeoactivity.php rename to lang/en/vimeoactivity.php From 87745b8568b7fdf6e84f3da2c47f89ad7820c0eb Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:42:38 +0200 Subject: [PATCH 14/44] Rename vimeoactivity/db/access.php to db/access.php --- {vimeoactivity/db => db}/access.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {vimeoactivity/db => db}/access.php (99%) diff --git a/vimeoactivity/db/access.php b/db/access.php similarity index 99% rename from vimeoactivity/db/access.php rename to db/access.php index 17ce932..d4ebc65 100644 --- a/vimeoactivity/db/access.php +++ b/db/access.php @@ -44,4 +44,4 @@ ), 'clonepermissionsfrom' => 'moodle/course:manageactivities' ), -); \ No newline at end of file +); From 1d844d6601688a7011f1d55a0174e7e89c3383f9 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:43:02 +0200 Subject: [PATCH 15/44] Rename vimeoactivity/db/install.php to db/install.php --- {vimeoactivity/db => db}/install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {vimeoactivity/db => db}/install.php (99%) diff --git a/vimeoactivity/db/install.php b/db/install.php similarity index 99% rename from vimeoactivity/db/install.php rename to db/install.php index b68c9cd..28c65a7 100644 --- a/vimeoactivity/db/install.php +++ b/db/install.php @@ -42,4 +42,4 @@ function xmldb_vimeoactivity_install() { */ function xmldb_vimeoactivity_install_recovery() { return(true); -} \ No newline at end of file +} From dc79f30339c19e1286448f282d7ad0d8b7c6c9e9 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:43:19 +0200 Subject: [PATCH 16/44] Rename vimeoactivity/db/upgrade.php to db/upgrade.php --- {vimeoactivity/db => db}/upgrade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {vimeoactivity/db => db}/upgrade.php (99%) diff --git a/vimeoactivity/db/upgrade.php b/db/upgrade.php similarity index 99% rename from vimeoactivity/db/upgrade.php rename to db/upgrade.php index af194e7..3d4b761 100644 --- a/vimeoactivity/db/upgrade.php +++ b/db/upgrade.php @@ -37,4 +37,4 @@ function xmldb_vimeoactivity_upgrade($oldversion) { } else { return(true); } -} \ No newline at end of file +} From 7cf1bfb947eea2a157af470ca5c5cc8481c8d9ae Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:43:38 +0200 Subject: [PATCH 17/44] Rename vimeoactivity/db/uninstall.php to db/uninstall.php --- {vimeoactivity/db => db}/uninstall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {vimeoactivity/db => db}/uninstall.php (99%) diff --git a/vimeoactivity/db/uninstall.php b/db/uninstall.php similarity index 99% rename from vimeoactivity/db/uninstall.php rename to db/uninstall.php index f1d9c1d..638cda9 100644 --- a/vimeoactivity/db/uninstall.php +++ b/db/uninstall.php @@ -32,4 +32,4 @@ */ function xmldb_vimeoactivity_uninstall() { return(true); -} \ No newline at end of file +} From 6845ae53d9c1387ba539f9701d62f9f64f324dea Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:44:00 +0200 Subject: [PATCH 18/44] Rename vimeoactivity/db/install.xml to db/install.xml --- {vimeoactivity/db => db}/install.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {vimeoactivity/db => db}/install.xml (99%) diff --git a/vimeoactivity/db/install.xml b/db/install.xml similarity index 99% rename from vimeoactivity/db/install.xml rename to db/install.xml index 91eab85..5a8608d 100644 --- a/vimeoactivity/db/install.xml +++ b/db/install.xml @@ -47,4 +47,4 @@ - \ No newline at end of file + From b88688dd30efea9bdacc36a235abcf8f47189f5b Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 13:46:10 +0200 Subject: [PATCH 19/44] Add files via upload --- ...ckup_vimeoactivity_activity_task.class.php | 70 +++++++ .../backup_vimeoactivity_settingslib.php | 27 +++ .../moodle2/backup_vimeoactivity_stepslib.php | 66 ++++++ ...tore_vimeoactivity_activity_task.class.php | 90 +++++++++ .../restore_vimeoactivity_stepslib.php | 75 +++++++ classes/analytics/indicator/activity_base.php | 34 ++++ .../analytics/indicator/cognitive_depth.php | 45 +++++ .../analytics/indicator/social_breadth.php | 45 +++++ classes/completion/custom_completion.php | 104 ++++++++++ .../course_module_instance_list_viewed.php | 21 ++ classes/event/course_module_viewed.php | 38 ++++ classes/external/progress.php | 102 ++++++++++ classes/util/watchprog.php | 188 ++++++++++++++++++ db/access.php | 1 - db/install.php | 1 - db/install.xml | 10 +- db/services.php | 34 ++++ db/uninstall.php | 2 - db/upgrade.php | 2 - index.php | 69 ++++++- lib.php | 55 ++--- locallib.php | 15 +- mod_form.php | 33 ++- ping.php | 2 +- pix/icon.png | Bin 0 -> 3285 bytes script.js | 4 +- style.css | 2 +- version.php | 4 +- view.php | 61 +++++- 29 files changed, 1127 insertions(+), 73 deletions(-) create mode 100644 backup/moodle2/backup_vimeoactivity_activity_task.class.php create mode 100644 backup/moodle2/backup_vimeoactivity_settingslib.php create mode 100644 backup/moodle2/backup_vimeoactivity_stepslib.php create mode 100644 backup/moodle2/restore_vimeoactivity_activity_task.class.php create mode 100644 backup/moodle2/restore_vimeoactivity_stepslib.php create mode 100644 classes/analytics/indicator/activity_base.php create mode 100644 classes/analytics/indicator/cognitive_depth.php create mode 100644 classes/analytics/indicator/social_breadth.php create mode 100644 classes/completion/custom_completion.php create mode 100644 classes/event/course_module_instance_list_viewed.php create mode 100644 classes/event/course_module_viewed.php create mode 100644 classes/external/progress.php create mode 100644 classes/util/watchprog.php create mode 100644 db/services.php create mode 100644 pix/icon.png diff --git a/backup/moodle2/backup_vimeoactivity_activity_task.class.php b/backup/moodle2/backup_vimeoactivity_activity_task.class.php new file mode 100644 index 0000000..b10fae8 --- /dev/null +++ b/backup/moodle2/backup_vimeoactivity_activity_task.class.php @@ -0,0 +1,70 @@ +. + +/** + * The task that provides all the steps to perform a complete backup is defined here. + * + * @package mod_vimeoactivity + * @category backup + */ + +defined('MOODLE_INTERNAL') || die(); + +// More information about the backup process: {@link https://docs.moodle.org/dev/Backup_API}. +// More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}. + +require_once($CFG->dirroot.'//mod/vimeoactivity/backup/moodle2/backup_vimeoactivity_stepslib.php'); +require_once($CFG->dirroot.'//mod/vimeoactivity/backup/moodle2/backup_vimeoactivity_settingslib.php'); + +/** + * Provides all the settings and steps to perform a complete backup of mod_vimeoactivity. + */ +class backup_vimeoactivity_activity_task extends backup_activity_task { + + /** + * Defines particular settings for the plugin. + */ + protected function define_my_settings() { + return; + } + + /** + * Defines particular steps for the backup process. + */ + protected function define_my_steps() { + $this->add_step(new backup_vimeoactivity_activity_structure_step('vimeoactivity_structure', 'vimeoactivity.xml')); + } + + /** + * Codes the transformations to perform in the activity in order to get transportable (encoded) links. + * + * @param string $content + * @return string + */ + public static function encode_content_links($content) { + global $CFG; + + $base = preg_quote($CFG->wwwroot, '/'); + + $search = "/(".$base."\/mod\/vimeoactivity\/index.php\?id\=)([0-9]+)/"; + $content = preg_replace($search, '$@vimeoactivityINDEX*$2@$', $content); + + $search = "/(".$base."\/mod\/vimeoactivity\/view.php\?id\=)([0-9]+)/"; + $content = preg_replace($search, '$@vimeoactivityVIEWBYID*$2@$', $content); + + return $content; + } +} diff --git a/backup/moodle2/backup_vimeoactivity_settingslib.php b/backup/moodle2/backup_vimeoactivity_settingslib.php new file mode 100644 index 0000000..f1b7b38 --- /dev/null +++ b/backup/moodle2/backup_vimeoactivity_settingslib.php @@ -0,0 +1,27 @@ +. + +/** + * vimeoactivity backup settings + * + * Workshop has no particular settings but the inherited from the generic + * {@link backup_activity_task}. + * + * @package mod_vimeoactivity + * @category backup + */ + +defined('MOODLE_INTERNAL') || die(); diff --git a/backup/moodle2/backup_vimeoactivity_stepslib.php b/backup/moodle2/backup_vimeoactivity_stepslib.php new file mode 100644 index 0000000..9f86073 --- /dev/null +++ b/backup/moodle2/backup_vimeoactivity_stepslib.php @@ -0,0 +1,66 @@ +. + +/** + * Backup steps for mod_vimeoactivity are defined here. + * + * @package mod_vimeoactivity + * @category backup + */ + +defined('MOODLE_INTERNAL') || die(); + +// More information about the backup process: {@link https://docs.moodle.org/dev/Backup_API}. +// More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}. + +/** + * Define the complete structure for backup, with file and id annotations. + */ +class backup_vimeoactivity_activity_structure_step extends backup_activity_structure_step { + + /** + * Defines the structure of the resulting xml file. + * + * @return backup_nested_element The structure wrapped by the common 'activity' element. + */ + protected function define_structure() { + + // Build the tree with these elements with $root as the root of the backup tree. + $vimeoactivity = new backup_nested_element('vimeoactivity', ['id'], [ + 'course', + 'name', + 'intro', + 'introformat', + 'video', + 'color', + 'autoplay', + 'autoloop', + 'popupopen', + 'popupwidth', + 'popupheight', + 'completionenable', + 'visible', + 'completionprogress', + 'timecreated', + 'timemodified']); + + + // Define the source tables for the elements. + $vimeoactivity->set_source_table('vimeoactivity', ['id' => backup::VAR_ACTIVITYID]); + + return $this->prepare_activity_structure($vimeoactivity); + } +} diff --git a/backup/moodle2/restore_vimeoactivity_activity_task.class.php b/backup/moodle2/restore_vimeoactivity_activity_task.class.php new file mode 100644 index 0000000..d7faed0 --- /dev/null +++ b/backup/moodle2/restore_vimeoactivity_activity_task.class.php @@ -0,0 +1,90 @@ +. + +/** + * The task that provides a complete restore of mod_vimeoactivity is defined here. + * + * @package mod_vimeoactivity + * @category backup + */ + +defined('MOODLE_INTERNAL') || die(); + +// More information about the backup process: {@link https://docs.moodle.org/dev/Backup_API}. +// More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}. + +require_once($CFG->dirroot.'/mod/vimeoactivity/backup/moodle2/restore_vimeoactivity_stepslib.php'); + +/** + * Restore task for mod_vimeoactivity. + */ +class restore_vimeoactivity_activity_task extends restore_activity_task { + + /** + * Defines particular settings that this activity can have. + */ + protected function define_my_settings() { + return; + } + + /** + * Defines particular steps that this activity can have. + */ + protected function define_my_steps() { + $this->add_step(new restore_vimeoactivity_activity_structure_step('vimeoactivity_structure', 'vimeoactivity.xml')); + } + + /** + * Defines the contents in the activity that must be processed by the link decoder. + * + * @return array. + */ + public static function define_decode_contents() { + $contents = array(); + + // Define the contents. + + return $contents; + } + + /** + * Defines the decoding rules for links belonging to the activity to be executed by the link decoder. + * + * @return array. + */ + public static function define_decode_rules() { + $rules = array(); + + // Define the rules. + + return $rules; + } + + /** + * Defines the restore log rules that will be applied by the + * {@see restore_logs_processor} when restoring mod_vimeoactivity logs. It + * must return one array of {@see restore_log_rule} objects. + * + * @return array. + */ + public static function define_restore_log_rules() { + $rules = array(); + + // Define the rules. + + return $rules; + } +} diff --git a/backup/moodle2/restore_vimeoactivity_stepslib.php b/backup/moodle2/restore_vimeoactivity_stepslib.php new file mode 100644 index 0000000..11010e2 --- /dev/null +++ b/backup/moodle2/restore_vimeoactivity_stepslib.php @@ -0,0 +1,75 @@ +. + +/** + * All the steps to restore mod_vimeoactivity are defined here. + * + * @package mod_vimeoactivity + * @category backup + */ + +defined('MOODLE_INTERNAL') || die(); + +// More information about the backup process: {@link https://docs.moodle.org/dev/Backup_API}. +// More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}. + +/** + * Defines the structure step to restore one mod_vimeoactivity activity. + */ +class restore_vimeoactivity_activity_structure_step extends restore_activity_structure_step { + + /** + * Defines the structure to be restored. + * + * @return restore_path_element[]. + */ + protected function define_structure() { + global $CFG; + + require_once($CFG->dirroot.'/mod/vimeoactivity/lib.php'); + + $paths = []; + $userinfo = $this->get_setting_value('userinfo'); + + $vimeoactivity = new restore_path_element('vimeoactivity', '/activity/vimeoactivity'); + $paths[] = $vimeoactivity; + + if ($userinfo) { + $paths[] = new restore_path_element('vimeoactivity_session', '/activity/vimeoactivity/sessions/session'); + } + + // Return the paths wrapped into standard activity structure. + return $this->prepare_activity_structure($paths); + } + + + /** + * Processes the elt restore data. + * + * @param array $data Parsed element data. + */ + protected function process_vimeoactivity($data) { + global $DB; + + $data = (object)$data; + $data->course = $this->get_courseid(); + + $newitemid = $DB->insert_record('vimeoactivity', $data); + + $this->apply_activity_instance($newitemid); + } + +} diff --git a/classes/analytics/indicator/activity_base.php b/classes/analytics/indicator/activity_base.php new file mode 100644 index 0000000..f8b602e --- /dev/null +++ b/classes/analytics/indicator/activity_base.php @@ -0,0 +1,34 @@ +. + +/** + * Activity base class. + * + * @package mod_vimeoactivity + */ +namespace mod_vimeoactivity\analytics\indicator; + +abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity { + + /** + * No need to fetch grades for resources. + * + * @param \core_analytics\course $course + * @return void + */ + public function fetch_student_grades(\core_analytics\course $course) { + } +} diff --git a/classes/analytics/indicator/cognitive_depth.php b/classes/analytics/indicator/cognitive_depth.php new file mode 100644 index 0000000..1a1a08e --- /dev/null +++ b/classes/analytics/indicator/cognitive_depth.php @@ -0,0 +1,45 @@ +. + +/** + * Cognitive depth indicator - vimeoactivity. + * + * @package mod_vimeoactivity + */ + +namespace mod_vimeoactivity\analytics\indicator; + +class cognitive_depth extends activity_base { + + /** + * Returns the name. + * + * If there is a corresponding '_help' string this will be shown as well. + * + * @return \lang_string + */ + public static function get_name() : \lang_string { + return new \lang_string('indicator:cognitivedepth', 'mod_vimeoactivity'); + } + + public function get_indicator_type() { + return self::INDICATOR_COGNITIVE; + } + + public function get_cognitive_depth_level(\cm_info $cm) { + return self::COGNITIVE_LEVEL_1; + } +} diff --git a/classes/analytics/indicator/social_breadth.php b/classes/analytics/indicator/social_breadth.php new file mode 100644 index 0000000..560892d --- /dev/null +++ b/classes/analytics/indicator/social_breadth.php @@ -0,0 +1,45 @@ +. + +/** + * Social breadth indicator - vimeoactivity. + * + * @package mod_vimeoactivity + */ + +namespace mod_vimeoactivity\analytics\indicator; + +class social_breadth extends activity_base { + + /** + * Returns the name. + * + * If there is a corresponding '_help' string this will be shown as well. + * + * @return \lang_string + */ + public static function get_name() : \lang_string { + return new \lang_string('indicator:socialbreadth', 'mod_vimeoactivity'); + } + + public function get_indicator_type() { + return self::INDICATOR_SOCIAL; + } + + public function get_social_breadth_level(\cm_info $cm) { + return self::SOCIAL_LEVEL_1; + } +} diff --git a/classes/completion/custom_completion.php b/classes/completion/custom_completion.php new file mode 100644 index 0000000..01cd53a --- /dev/null +++ b/classes/completion/custom_completion.php @@ -0,0 +1,104 @@ +. + +declare(strict_types=1); + +namespace mod_vimeoactivity\completion; + +use core_completion\activity_custom_completion; +use mod_vimeoactivity\util\watchprog; + +/** + * Activity custom completion subclass for the Assign Tutor activity. + * + * Class for defining mod_vimeoactivity's custom completion rules and fetching the completion statuses + * of the custom completion rules for a given instance and a user. + * + */ +class custom_completion extends activity_custom_completion { + + /** + * Fetches the completion state for a given completion rule. + * + * @param string $rule The completion rule. + * @return int The completion state. + */ + public function get_state(string $rule): int { + global $DB; + + $this->validate_rule($rule); + $videoid = $this->cm->instance; + + if (!$vimeoactivity = $DB->get_record('vimeoactivity', ['id' => $videoid])) { + throw new \moodle_exception('Unable to find video with id ' . $videoid); + } + + if ($rule == 'completionprogress') { + $requiredprogress = $vimeoactivity->completionprogress; + + $progutil = new watchprog(); + + $userhighprogress = $progutil->vimeoactivity_fetch_progress($this->userid, $videoid); + + if ($userhighprogress >= $requiredprogress) { + return COMPLETION_COMPLETE; + } + } + + return COMPLETION_INCOMPLETE; + } + + /** + * Fetch the list of custom completion rules that this module defines. + * + * @return array + */ + public static function get_defined_custom_rules(): array { + return ['completionprogress']; + } + + /** + * Returns an associative array of the descriptions of custom completion rules. + * + * @return array + */ + public function get_custom_rule_descriptions(): array { + global $DB; + + $videoid = $this->cm->instance; + + if (!$vimeoactivity = $DB->get_record('vimeoactivity', ['id' => $videoid])) { + throw new \moodle_exception('Unable to find vidoe with id ' . $videoid); + } + + return [ + 'completionprogress' => get_string('completionprogress_ruledesc', + 'mod_vimeoactivity', $vimeoactivity->completionprogress) + ]; + } + + /** + * Returns an array of all completion rules, in the order they should be displayed to users. + * + * @return array + */ + public function get_sort_order(): array { + return [ + 'completionview', + 'completionprogress' + ]; + } +} diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php new file mode 100644 index 0000000..fda6974 --- /dev/null +++ b/classes/event/course_module_instance_list_viewed.php @@ -0,0 +1,21 @@ +. + +namespace mod_vimeoactivity\event; + +class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { + +} diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php new file mode 100644 index 0000000..8bec2e5 --- /dev/null +++ b/classes/event/course_module_viewed.php @@ -0,0 +1,38 @@ +. + +namespace mod_vimeoactivity\event; + +/** + * The course_module_viewed event class. + * + * @package mod_vimeoactivity + * @category event + */ +class course_module_viewed extends \core\event\course_module_viewed { + /** + * Init method. + */ + protected function init() { + $this->data['crud'] = 'r'; + $this->data['edulevel'] = self::LEVEL_PARTICIPATING; + $this->data['objecttable'] = 'vimeoactivity'; + } + + public static function get_objectid_mapping() { + return array('db' => 'vimeoactivity', 'restore' => 'vimeoactivity'); + } +} diff --git a/classes/external/progress.php b/classes/external/progress.php new file mode 100644 index 0000000..b36f466 --- /dev/null +++ b/classes/external/progress.php @@ -0,0 +1,102 @@ +. + +namespace mod_vimeoactivity\external; + +use completion_info; +use external_api; +use external_function_parameters; +use external_single_structure; +use external_value; +use mod_vimeoactivity\util\watchprog; + +defined('MOODLE_INTERNAL') || die(); + +global $USER, $config; +/** + * Completion external api class. + * + * @package mod_vimeoactivity + */ +class progress extends external_api { + /** + * Complete parameters + * + * @return external_function_parameters + */ + public static function track_parameters() { + return new external_function_parameters([ + 'cmid' => new external_value(PARAM_INT, 'The course module id'), + 'progress' => new external_value(PARAM_INT, 'The progress'), + ]); + } + + /** + * Complete method + * + * @param int $cmid + * + * @return array + * + * @throws \coding_exception + * @throws \invalid_parameter_exception + * @throws \moodle_exception + */ + public static function track($cmid, $watchprog) { + global $DB, $USER, $CFG; + + // We always must pass webservice params through validate_parameters. + self::validate_parameters(self::track_parameters(), ['cmid' => $cmid, 'progress' => $watchprog]); + + list ($course, $cm) = get_course_and_cm_from_cmid($cmid, 'video'); + + $context = \context_course::instance($course->id); + + if (!is_enrolled($context)) { + return [ + 'status' => 'notenrolled' + ]; + } + + $progutil = new watchprog(); + $progutil->addpoint($cm->instance, $watchprog); + + $completion = new completion_info($course); + $completion->update_state($cm, COMPLETION_COMPLETE); + + return [ + 'status' => 'ok' + ]; + } + + /** + * Complete return fields + * + * @return external_single_structure + */ + public static function track_returns() { + return new external_single_structure( + array( + 'status' => new external_value(PARAM_TEXT, 'Operation status') + ) + ); + } + + /** + */ + public function __construct() { + } +} diff --git a/classes/util/watchprog.php b/classes/util/watchprog.php new file mode 100644 index 0000000..0d076d6 --- /dev/null +++ b/classes/util/watchprog.php @@ -0,0 +1,188 @@ +. + +namespace mod_vimeoactivity\util; + +/** + * watchprogress class. + * + * @package mod_vimeoactivity + */ +class watchprog { + /** + * [vimeoactivity_fetch_progress] + * + * @param integer $userid + * @param integer $videoid + * @return object|null + */ + public function vimeoactivity_fetch_progress($userid, $videoid) { + // Importing all the required global + // objects into this function scope. + global $DB; + + // Normalizing the supplied arguments and making + // sure they are within the required parameters. + $userid = max(0, (integer)$userid); + $videoid = max(0, (integer)$videoid); + $result = null; + + // Verifying if the supplied identifiers are valid + // (greater than zero) and, if not, there is no need + // to even touch the database and returning a null + // value as this function result. + if ($userid < 1 || $videoid < 1) { + return($result); + } + + // Compiling the required command to + // load this object from the database. + $sql = "SELECT id,". + "user,". + "video,". + "progress,". + "timecreated,". + "timemodified ". + "FROM {vimeoactivity_progress} ". + "WHERE user=? ". + "AND video=? ". + "LIMIT 1"; + + // Executing the required command to + // load this object from the database. + + if ($record = $DB->get_record_sql($sql, [$userid, $videoid])) { + // Normalizing the loaded object + // attributes and making sure they + // are within the required parameters. + $result = new \stdClass; + $result->id = max(0, (integer)$record->id); + $result->user = max(0, (integer)$record->user); + $result->video = max(0, (integer)$record->video); + $result->progress = max(0, (integer)$record->progress); + $result->timecreated = max(0, (integer)$record->timecreated); + $result->timemodified = max(0, (integer)$record->timemodified); + } + + // Returning the object loaded + // from the database, if any, + // as this function result. + return($result); + } + + /** + * [vimeoactivity_insert_progress] + * + * @param integer $userid + * @param integer $videoid + * @param integer $value + * @return boolean + */ + public function vimeoactivity_save_progress($userid, $videoid, $value) { + // Importing all the required global + // objects into this function scope. + global $DB; + + // Normalizing the supplied arguments and making + // sure they are within the required parameters. + $userid = max(0, (integer)$userid); + $videoid = max(0, (integer)$videoid); + $value = max(0, (integer)$value); + $created = time(); + + // Verifying if the supplied identifiers are valid + // (greater than zero) and, if not, there is no need + // to even touch the database and returning a false + // boolean value as this function result. + if ($userid < 1 || $videoid < 1) { + return(false); + } + + // Compiling the required command + // to persist the supplied object + // progress within the database. + if ($object = vimeoactivity_fetch_progress($userid, $videoid)) { + // Verifying if the supplied progress value is higher than + // what we have stored within the database, if true, store + // it, otherwise return false because it would make no sense + // to unsee the video, and it would mess up completion rules + // that depends on it. + if ($value > $object->progress) { + // Compiling the required command + // to update the supplied object + // within the database. + $values = ['id' => $object->id, + 'progress' => $value, + 'timemodified' => $created]; + + // Executing the required command + // to update the supplied object + // within the database. + return((boolean)$DB->update_record_raw('vimeoactivity_progress', $values)); + } + } else { + // Compiling the required command + // to update the supplied object + // within the database. + $values = ['user' => $userid, + 'video' => $videoid, + 'progress' => $value, + 'timecreated' => $created]; + + // Executing the required command + // to update the supplied object + // within the database. + return((boolean)$DB->insert_record_raw('vimeoactivity_progress', $values)); + } + + // Because we were unable to execute this operation + // successfully, returning a false boolean value as + // this function result. + return(false); + } + + /** + * [vimeoactivity_delete_progress] + * + * @param integer $userid + * @param integer $videoid + * @return boolean + */ + public function vimeoactivity_delete_progress($userid, $videoid) { + // Importing all the required global + // objects into this function scope. + global $DB; + + // Normalizing the supplied arguments and making + // sure they are within the required parameters. + $userid = max(0, (integer)$userid); + $videoid = max(0, (integer)$videoid); + + // Verifying if the supplied identifiers are valid + // (greater than zero) and, if not, there is no need + // to even touch the database and returning a false + // boolean value as this function result. + if ($userid < 1 || $videoid < 1) { + return(false); + } + + // Removing the requested object from the + // database and returning a boolean value + // as this function result. + return((boolean)$DB->delete_records('vimeoactivity_progress', ['user' => $userid, 'video' => $videoid])); + } + +} diff --git a/db/access.php b/db/access.php index d4ebc65..ec70f44 100644 --- a/db/access.php +++ b/db/access.php @@ -19,7 +19,6 @@ * * @package mod_vimeoactivity * @author Vignesh - * @license http://www.gnu.org/copyleft/gpl.html */ defined('MOODLE_INTERNAL') || die(); diff --git a/db/install.php b/db/install.php index 28c65a7..346367e 100644 --- a/db/install.php +++ b/db/install.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html */ -defined('MOODLE_INTERNAL') || die(); /** * This function is responsible for executing the diff --git a/db/install.xml b/db/install.xml index 5a8608d..f9aba32 100644 --- a/db/install.xml +++ b/db/install.xml @@ -7,9 +7,9 @@ - - - + + + @@ -17,7 +17,7 @@ - + @@ -47,4 +47,4 @@ - + \ No newline at end of file diff --git a/db/services.php b/db/services.php new file mode 100644 index 0000000..660bd50 --- /dev/null +++ b/db/services.php @@ -0,0 +1,34 @@ +. + +/** + * Vimeo services definition + * + * @package mod_vimeoactivity + */ + +defined('MOODLE_INTERNAL') || die(); + +$functions = [ + 'mod_vimeoactivity_trackprogress' => [ + 'classname' => 'mod_vimeoactivity\external\progress', + 'classpath' => 'mod/vimeoactivity/classes/external/progress.php', + 'methodname' => 'track', + 'description' => 'Saves the tracked video progress', + 'type' => 'write', + 'ajax' => true + ] +]; diff --git a/db/uninstall.php b/db/uninstall.php index 638cda9..08550dc 100644 --- a/db/uninstall.php +++ b/db/uninstall.php @@ -19,10 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - * @license http://www.gnu.org/copyleft/gpl.html */ -defined('MOODLE_INTERNAL') || die(); /** * This function is responsible for executing the diff --git a/db/upgrade.php b/db/upgrade.php index 3d4b761..940dfd9 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -19,10 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - * @license http://www.gnu.org/copyleft/gpl.html */ -defined('MOODLE_INTERNAL') || die(); /** * This function is responsible for executing the diff --git a/index.php b/index.php index 2555bf9..ec65cba 100644 --- a/index.php +++ b/index.php @@ -22,7 +22,70 @@ * @license http://www.gnu.org/copyleft/gpl.html */ -defined('MOODLE_INTERNAL') || exit(0); +require(__DIR__.'/../../config.php'); -// Nothing to be done here! -exit(0); +require_once(__DIR__.'/lib.php'); + +$id = required_param('id', PARAM_INT); +require_course_login($course, true); +$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); +require_course_login($course); + +$coursecontext = context_course::instance($course->id); + +$event = \mod_vimeoactivity\event\course_module_instance_list_viewed::create(array( + 'context' => $coursecontext +)); +$event->add_record_snapshot('course', $course); +$event->trigger(); + +$PAGE->set_url('/mod/vimeoactivity/index.php', array('id' => $id)); +$PAGE->set_title(format_string($course->fullname)); +$PAGE->set_heading(format_string($course->fullname)); +$PAGE->set_context($coursecontext); + +echo $OUTPUT->header(); + +$modulenameplural = get_string('modulenameplural', 'mod_vimeoactivity'); +echo $OUTPUT->heading($modulenameplural); + +$videos = get_all_instances_in_course('vimeoactivity', $course); + +if (empty($videos)) { + notice(get_string('no$vimeoactivityinstances', 'mod_vimeoactivity'), new moodle_url('/course/view.php', array('id' => $course->id))); +} + +$table = new html_table(); +$table->attributes['class'] = 'generaltable mod_index'; + +if ($course->format == 'weeks') { + $table->head = array(get_string('week'), get_string('name')); + $table->align = array('center', 'left'); +} else if ($course->format == 'topics') { + $table->head = array(get_string('topic'), get_string('name')); + $table->align = array('center', 'left', 'left', 'left'); +} else if ($course->format == 'tiles') { + $table->head = array('Tile', get_string('name')); + $table->align = array('center', 'left', 'left', 'left'); +} else { + $table->head = array(get_string('name')); + $table->align = array('left', 'left', 'left'); +} + +foreach ($videos as $video) { + $link = (!$video->visible) ? html_writer::link( + new moodle_url('/mod/vimeoactivity/view.php', array('id' => $video->coursemodule)), + format_string($video->name, true), + array('class' => 'dimmed')) : html_writer::link( + new moodle_url('/mod/vimeoactivity/view.php', array('id' => $video->coursemodule)), + format_string($video->name, true)); + + if ($course->format == 'weeks' or $course->format == 'topics' or $course->format == 'tiles') { + $table->data[] = array($video->section, $link); + } else { + $table->data[] = array($link); + } +} + +echo html_writer::table($table); +echo $OUTPUT->footer(); diff --git a/lib.php b/lib.php index c6d977c..48f6ef3 100644 --- a/lib.php +++ b/lib.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html */ -defined('MOODLE_INTERNAL') || die(); /** * This function returns what @@ -41,6 +40,8 @@ function vimeoactivity_supports($feature) { return true; case FEATURE_COMPLETION_TRACKS_VIEWS: return true; + case FEATURE_BACKUP_MOODLE2: + return true; default: return false; } @@ -71,8 +72,10 @@ function vimeoactivity_get_coursemodule_info(stdclass $coursemodule) { if ($video->popupopen) { $video->popupwidth = ($video->popupwidth > 0) ? $video->popupwidth : 640; $video->popupheight = ($video->popupheight > 0) ? $video->popupheight : 360; - $info->onclick = "window.open('".$CFG->wwwroot."/mod/vimeoactivity/view.php?id=".$coursemodule->id."&popup=1','_blank',". - "'top=' + (window.top.outerHeight / 2 + window.top.screenY - ( ".$video->popupheight." / 2)) + ',". + $info->onclick = "window.open('".$CFG->wwwroot."/mod/vimeoactivity/view.php?id=". + $coursemodule->id."&popup=1','_blank',". + "'top=' + (window.top.outerHeight / 2 + window.top.screenY - ( ". + $video->popupheight." / 2)) + ',". "left=' + (window.top.outerWidth / 2 + window.top.screenX - ( ".$video->popupwidth." / 2)) + ',". "width=".$video->popupwidth.",height=".$video->popupheight.",toolbar=no,location=no,menubar=no,". "copyhistory=no,status=no,directories=no,scrollbars=yes,resizable=yes'); return false;"; @@ -92,7 +95,7 @@ function vimeoactivity_get_coursemodule_info(stdclass $coursemodule) { // Because we were unable to execute // this operation successfully, returning // a null value as this function result. - return(null); + return new cached_cm_info(); } /** @@ -193,7 +196,7 @@ function vimeoactivity_delete_instance($id) { // Trying to delete the requested object // from the database and, if successful, // returning a true boolean as result. - if (vimeoactivity_delete_video($video)) { + if (vimeoactivity_delete_video($video->id)) { // Rebuilding this course cache. rebuild_course_cache($video->course, true); @@ -209,27 +212,27 @@ function vimeoactivity_delete_instance($id) { return(false); } -/** - * This standard function will check all instances of this - * module and make sure there are up-to-date events created - * for each of them. If courseid equals to zero, then every - * Vimeo event in the site is checked, else only Vimeo events - * belonging to the course specified are checked. This is only - * required if the module is generating calendar events. - * - * @param integer $courseid - * @return boolean - */ -function vimeoactivity_refresh_events($courseid) { - // Because we don't have any related - // events returning a true boolean - // value as this function result. - if ($courseid > 0) { - return(true); - } else { - return(true); - } -} +// /** +// * This standard function will check all instances of this +// * module and make sure there are up-to-date events created +// * for each of them. If courseid equals to zero, then every +// * Vimeo event in the site is checked, else only Vimeo events +// * belonging to the course specified are checked. This is only +// * required if the module is generating calendar events. +// * +// * @param integer $courseid +// * @return boolean +// */ +// function vimeoactivity_refresh_events($courseid) { +// // Because we don't have any related +// // events returning a true boolean +// // value as this function result. +// if ($courseid > 0) { +// return(true); +// } else { +// return(false); +// } +// } /** * Obtains the automatic completion state diff --git a/locallib.php b/locallib.php index 1451597..69fba60 100644 --- a/locallib.php +++ b/locallib.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html */ -defined('MOODLE_INTERNAL') || die(); /** * [vimeoactivity_fetch_video] @@ -298,7 +297,9 @@ function vimeoactivity_render_video(stdclass $video, $styles = true, $scripts = } if ($video->color <> '') { - $output .= '
'; + $output .= '
'; $output .= ' '; $output .= '
'."\n"; } else { @@ -337,8 +338,7 @@ function vimeoactivity_render_video(stdclass $video, $styles = true, $scripts = } else { $output .= ' loop:false,'."\n"; } - - $output .= ' title:false,'."\n"; + $output .= ' title:true,'."\n"; $output .= ' byline:false};'."\n"; $output .= 'var vimeo_'.$video->id.'_player = new Vimeo.Player("mod-vimeoactivity-'.$video->id.'", options);'."\n"; $output .= 'var vimeo_'.$video->id.'_progress = 0;'."\n"; @@ -357,7 +357,6 @@ function vimeoactivity_render_video(stdclass $video, $styles = true, $scripts = $output .= '}'."\n"; $output .= '});'."\n"; $output .= ''."\n"; - // Returning the compiled Vimeo // video as this method's result. return($output); @@ -555,7 +554,7 @@ function vimeoactivity_fetch_progress($userid, $videoid) { // (greater than zero) and, if not, there is no need // to even touch the database and returning a null // value as this function result. - if ($userid < 1 or $videoid < 1) { + if ($userid < 1 || $videoid < 1) { return($result); } @@ -617,7 +616,7 @@ function vimeoactivity_save_progress($userid, $videoid, $value) { // (greater than zero) and, if not, there is no need // to even touch the database and returning a false // boolean value as this function result. - if ($userid < 1 or $videoid < 1) { + if ($userid < 1 || $videoid < 1) { return(false); } @@ -685,7 +684,7 @@ function vimeoactivity_delete_progress($userid, $videoid) { // (greater than zero) and, if not, there is no need // to even touch the database and returning a false // boolean value as this function result. - if ($userid < 1 or $videoid < 1) { + if ($userid < 1 || $videoid < 1) { return(false); } diff --git a/mod_form.php b/mod_form.php index 59685df..b630d55 100644 --- a/mod_form.php +++ b/mod_form.php @@ -19,7 +19,6 @@ * * @package mod_vimeoactivity * @author Vignesh - * @license http://www.gnu.org/copyleft/gpl.html */ defined('MOODLE_INTERNAL') || die(); @@ -33,11 +32,9 @@ /** * This class is responsible for defining and validating this plug-in add and edit forms. * - * @license http://www.gnu.org/copyleft/gpl.html */ -class mod_vimeoactivity_mod_form extends moodleform_mod -{ +class mod_vimeoactivity_mod_form extends moodleform_mod { /** * This method is responsible for * registering this form inputs. @@ -121,10 +118,10 @@ public function add_completion_rules() { 80 => '80%', 90 => '90%', 100 => '100%']), - $this->_form->createElement('checkbox', 'completionenable', ' ', get_string('label_enable', 'mod_vimeoactivity')), + $this->_form->createElement('checkbox', 'completionenable', ' ', get_string('label_enable', 'mod_vimeoactivity')) ]; $this->_form->setType('completionprogress', PARAM_INT); - $this->_form->addGroup($group, 'completionprogress', get_string('label_completion', 'mod_vimeoactivity'), [''], false); + $this->_form->addGroup($group, 'completionprogress', get_string('label_completion', 'mod_vimeoactivity'), null, false); $this->_form->addHelpButton('completionprogress', 'label_completion', 'mod_vimeoactivity'); $this->_form->disabledIf('completionprogress', 'completionenable', 'notchecked'); @@ -142,11 +139,29 @@ public function add_completion_rules() { public function completion_rule_enabled($data) { $data['completionenable'] = intval($data['completionenable']); $data['completionprogress'] = intval($data['completionprogress']); - return($data['completionenable'] == 1 and - $data['completionprogress'] >= 0 and + return($data['completionenable'] == 1 && + $data['completionprogress'] >= 0 && $data['completionprogress'] <= 100); } - + /** + * Allows module to modify the data returned by form get_data(). + * This method is also called in the bulk activity completion form. + * + * Only available on moodleform_mod. + * + * @param stdClass $data the form data to be modified. + */ + // public function data_postprocessing($data) { + // parent::data_postprocessing($data); + // if (!empty($data->completionunlocked)) { + // // Turn off completion settings if the checkboxes aren't ticked. + // $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC; + + // if (!$autocompletion || empty($data->completionprogress)) { + // $data->completionprogress = null; + // } + // } + // } /** * This function is responsible for validating * the supplied Vimeo video data and returning diff --git a/ping.php b/ping.php index 9b3f149..f9ae031 100644 --- a/ping.php +++ b/ping.php @@ -56,7 +56,7 @@ // Deciding if the loaded video must be // marked as a completed task, or not. - if ($video->completionenable == true and + if ($video->completionenable == true && $video->completionprogress <= $value) { $module = get_coursemodule_from_instance('vimeoactivity', $videoid, 0, false, MUST_EXIST); $course = $DB->get_record('course', ['id' => $module->course], '*', MUST_EXIST); diff --git a/pix/icon.png b/pix/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0032378ed66eceeac7399a5514a3878d4fbbb1e3 GIT binary patch literal 3285 zcmV;`3@Y=9P)cBXKA9RX##I|^&txQK4bQC8+jNB|DFc~abKn0aRqLGWc2?V)C zLbBQKJpB;@?Du_p%|>}<&W~izd2io2?|IKT?<*wHnHY*!Gt8!@v7{6L;w6x+Krex8 z2)qCQA|ODWh6Dtt0~iotwb8Zfu0xo2xijUH&M?3o&1?GUkd%NZf#4nho+L>%gV+th z7UklW&piuHrczEIg$C%4bskS+s1%Tg01Qb9Q9BL;T;JTywfbv3+?)!69X5cV%qY6} z-FyPe0r*lOR2=XNu)M0rkJb{i%#IN1kO7J=teZ~3Qy>O)M2MszI4Z=_s-6$Ol{ATD z3~>8}*KtRBP1W-BmlR@N&iDb zT(gh#oO>csT@p4x;rUmKp|KG_-{_Qa2pSa{Qc=_A!H*La3;+h6eQlTmr$S*Wh@mmM zpMk=RW4-3>O@v261}JEFZ9YW)1t2{#MU*RY+0i}^9!o@!SQvEnwL&ej0>sQH-GU$= zt0YgfV>DGH$s<+FK;ns#4>`4#VG$Y zpC#2)Qo-6ZRV8SQ_`a0~fSOz8YzB=HnyS)CHd0N^Kh0-j(TQq++XChDVag(EfwgH< z*7WjU7+;e$t08r2C5D=;Sq;7X7shK-);P%sQx@G8D4!pVM#Lp>TU}W(w0a+QhZmw? zVXb$@>J;gb666OqmJ0D40GH*bAe0{WRrV~$-NDfS`E_sQ!o>gJwAE1_tIe5qQz_q$ z{8O7sA$-ZA)aFcEO|8~A$laGAV}sKe zn*s7pyfYmdqd-AegH-lzIP+L6A#zW?J+A-p&5?GDPDh)JQfZT4V^rRWccxqWhZ#Un zW`OdPgGW8#3Z~CIFnmF4ECG}@atOSg_x0wT{l40IM=F(z2M2~PXmthCXOilKRS!^} z5|kNX^4|DI?$;Ufq17O0g&P|wkJk*C7@xN{jka-AH)0=<$j$JwkupSK>y==Jk(fD3c?zs@!Y0y710} z2h&ohXH=Z%U$U8yN}E0!%ljYSbM1oWngPsUODVPTSsjQru_PhRb_WD%)sv>Ns-b(s zXF1jHPD-Jk(M2(_#6cFH8Eh$S?{ni4c*yEF2$Y{1I4SYi-s*tb=}`&=vbA6Jf41k< z>?}%!lF@K#;G~ZTl-nIT9%}ES0Kj)-XFpO6v4y%C%M#{l8ct!UwcTfG9?m)T-t)Pi zZS9pZjUAvhmO1br;ybdlAJ9GnL`rN^h3b&M@VJxf5^!oRYV|wQ<*D&iy7KQ>XfM zh*lLg{dm;?S%-IIkm?@W^cN;)060$h4HPvEG-@L)3sC(8+SuXyV$VA{Rh0u%X#g#( zaNv1Q*5Mr)%7A+;wRkKisc-y6W0ShZGELY|Wg74ojd{C^yXkgl^(3`4I-TCGwkbNq zFMNmh{Po8NclJny0sKW{Kc<#%EPOl$++&rd6rk-3TyI*oCC|=)jUL;Ucg=u_E&joy zp9vW(pjK-^MSEWbQl$~b6P`48jrX&?3nY$vi{ z%bDB9)YlFDmWE7+avjO~WZz#hKlq?qB4P<#0SB61 zMJ?G@M`Y^cXMm#<48aM%4oE|pnPljm>qLw$JI7v56^`vsUs{8K$XuiaC6ICc8Yk#j+HH>nOpi6*lE^-AV}1N-|PJXjo) za7#Kz(q;`kbzWsf1^Vtel4TnDX+j>3 zF+CbYxa?f<;C~agfHE;?l}`zmLx_Njlxhd-ci`H}aQNbF^kw^(?p_%!3!!8wsGpy$uuj?cfCyewfdOtMZ*lGU#C7IRl~dRnuDXL8-zb63@{3uB8CKM|S=gxv}D z+EaCZ&#wF%wTdyjxLGTC;^OF{nuK{rK+j!O!$e6~wh4h|PcXDg)lV358Bn{eL4t@R z{kY)}w9F>eCTb%;QedNLd_fZv&X2kMSE*DU07S(0x(%q^^%I6%R&4^y7W)OJO3nb< zaJuzzN4XLDmRcUWbhcpVg>gmirBd;BkZP*K1??8#>V9RIt}PBHrJ>z-A1h3hS=(74 zt~`5 z-i`?{`O<{`6C20pR;5%?2lUu+d?Y9{9pqTw-shSD8r`y*+J0%Esa7V$)oBS(UC^d1 zYV3V(@Wp%cJ8<2W7&O&Nho$Flbj!6T{%Z!{n7n4~^fst5I%E6EDRDD}apQPX6aSRf z^nu?^%zKW*hsS(fP8Bk?pPWLC(YEV3jpZDZcP-C2ENE}KoVylU9ksryidHXn+g_g; z7iW$3aqo+kpI)Ar``b$;*=JL$UUYQZUY{viz3A{de6;CuZdeXsm;pEoriQW9!Exm> zq{}6q*WI?ez5BnLeCzne$vK~=Shtvvg9pzF_HnlqA;6N5+RMeL`jky_+QBhw? ztrj@QeMYy+Y^O01)8x8tYAB}AIZckTuz6bMO_eO=+0;-fLdP^Yp^R&qmKlGVTsyjK zYM2kmD~>-BYnspYd5jD2y?J&g$Qq=1`kZ|U;xz36fR9|6mKia5I%cl0XXDww0}>%g zS}N0YaAxDItREy>v|CwyW~)js2N)r7nyZ>;^!YEmmF7xDNtdU{s#bPi9M1tOp@NC@Hyh^zj9M^3k#a+@ta(=Acd2r+q1T# zH%Tcgot1U)D5Iqm?Bvo};d*VlSMy=q9Hq04L|;Weu(jlBDq6>ir-9uRZh@q2;XK^D z#nTZPyowB%=2(anfZ7X@Y!F_6*$}x}KF0&&void 0!==arguments[0]?arguments[0]:{},t=e.id,i=e.url,o=t||i;if(!o)throw new Error("An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.");if(n(o))return"https://vimeo.com/"+o;if(r(o))return o.replace("http:","https:");if(t)throw new TypeError("“"+t+"” is not a valid video id.");throw new TypeError("“"+o+"” is not a vimeo.com url.")}function o(e,t){return t={exports:{}},e(t,t.exports),t.exports}function a(e,t,n){var r=T.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),T.set(e.element,r)}function u(e,t){return(T.get(e.element)||{})[t]||[]}function s(e,t,n){var r=T.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],T.set(e.element,r),!0;var i=r[t].indexOf(n);return-1!==i&&r[t].splice(i,1),T.set(e.element,r),r[t]&&0===r[t].length}function c(e,t){var n=u(e,t);if(n.length<1)return!1;var r=n.shift();return s(e,t,r),r}function l(e,t){var n=T.get(e);T.set(t,n),T.delete(e)}function f(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return _.reduce(function(t,n){var r=e.getAttribute("data-vimeo-"+n);return(r||""===r)&&(t[n]=""===r?1:r),t},t)}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(n,i){if(!r(e))throw new TypeError("“"+e+"” is not a vimeo.com url.");var o="https://vimeo.com/api/oembed.json?url="+encodeURIComponent(e);for(var a in t)t.hasOwnProperty(a)&&(o+="&"+a+"="+encodeURIComponent(t[a]));var u="XDomainRequest"in window?new XDomainRequest:new XMLHttpRequest;u.open("GET",o,!0),u.onload=function(){if(404===u.status)return void i(new Error("“"+e+"” was not found."));if(403===u.status)return void i(new Error("“"+e+"” is not embeddable."));try{var t=JSON.parse(u.responseText);n(t)}catch(e){i(e)}},u.onerror=function(){var e=u.status?" ("+u.status+")":"";i(new Error("There was an error fetching the embed code from Vimeo"+e+"."))},u.send()})}function d(e,t){var n=e.html;if(!t)throw new TypeError("An element must be provided");if(null!==t.getAttribute("data-vimeo-initialized"))return t.querySelector("iframe");var r=document.createElement("div");return r.innerHTML=n,t.appendChild(r.firstChild),t.setAttribute("data-vimeo-initialized","true"),t.querySelector("iframe")}function v(e){return"string"==typeof e&&(e=JSON.parse(e)),e}function p(e,t,n){if(e.element.contentWindow&&e.element.contentWindow.postMessage){var r={method:t};void 0!==n&&(r.value=n);var i=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,"$1"));i>=8&&i<10&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}}function y(e,t){t=v(t);var n=[],r=void 0;if(t.event){if("error"===t.event){u(e,t.data.method).forEach(function(n){var r=new Error(t.data.message);r.name=t.data.name,n.reject(r),s(e,t.data.method,n)})}n=u(e,"event:"+t.event),r=t.data}else if(t.method){var i=c(e,t.method);i&&(n.push(i),r=t.value)}n.forEach(function(t){try{if("function"==typeof t)return void t.call(e,r);t.resolve(r)}catch(e){}})}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var g="undefined"!=typeof global&&"[object global]"==={}.toString.call(global),w=void 0!==Array.prototype.indexOf,b="undefined"!=typeof window&&void 0!==window.postMessage;if(!(g||w&&b))throw new Error("Sorry, the Vimeo Player API is not available in this browser.");var k="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},E=(o(function(e,t){!function(e){function t(e,t){function r(e){if(!this||this.constructor!==r)return new r(e);this._keys=[],this._values=[],this._itp=[],this.objectOnly=t,e&&n.call(this,e)}return t||w(e,"size",{get:y}),e.constructor=r,r.prototype=e,r}function n(e){this.add?e.forEach(this.add,this):e.forEach(function(e){this.set(e[0],e[1])},this)}function r(e){return this.has(e)&&(this._keys.splice(g,1),this._values.splice(g,1),this._itp.forEach(function(e){g0&&e(r,u))}catch(e){a.call(new s(u),e)}}}function a(t){var n=this;n.triggered||(n.triggered=!0,n.def&&(n=n.def),n.msg=t,n.state=2,n.chain.length>0&&e(r,n))}function u(e,t,n,r){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{};if(m(this,Player),window.jQuery&&e instanceof jQuery&&(e.length>1&&window.console&&console.warn&&console.warn("A jQuery object with multiple elements was passed, using the first element."),e=e[0]),"undefined"!=typeof document&&"string"==typeof e&&(e=document.getElementById(e)),!t(e))throw new TypeError("You must pass either a valid element or a valid id.");if("IFRAME"!==e.nodeName){var a=e.querySelector("iframe");a&&(e=a)}if("IFRAME"===e.nodeName&&!r(e.getAttribute("src")||""))throw new Error("The player element passed isn’t a Vimeo embed.");if(M.has(e))return M.get(e);this.element=e,this.origin="*";var u=new E(function(t,a){var u=function(e){if(r(e.origin)&&n.element.contentWindow===e.source){"*"===n.origin&&(n.origin=e.origin);var i=v(e.data),o="event"in i&&"ready"===i.event,a="method"in i&&"ping"===i.method;if(o||a)return n.element.setAttribute("data-ready","true"),void t();y(n,i)}};if(window.addEventListener?window.addEventListener("message",u,!1):window.attachEvent&&window.attachEvent("onmessage",u),"IFRAME"!==n.element.nodeName){var s=f(e,o);h(i(s),s).then(function(t){var r=d(t,e);return n.element=r,n._originalElement=e,l(e,r),M.set(n.element,n),t}).catch(function(e){return a(e)})}});return x.set(this,u),M.set(this.element,this),"IFRAME"===this.element.nodeName&&p(this,"ping"),this}return j(Player,[{key:"callMethod",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new E(function(r,i){return t.ready().then(function(){a(t,e,{resolve:r,reject:i}),p(t,e,n)}).catch(function(e){i(e)})})}},{key:"get",value:function(t){var n=this;return new E(function(r,i){return t=e(t,"get"),n.ready().then(function(){a(n,t,{resolve:r,reject:i}),p(n,t)})})}},{key:"set",value:function(t,n){var r=this;return E.resolve(n).then(function(n){if(t=e(t,"set"),void 0===n||null===n)throw new TypeError("There must be a value to set.");return r.ready().then(function(){return new E(function(e,i){a(r,t,{resolve:e,reject:i}),p(r,t,n)})})})}},{key:"on",value:function(e,t){if(!e)throw new TypeError("You must pass an event name.");if(!t)throw new TypeError("You must pass a callback function.");if("function"!=typeof t)throw new TypeError("The callback must be a function.");0===u(this,"event:"+e).length&&this.callMethod("addEventListener",e).catch(function(){}),a(this,"event:"+e,t)}},{key:"off",value:function(e,t){if(!e)throw new TypeError("You must pass an event name.");if(t&&"function"!=typeof t)throw new TypeError("The callback must be a function.");s(this,"event:"+e,t)&&this.callMethod("removeEventListener",e).catch(function(e){})}},{key:"loadVideo",value:function(e){return this.callMethod("loadVideo",e)}},{key:"ready",value:function(){var e=x.get(this)||new E(function(e,t){t("Unknown player. Probably unloaded.")});return E.resolve(e)}},{key:"addCuePoint",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.callMethod("addCuePoint",{time:e,data:t})}},{key:"removeCuePoint",value:function(e){return this.callMethod("removeCuePoint",e)}},{key:"enableTextTrack",value:function(e,t){if(!e)throw new TypeError("You must pass a language.");return this.callMethod("enableTextTrack",{language:e,kind:t})}},{key:"disableTextTrack",value:function(){return this.callMethod("disableTextTrack")}},{key:"pause",value:function(){return this.callMethod("pause")}},{key:"play",value:function(){return this.callMethod("play")}},{key:"unload",value:function(){return this.callMethod("unload")}},{key:"destroy",value:function(){var e=this;return new E(function(t){x.delete(e),M.delete(e.element),e._originalElement&&(M.delete(e._originalElement),e._originalElement.removeAttribute("data-vimeo-initialized")),e.element&&"IFRAME"===e.element.nodeName&&e.element.remove(),t()})}},{key:"getAutopause",value:function(){return this.get("autopause")}},{key:"setAutopause",value:function(e){return this.set("autopause",e)}},{key:"getColor",value:function(){return this.get("color")}},{key:"setColor",value:function(e){return this.set("color",e)}},{key:"getCuePoints",value:function(){return this.get("cuePoints")}},{key:"getCurrentTime",value:function(){return this.get("currentTime")}},{key:"setCurrentTime",value:function(e){return this.set("currentTime",e)}},{key:"getDuration",value:function(){return this.get("duration")}},{key:"getEnded",value:function(){return this.get("ended")}},{key:"getLoop",value:function(){return this.get("loop")}},{key:"setLoop",value:function(e){return this.set("loop",e)}},{key:"getPaused",value:function(){return this.get("paused")}},{key:"getPlaybackRate",value:function(){return this.get("playbackRate")}},{key:"setPlaybackRate",value:function(e){return this.set("playbackRate",e)}},{key:"getTextTracks",value:function(){return this.get("textTracks")}},{key:"getVideoEmbedCode",value:function(){return this.get("videoEmbedCode")}},{key:"getVideoId",value:function(){return this.get("videoId")}},{key:"getVideoTitle",value:function(){return this.get("videoTitle")}},{key:"getVideoWidth",value:function(){return this.get("videoWidth")}},{key:"getVideoHeight",value:function(){return this.get("videoHeight")}},{key:"getVideoUrl",value:function(){return this.get("videoUrl")}},{key:"getVolume",value:function(){return this.get("volume")}},{key:"setVolume",value:function(e){return this.set("volume",e)}}]),Player}();return g||(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=[].slice.call(e.querySelectorAll("[data-vimeo-id], [data-vimeo-url]")),n=function(e){"console"in window&&console.error&&console.error("There was an error creating an embed: "+e)};t.forEach(function(e){try{if(null!==e.getAttribute("data-vimeo-defer"))return;var t=f(e);h(i(t),t).then(function(t){return d(t,e)}).catch(n)}catch(e){n(e)}})}(),function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=function(t){if(r(t.origin)&&t.data&&"spacechange"===t.data.event)for(var n=e.querySelectorAll("iframe"),i=0;icomponent = 'mod_vimeoactivity'; -$plugin->release = '1.0.6'; -$plugin->version = 2021092806; +$plugin->release = '1.2.14'; +$plugin->version = 2023030117; $plugin->maturity = MATURITY_BETA; $plugin->requires = 2016052311; $plugin->dependencies = []; diff --git a/view.php b/view.php index 20de6ba..65d5312 100644 --- a/view.php +++ b/view.php @@ -1,4 +1,5 @@ id); $course = $DB->get_record('course', ['id' => $module->course], '*', MUST_EXIST); $video = vimeoactivity_fetch_video($module->instance); +list ($course, $cm) = get_course_and_cm_from_cmid($cmid, 'vimeoactivity'); +$video = $DB->get_record('vimeoactivity', ['id' => $cm->instance], '*', MUST_EXIST); + +require_login($course, true, $cm); + +$modulecontext = context_module::instance($cm->id); + +$event = \mod_vimeoactivity\event\course_module_viewed::create(array( + 'objectid' => $video->id, + 'context' => $modulecontext +)); +$event->add_record_snapshot('course_modules', $cm); +$event->add_record_snapshot('course', $course); +$event->add_record_snapshot('vimeoactivity', $video); +$event->trigger(); + +$completion = new completion_info($course); +$completion->set_module_viewed($cm); + // Because we were unable to load the // requested Vimeo video, displaying // an error message about this. if (empty($video)) { - error('The requested Vimeo video was not found.'); + echo('The requested Vimeo video was not found.'); } // This user needs to be authenticated @@ -57,22 +80,40 @@ // before viewing this Vimeo video. require_capability('mod/vimeoactivity:view', $context); -// Marking this Vimeo video as viewed so -// any other task that depends on it, works. -$completion = new completion_info($course); -$completion->set_module_viewed($module); - // Deciding if we need to render the Moodle // interface (with header, footer, menus, // blocks, etc) or the full screen one. if ($video->popupopen == false) { - $PAGE->set_url('/mod/vimeoactivity/view.php', ['id' => $video->id]); + $PAGE->set_url('/mod/vimeoactivity/view.php', ['id' => $cm->id]); $PAGE->set_title(format_string($video->name)); $PAGE->set_heading(format_string($course->fullname)); - + echo($OUTPUT->header()); echo(vimeoactivity_render_video($video, true, true, false)); + echo(''); echo($OUTPUT->footer()); } else { From 162e88b5ddb6f492fcab9c6f29930edb4b98e1f6 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 14:28:18 +0200 Subject: [PATCH 20/44] Add files via upload --- workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 workflows/ci.yml diff --git a/workflows/ci.yml b/workflows/ci.yml new file mode 100644 index 0000000..3618d13 --- /dev/null +++ b/workflows/ci.yml @@ -0,0 +1,7 @@ +name: ci + +on: [push, pull_request] + +jobs: + ci: + uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main \ No newline at end of file From e35df26207aad5e19ee350d7517bb1058ef1d81a Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 14:28:52 +0200 Subject: [PATCH 21/44] Rename workflows/ci.yml to .github/workflows/ci.yml --- {workflows => .github/workflows}/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {workflows => .github/workflows}/ci.yml (86%) diff --git a/workflows/ci.yml b/.github/workflows/ci.yml similarity index 86% rename from workflows/ci.yml rename to .github/workflows/ci.yml index 3618d13..4618731 100644 --- a/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,4 +4,4 @@ on: [push, pull_request] jobs: ci: - uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main \ No newline at end of file + uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main From 358969bb96d3a8afc3e13590587952c57e47bd7e Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 22:14:02 +0200 Subject: [PATCH 22/44] Update vimeoactivity.php --- lang/en/vimeoactivity.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lang/en/vimeoactivity.php b/lang/en/vimeoactivity.php index f5416b7..0573120 100644 --- a/lang/en/vimeoactivity.php +++ b/lang/en/vimeoactivity.php @@ -19,8 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - * @copyright BlackBean Technologies Ltda - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || exit(0); @@ -34,7 +34,9 @@ $string['modulenameplural'] = 'Vimeo Activity'; $string['moduleadministration'] = 'Vimeo Activity - Administration'; $string['vimeo:addinstance'] = 'Add instance'; -$string['vimeo'] = 'Vimeo Activity'; +$string['vimeoactivity:addinstance']='add instance'; +$string['vimeoactivity:view']='view'; +$string['vimeoactivity'] = 'Vimeo Activity'; $string['mod/vimeoactivity'] = 'Vimeo Activity'; $string['mod_vimeoactivity'] = 'Vimeo Activity'; $string['label_name'] = 'Name'; From 4c49dbcba916ac9b06889273467e12bb15af18b6 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 22:15:43 +0200 Subject: [PATCH 23/44] Add files via upload --- ...ckup_vimeoactivity_activity_task.class.php | 5 ++- .../moodle2/backup_vimeoactivity_stepslib.php | 8 ++-- ...tore_vimeoactivity_activity_task.class.php | 5 ++- .../restore_vimeoactivity_stepslib.php | 7 ++-- classes/analytics/indicator/activity_base.php | 5 ++- .../analytics/indicator/cognitive_depth.php | 5 ++- .../analytics/indicator/social_breadth.php | 5 ++- classes/completion/custom_completion.php | 5 ++- .../course_module_instance_list_viewed.php | 7 +++- classes/event/course_module_viewed.php | 5 ++- classes/external/progress.php | 5 ++- classes/util/watchprog.php | 37 ++----------------- db/access.php | 3 +- db/install.php | 4 +- db/services.php | 5 ++- db/uninstall.php | 3 +- db/upgrade.php | 3 +- index.php | 19 +++++----- lib.php | 26 +------------ locallib.php | 6 +-- mod_form.php | 26 +++++++------ ping.php | 4 +- version.php | 4 +- view.php | 9 ++--- 24 files changed, 99 insertions(+), 112 deletions(-) diff --git a/backup/moodle2/backup_vimeoactivity_activity_task.class.php b/backup/moodle2/backup_vimeoactivity_activity_task.class.php index b10fae8..3c1424e 100644 --- a/backup/moodle2/backup_vimeoactivity_activity_task.class.php +++ b/backup/moodle2/backup_vimeoactivity_activity_task.class.php @@ -17,7 +17,10 @@ /** * The task that provides all the steps to perform a complete backup is defined here. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @category backup */ diff --git a/backup/moodle2/backup_vimeoactivity_stepslib.php b/backup/moodle2/backup_vimeoactivity_stepslib.php index 9f86073..1ab4c89 100644 --- a/backup/moodle2/backup_vimeoactivity_stepslib.php +++ b/backup/moodle2/backup_vimeoactivity_stepslib.php @@ -17,12 +17,13 @@ /** * Backup steps for mod_vimeoactivity are defined here. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @category backup */ -defined('MOODLE_INTERNAL') || die(); - // More information about the backup process: {@link https://docs.moodle.org/dev/Backup_API}. // More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}. @@ -57,7 +58,6 @@ protected function define_structure() { 'timecreated', 'timemodified']); - // Define the source tables for the elements. $vimeoactivity->set_source_table('vimeoactivity', ['id' => backup::VAR_ACTIVITYID]); diff --git a/backup/moodle2/restore_vimeoactivity_activity_task.class.php b/backup/moodle2/restore_vimeoactivity_activity_task.class.php index d7faed0..f11d374 100644 --- a/backup/moodle2/restore_vimeoactivity_activity_task.class.php +++ b/backup/moodle2/restore_vimeoactivity_activity_task.class.php @@ -17,7 +17,10 @@ /** * The task that provides a complete restore of mod_vimeoactivity is defined here. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @category backup */ diff --git a/backup/moodle2/restore_vimeoactivity_stepslib.php b/backup/moodle2/restore_vimeoactivity_stepslib.php index 11010e2..d4af89e 100644 --- a/backup/moodle2/restore_vimeoactivity_stepslib.php +++ b/backup/moodle2/restore_vimeoactivity_stepslib.php @@ -17,12 +17,13 @@ /** * All the steps to restore mod_vimeoactivity are defined here. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @category backup */ -defined('MOODLE_INTERNAL') || die(); - // More information about the backup process: {@link https://docs.moodle.org/dev/Backup_API}. // More information about the restore process: {@link https://docs.moodle.org/dev/Restore_API}. diff --git a/classes/analytics/indicator/activity_base.php b/classes/analytics/indicator/activity_base.php index f8b602e..2fab70d 100644 --- a/classes/analytics/indicator/activity_base.php +++ b/classes/analytics/indicator/activity_base.php @@ -17,7 +17,10 @@ /** * Activity base class. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_vimeoactivity\analytics\indicator; diff --git a/classes/analytics/indicator/cognitive_depth.php b/classes/analytics/indicator/cognitive_depth.php index 1a1a08e..65adcea 100644 --- a/classes/analytics/indicator/cognitive_depth.php +++ b/classes/analytics/indicator/cognitive_depth.php @@ -17,7 +17,10 @@ /** * Cognitive depth indicator - vimeoactivity. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_vimeoactivity\analytics\indicator; diff --git a/classes/analytics/indicator/social_breadth.php b/classes/analytics/indicator/social_breadth.php index 560892d..b73acbd 100644 --- a/classes/analytics/indicator/social_breadth.php +++ b/classes/analytics/indicator/social_breadth.php @@ -17,7 +17,10 @@ /** * Social breadth indicator - vimeoactivity. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_vimeoactivity\analytics\indicator; diff --git a/classes/completion/custom_completion.php b/classes/completion/custom_completion.php index 01cd53a..732350c 100644 --- a/classes/completion/custom_completion.php +++ b/classes/completion/custom_completion.php @@ -26,7 +26,10 @@ * * Class for defining mod_vimeoactivity's custom completion rules and fetching the completion statuses * of the custom completion rules for a given instance and a user. - * + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class custom_completion extends activity_custom_completion { diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php index fda6974..e6dc476 100644 --- a/classes/event/course_module_instance_list_viewed.php +++ b/classes/event/course_module_instance_list_viewed.php @@ -13,7 +13,12 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - +/** + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ namespace mod_vimeoactivity\event; class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php index 8bec2e5..46a58f3 100644 --- a/classes/event/course_module_viewed.php +++ b/classes/event/course_module_viewed.php @@ -19,7 +19,10 @@ /** * The course_module_viewed event class. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @category event */ class course_module_viewed extends \core\event\course_module_viewed { diff --git a/classes/external/progress.php b/classes/external/progress.php index b36f466..f1f6eb2 100644 --- a/classes/external/progress.php +++ b/classes/external/progress.php @@ -29,7 +29,10 @@ /** * Completion external api class. * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class progress extends external_api { /** diff --git a/classes/util/watchprog.php b/classes/util/watchprog.php index 0d076d6..c454da4 100644 --- a/classes/util/watchprog.php +++ b/classes/util/watchprog.php @@ -18,8 +18,10 @@ /** * watchprogress class. - * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class watchprog { /** @@ -154,35 +156,4 @@ public function vimeoactivity_save_progress($userid, $videoid, $value) { return(false); } - /** - * [vimeoactivity_delete_progress] - * - * @param integer $userid - * @param integer $videoid - * @return boolean - */ - public function vimeoactivity_delete_progress($userid, $videoid) { - // Importing all the required global - // objects into this function scope. - global $DB; - - // Normalizing the supplied arguments and making - // sure they are within the required parameters. - $userid = max(0, (integer)$userid); - $videoid = max(0, (integer)$videoid); - - // Verifying if the supplied identifiers are valid - // (greater than zero) and, if not, there is no need - // to even touch the database and returning a false - // boolean value as this function result. - if ($userid < 1 || $videoid < 1) { - return(false); - } - - // Removing the requested object from the - // database and returning a boolean value - // as this function result. - return((boolean)$DB->delete_records('vimeoactivity_progress', ['user' => $userid, 'video' => $videoid])); - } - } diff --git a/db/access.php b/db/access.php index ec70f44..5b42706 100644 --- a/db/access.php +++ b/db/access.php @@ -19,7 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); diff --git a/db/install.php b/db/install.php index 346367e..db58788 100644 --- a/db/install.php +++ b/db/install.php @@ -19,8 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** diff --git a/db/services.php b/db/services.php index 660bd50..9023da3 100644 --- a/db/services.php +++ b/db/services.php @@ -17,7 +17,10 @@ /** * Vimeo services definition * - * @package mod_vimeoactivity + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); diff --git a/db/uninstall.php b/db/uninstall.php index 08550dc..ba87395 100644 --- a/db/uninstall.php +++ b/db/uninstall.php @@ -19,7 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** diff --git a/db/upgrade.php b/db/upgrade.php index 940dfd9..44e0fdb 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -19,7 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** diff --git a/index.php b/index.php index ec65cba..3ccb7d4 100644 --- a/index.php +++ b/index.php @@ -18,9 +18,9 @@ * This file contains the required routines for this activity module. * * @package mod_vimeoactivity - * @author Vignesh - - * @license http://www.gnu.org/copyleft/gpl.html + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require(__DIR__.'/../../config.php'); @@ -52,23 +52,24 @@ $videos = get_all_instances_in_course('vimeoactivity', $course); if (empty($videos)) { - notice(get_string('no$vimeoactivityinstances', 'mod_vimeoactivity'), new moodle_url('/course/view.php', array('id' => $course->id))); + notice(get_string('no$vimeoactivityinstances', 'mod_vimeoactivity'), + new moodle_url('/course/view.php', array('id' => $course->id))); } $table = new html_table(); $table->attributes['class'] = 'generaltable mod_index'; if ($course->format == 'weeks') { - $table->head = array(get_string('week'), get_string('name')); + $table->head = array(get_string('week'), get_string('name')); $table->align = array('center', 'left'); } else if ($course->format == 'topics') { - $table->head = array(get_string('topic'), get_string('name')); + $table->head = array(get_string('topic'), get_string('name')); $table->align = array('center', 'left', 'left', 'left'); } else if ($course->format == 'tiles') { - $table->head = array('Tile', get_string('name')); + $table->head = array('Tile', get_string('name')); $table->align = array('center', 'left', 'left', 'left'); } else { - $table->head = array(get_string('name')); + $table->head = array(get_string('name')); $table->align = array('left', 'left', 'left'); } @@ -80,7 +81,7 @@ new moodle_url('/mod/vimeoactivity/view.php', array('id' => $video->coursemodule)), format_string($video->name, true)); - if ($course->format == 'weeks' or $course->format == 'topics' or $course->format == 'tiles') { + if ($course->format == 'weeks' || $course->format == 'topics' || $course->format == 'tiles') { $table->data[] = array($video->section, $link); } else { $table->data[] = array($link); diff --git a/lib.php b/lib.php index 48f6ef3..28cd894 100644 --- a/lib.php +++ b/lib.php @@ -19,8 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** @@ -212,28 +212,6 @@ function vimeoactivity_delete_instance($id) { return(false); } -// /** -// * This standard function will check all instances of this -// * module and make sure there are up-to-date events created -// * for each of them. If courseid equals to zero, then every -// * Vimeo event in the site is checked, else only Vimeo events -// * belonging to the course specified are checked. This is only -// * required if the module is generating calendar events. -// * -// * @param integer $courseid -// * @return boolean -// */ -// function vimeoactivity_refresh_events($courseid) { -// // Because we don't have any related -// // events returning a true boolean -// // value as this function result. -// if ($courseid > 0) { -// return(true); -// } else { -// return(false); -// } -// } - /** * Obtains the automatic completion state * for this video based on any conditions diff --git a/locallib.php b/locallib.php index 69fba60..b448a05 100644 --- a/locallib.php +++ b/locallib.php @@ -19,8 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** @@ -202,7 +202,7 @@ function vimeoactivity_update_video(stdclass $video) { // Executing the required command // to persist the supplied object // within the database. - if ($result = $DB->update_record_raw('vimeoactivity', $values)) { + if ($DB->update_record_raw('vimeoactivity', $values)) { // Because we were able to execute this operation // completely and successfully, returning a true // boolean value as this function result. diff --git a/mod_form.php b/mod_form.php index b630d55..151c27a 100644 --- a/mod_form.php +++ b/mod_form.php @@ -19,7 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); @@ -151,17 +152,18 @@ public function completion_rule_enabled($data) { * * @param stdClass $data the form data to be modified. */ - // public function data_postprocessing($data) { - // parent::data_postprocessing($data); - // if (!empty($data->completionunlocked)) { - // // Turn off completion settings if the checkboxes aren't ticked. - // $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC; - - // if (!$autocompletion || empty($data->completionprogress)) { - // $data->completionprogress = null; - // } - // } - // } + /** public function data_postprocessing($data) { + * parent::data_postprocessing($data); + * if (!empty($data->completionunlocked)) { + * // Turn off completion settings if the checkboxes aren't ticked. + * $autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC; + * + * if (!$autocompletion || empty($data->completionprogress)) { + * $data->completionprogress = null; + * } + * } + * } + */ /** * This function is responsible for validating * the supplied Vimeo video data and returning diff --git a/ping.php b/ping.php index f9ae031..7f09dd1 100644 --- a/ping.php +++ b/ping.php @@ -19,8 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('AJAX_SCRIPT', true); diff --git a/version.php b/version.php index 52eb9d6..bc4836d 100644 --- a/version.php +++ b/version.php @@ -19,8 +19,8 @@ * * @package mod_vimeoactivity * @author Vignesh - - * @license http://www.gnu.org/copyleft/gpl.html + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); diff --git a/view.php b/view.php index 65d5312..ce25dd7 100644 --- a/view.php +++ b/view.php @@ -1,5 +1,4 @@ + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ // Loading all libraries, classes @@ -88,7 +87,7 @@ $PAGE->set_url('/mod/vimeoactivity/view.php', ['id' => $cm->id]); $PAGE->set_title(format_string($video->name)); $PAGE->set_heading(format_string($course->fullname)); - + echo($OUTPUT->header()); echo(vimeoactivity_render_video($video, true, true, false)); echo(''); echo($OUTPUT->footer()); From da8c94248c80b44058eeae3962dc68615120633d Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:36:27 +0200 Subject: [PATCH 24/44] Delete backup_vimeoactivity_settingslib.php --- .../backup_vimeoactivity_settingslib.php | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 backup/moodle2/backup_vimeoactivity_settingslib.php diff --git a/backup/moodle2/backup_vimeoactivity_settingslib.php b/backup/moodle2/backup_vimeoactivity_settingslib.php deleted file mode 100644 index f1b7b38..0000000 --- a/backup/moodle2/backup_vimeoactivity_settingslib.php +++ /dev/null @@ -1,27 +0,0 @@ -. - -/** - * vimeoactivity backup settings - * - * Workshop has no particular settings but the inherited from the generic - * {@link backup_activity_task}. - * - * @package mod_vimeoactivity - * @category backup - */ - -defined('MOODLE_INTERNAL') || die(); From 5d56ae7ff1a903952321064aa80d8ada7a43bf4c Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:37:44 +0200 Subject: [PATCH 25/44] Add files via upload --- classes/analytics/indicator/activity_base.php | 8 +++++++ .../analytics/indicator/cognitive_depth.php | 20 ++++++++++++++++++ .../analytics/indicator/social_breadth.php | 21 ++++++++++++++++--- .../course_module_instance_list_viewed.php | 7 ++++++- classes/event/course_module_viewed.php | 11 +++++++++- classes/external/progress.php | 10 ++------- classes/util/watchprog.php | 15 ++++++++++++- lib.php | 6 +++--- 8 files changed, 81 insertions(+), 17 deletions(-) diff --git a/classes/analytics/indicator/activity_base.php b/classes/analytics/indicator/activity_base.php index 2fab70d..d020168 100644 --- a/classes/analytics/indicator/activity_base.php +++ b/classes/analytics/indicator/activity_base.php @@ -24,6 +24,14 @@ */ namespace mod_vimeoactivity\analytics\indicator; +/** + * Activity base class. + * + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity { /** diff --git a/classes/analytics/indicator/cognitive_depth.php b/classes/analytics/indicator/cognitive_depth.php index 65adcea..7184883 100644 --- a/classes/analytics/indicator/cognitive_depth.php +++ b/classes/analytics/indicator/cognitive_depth.php @@ -25,6 +25,15 @@ namespace mod_vimeoactivity\analytics\indicator; +/** + * Activity base class. + * + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + class cognitive_depth extends activity_base { /** @@ -38,10 +47,21 @@ public static function get_name() : \lang_string { return new \lang_string('indicator:cognitivedepth', 'mod_vimeoactivity'); } + /** + * Defines indicator type. + * + * @return string + */ public function get_indicator_type() { return self::INDICATOR_COGNITIVE; } + /** + * Returns the potential level of social breadth. + * + * @return int + */ + public function get_cognitive_depth_level(\cm_info $cm) { return self::COGNITIVE_LEVEL_1; } diff --git a/classes/analytics/indicator/social_breadth.php b/classes/analytics/indicator/social_breadth.php index b73acbd..c0e0f44 100644 --- a/classes/analytics/indicator/social_breadth.php +++ b/classes/analytics/indicator/social_breadth.php @@ -24,7 +24,14 @@ */ namespace mod_vimeoactivity\analytics\indicator; - +/** + * Activity base class. + * + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class social_breadth extends activity_base { /** @@ -37,11 +44,19 @@ class social_breadth extends activity_base { public static function get_name() : \lang_string { return new \lang_string('indicator:socialbreadth', 'mod_vimeoactivity'); } - + /** + * Define indicator typr + * + * @return string + */ public function get_indicator_type() { return self::INDICATOR_SOCIAL; } - + /** + * Returns the potential level of social breadth. + * + * @return int + */ public function get_social_breadth_level(\cm_info $cm) { return self::SOCIAL_LEVEL_1; } diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php index e6dc476..c5c0488 100644 --- a/classes/event/course_module_instance_list_viewed.php +++ b/classes/event/course_module_instance_list_viewed.php @@ -20,7 +20,12 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace mod_vimeoactivity\event; - +/** + * @package mod_vimeoactivity + * @author Mohammad Farouk + * @copyright 2023 Mohammad Farouk + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed { } diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php index 46a58f3..be6b70c 100644 --- a/classes/event/course_module_viewed.php +++ b/classes/event/course_module_viewed.php @@ -34,7 +34,16 @@ protected function init() { $this->data['edulevel'] = self::LEVEL_PARTICIPATING; $this->data['objecttable'] = 'vimeoactivity'; } - + /** + * This is used when restoring course logs where it is required that we + * map the objectid to it's new value in the new course. + * Does nothing in the base class except display a debugging message warning + * the user that the event does not contain the required functionality to + * map this information. For events that do not store an objectid this won't + * be called, so no debugging message will be displayed. + * + * @return array + */ public static function get_objectid_mapping() { return array('db' => 'vimeoactivity', 'restore' => 'vimeoactivity'); } diff --git a/classes/external/progress.php b/classes/external/progress.php index f1f6eb2..15a53d2 100644 --- a/classes/external/progress.php +++ b/classes/external/progress.php @@ -51,7 +51,7 @@ public static function track_parameters() { * Complete method * * @param int $cmid - * + * @param int $watchprog * @return array * * @throws \coding_exception @@ -75,8 +75,7 @@ public static function track($cmid, $watchprog) { } $progutil = new watchprog(); - $progutil->addpoint($cm->instance, $watchprog); - + $progutil->addprogress($cm->instance, $watchprog); $completion = new completion_info($course); $completion->update_state($cm, COMPLETION_COMPLETE); @@ -97,9 +96,4 @@ public static function track_returns() { ) ); } - - /** - */ - public function __construct() { - } } diff --git a/classes/util/watchprog.php b/classes/util/watchprog.php index c454da4..0d4cde8 100644 --- a/classes/util/watchprog.php +++ b/classes/util/watchprog.php @@ -24,7 +24,20 @@ * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class watchprog { - /** + public function addprogress($videoid, $watchprog) { + global $DB, $USER; + + $data = new \stdClass(); + $data->video = $videoid; + $data->user = $USER->id; + $data->progress = $watchprog; + $data->timecreated = time(); + + $id = $DB->insert_record('vimeoactivity_progress', $data); + + return $id; + } + /** * [vimeoactivity_fetch_progress] * * @param integer $userid diff --git a/lib.php b/lib.php index 28cd894..463dd47 100644 --- a/lib.php +++ b/lib.php @@ -305,7 +305,7 @@ function vimeoactivity_print_recent_activity($course, $viewfullnames, $timestart * * This callback function is supposed to populate the passed array with * custom activity records. These records are then rendered into HTML via - * {@link vimeoactivity_print_recent_mod_activity()}. + * {vimeoactivity_print_recent_mod_activity()}. * * Returns void, it adds items into $activities and increases $index. * @@ -323,12 +323,12 @@ function vimeoactivity_get_recent_mod_activity(&$activities, &$index, $timestart /** * Prints single activity item prepared by - * {@link vimeoactivity_get_recent_mod_activity()} + * {vimeoactivity_get_recent_mod_activity()} * * @param stdclass $activity activity record with added 'cmid' property * @param integer $courseid the id of the course we produce the report for * @param boolean $detail print detailed report - * @param array $modnames as returned by {@link get_module_types_names()} + * @param array $modnames as returned by {get_module_types_names()} * @param boolean $viewfullnames disautoplay users' full names */ function vimeoactivity_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames) { From a192a86a5d87f8a0d132085938711fabb31bf45f Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sun, 5 Mar 2023 23:59:03 +0200 Subject: [PATCH 26/44] Add files via upload --- script.js | 2644 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 2643 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 113082f..4996ac1 100644 --- a/script.js +++ b/script.js @@ -1,2 +1,2644 @@ /*! @vimeo/player v2.18.0 | (c) 2022 Vimeo | MIT License | https://github.com/vimeo/player.js */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).Vimeo=e.Vimeo||{},e.Vimeo.Player=t())}(this,function(){"use strict";function r(e,t){for(var n=0;n 0 && arguments[0] !== undefined ? arguments[0] : {}; + var id = oEmbedParameters.id; + var url = oEmbedParameters.url; + var idOrUrl = id || url; + + if (!idOrUrl) { + throw new Error('An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.'); + } + + if (isInteger(idOrUrl)) { + return "https://vimeo.com/".concat(idOrUrl); + } + + if (isVimeoUrl(idOrUrl)) { + return idOrUrl.replace('http:', 'https:'); + } + + if (id) { + throw new TypeError("\u201C".concat(id, "\u201D is not a valid video id.")); + } + + throw new TypeError("\u201C".concat(idOrUrl, "\u201D is not a vimeo.com url.")); + } + + var arrayIndexOfSupport = typeof Array.prototype.indexOf !== 'undefined'; + var postMessageSupport = typeof window !== 'undefined' && typeof window.postMessage !== 'undefined'; + + if (!isNode && (!arrayIndexOfSupport || !postMessageSupport)) { + throw new Error('Sorry, the Vimeo Player API is not available in this browser.'); + } + + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + /*! + * weakmap-polyfill v2.0.4 - ECMAScript6 WeakMap polyfill + * https://github.com/polygonplanet/weakmap-polyfill + * Copyright (c) 2015-2021 polygonplanet + * @license MIT + */ + (function (self) { + + if (self.WeakMap) { + return; + } + + var hasOwnProperty = Object.prototype.hasOwnProperty; + + var hasDefine = Object.defineProperty && function () { + try { + // Avoid IE8's broken Object.defineProperty + return Object.defineProperty({}, 'x', { + value: 1 + }).x === 1; + } catch (e) {} + }(); + + var defineProperty = function (object, name, value) { + if (hasDefine) { + Object.defineProperty(object, name, { + configurable: true, + writable: true, + value: value + }); + } else { + object[name] = value; + } + }; + + self.WeakMap = function () { + // ECMA-262 23.3 WeakMap Objects + function WeakMap() { + if (this === void 0) { + throw new TypeError("Constructor WeakMap requires 'new'"); + } + + defineProperty(this, '_id', genId('_WeakMap')); // ECMA-262 23.3.1.1 WeakMap([iterable]) + + if (arguments.length > 0) { + // Currently, WeakMap `iterable` argument is not supported + throw new TypeError('WeakMap iterable is not supported'); + } + } // ECMA-262 23.3.3.2 WeakMap.prototype.delete(key) + + + defineProperty(WeakMap.prototype, 'delete', function (key) { + checkInstance(this, 'delete'); + + if (!isObject(key)) { + return false; + } + + var entry = key[this._id]; + + if (entry && entry[0] === key) { + delete key[this._id]; + return true; + } + + return false; + }); // ECMA-262 23.3.3.3 WeakMap.prototype.get(key) + + defineProperty(WeakMap.prototype, 'get', function (key) { + checkInstance(this, 'get'); + + if (!isObject(key)) { + return void 0; + } + + var entry = key[this._id]; + + if (entry && entry[0] === key) { + return entry[1]; + } + + return void 0; + }); // ECMA-262 23.3.3.4 WeakMap.prototype.has(key) + + defineProperty(WeakMap.prototype, 'has', function (key) { + checkInstance(this, 'has'); + + if (!isObject(key)) { + return false; + } + + var entry = key[this._id]; + + if (entry && entry[0] === key) { + return true; + } + + return false; + }); // ECMA-262 23.3.3.5 WeakMap.prototype.set(key, value) + + defineProperty(WeakMap.prototype, 'set', function (key, value) { + checkInstance(this, 'set'); + + if (!isObject(key)) { + throw new TypeError('Invalid value used as weak map key'); + } + + var entry = key[this._id]; + + if (entry && entry[0] === key) { + entry[1] = value; + return this; + } + + defineProperty(key, this._id, [key, value]); + return this; + }); + + function checkInstance(x, methodName) { + if (!isObject(x) || !hasOwnProperty.call(x, '_id')) { + throw new TypeError(methodName + ' method called on incompatible receiver ' + typeof x); + } + } + + function genId(prefix) { + return prefix + '_' + rand() + '.' + rand(); + } + + function rand() { + return Math.random().toString().substring(2); + } + + defineProperty(WeakMap, '_polyfill', true); + return WeakMap; + }(); + + function isObject(x) { + return Object(x) === x; + } + })(typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : commonjsGlobal); + + var npo_src = createCommonjsModule(function (module) { + /*! Native Promise Only + v0.8.1 (c) Kyle Simpson + MIT License: http://getify.mit-license.org + */ + (function UMD(name, context, definition) { + // special form of UMD for polyfilling across evironments + context[name] = context[name] || definition(); + + if ( module.exports) { + module.exports = context[name]; + } + })("Promise", typeof commonjsGlobal != "undefined" ? commonjsGlobal : commonjsGlobal, function DEF() { + + var builtInProp, + cycle, + scheduling_queue, + ToString = Object.prototype.toString, + timer = typeof setImmediate != "undefined" ? function timer(fn) { + return setImmediate(fn); + } : setTimeout; // dammit, IE8. + + try { + Object.defineProperty({}, "x", {}); + + builtInProp = function builtInProp(obj, name, val, config) { + return Object.defineProperty(obj, name, { + value: val, + writable: true, + configurable: config !== false + }); + }; + } catch (err) { + builtInProp = function builtInProp(obj, name, val) { + obj[name] = val; + return obj; + }; + } // Note: using a queue instead of array for efficiency + + + scheduling_queue = function Queue() { + var first, last, item; + + function Item(fn, self) { + this.fn = fn; + this.self = self; + this.next = void 0; + } + + return { + add: function add(fn, self) { + item = new Item(fn, self); + + if (last) { + last.next = item; + } else { + first = item; + } + + last = item; + item = void 0; + }, + drain: function drain() { + var f = first; + first = last = cycle = void 0; + + while (f) { + f.fn.call(f.self); + f = f.next; + } + } + }; + }(); + + function schedule(fn, self) { + scheduling_queue.add(fn, self); + + if (!cycle) { + cycle = timer(scheduling_queue.drain); + } + } // promise duck typing + + + function isThenable(o) { + var _then, + o_type = typeof o; + + if (o != null && (o_type == "object" || o_type == "function")) { + _then = o.then; + } + + return typeof _then == "function" ? _then : false; + } + + function notify() { + for (var i = 0; i < this.chain.length; i++) { + notifyIsolated(this, this.state === 1 ? this.chain[i].success : this.chain[i].failure, this.chain[i]); + } + + this.chain.length = 0; + } // NOTE: This is a separate function to isolate + // the `try..catch` so that other code can be + // optimized better + + + function notifyIsolated(self, cb, chain) { + var ret, _then; + + try { + if (cb === false) { + chain.reject(self.msg); + } else { + if (cb === true) { + ret = self.msg; + } else { + ret = cb.call(void 0, self.msg); + } + + if (ret === chain.promise) { + chain.reject(TypeError("Promise-chain cycle")); + } else if (_then = isThenable(ret)) { + _then.call(ret, chain.resolve, chain.reject); + } else { + chain.resolve(ret); + } + } + } catch (err) { + chain.reject(err); + } + } + + function resolve(msg) { + var _then, + self = this; // already triggered? + + + if (self.triggered) { + return; + } + + self.triggered = true; // unwrap + + if (self.def) { + self = self.def; + } + + try { + if (_then = isThenable(msg)) { + schedule(function () { + var def_wrapper = new MakeDefWrapper(self); + + try { + _then.call(msg, function $resolve$() { + resolve.apply(def_wrapper, arguments); + }, function $reject$() { + reject.apply(def_wrapper, arguments); + }); + } catch (err) { + reject.call(def_wrapper, err); + } + }); + } else { + self.msg = msg; + self.state = 1; + + if (self.chain.length > 0) { + schedule(notify, self); + } + } + } catch (err) { + reject.call(new MakeDefWrapper(self), err); + } + } + + function reject(msg) { + var self = this; // already triggered? + + if (self.triggered) { + return; + } + + self.triggered = true; // unwrap + + if (self.def) { + self = self.def; + } + + self.msg = msg; + self.state = 2; + + if (self.chain.length > 0) { + schedule(notify, self); + } + } + + function iteratePromises(Constructor, arr, resolver, rejecter) { + for (var idx = 0; idx < arr.length; idx++) { + (function IIFE(idx) { + Constructor.resolve(arr[idx]).then(function $resolver$(msg) { + resolver(idx, msg); + }, rejecter); + })(idx); + } + } + + function MakeDefWrapper(self) { + this.def = self; + this.triggered = false; + } + + function MakeDef(self) { + this.promise = self; + this.state = 0; + this.triggered = false; + this.chain = []; + this.msg = void 0; + } + + function Promise(executor) { + if (typeof executor != "function") { + throw TypeError("Not a function"); + } + + if (this.__NPO__ !== 0) { + throw TypeError("Not a promise"); + } // instance shadowing the inherited "brand" + // to signal an already "initialized" promise + + + this.__NPO__ = 1; + var def = new MakeDef(this); + + this["then"] = function then(success, failure) { + var o = { + success: typeof success == "function" ? success : true, + failure: typeof failure == "function" ? failure : false + }; // Note: `then(..)` itself can be borrowed to be used against + // a different promise constructor for making the chained promise, + // by substituting a different `this` binding. + + o.promise = new this.constructor(function extractChain(resolve, reject) { + if (typeof resolve != "function" || typeof reject != "function") { + throw TypeError("Not a function"); + } + + o.resolve = resolve; + o.reject = reject; + }); + def.chain.push(o); + + if (def.state !== 0) { + schedule(notify, def); + } + + return o.promise; + }; + + this["catch"] = function $catch$(failure) { + return this.then(void 0, failure); + }; + + try { + executor.call(void 0, function publicResolve(msg) { + resolve.call(def, msg); + }, function publicReject(msg) { + reject.call(def, msg); + }); + } catch (err) { + reject.call(def, err); + } + } + + var PromisePrototype = builtInProp({}, "constructor", Promise, + /*configurable=*/ + false); // Note: Android 4 cannot use `Object.defineProperty(..)` here + + Promise.prototype = PromisePrototype; // built-in "brand" to signal an "uninitialized" promise + + builtInProp(PromisePrototype, "__NPO__", 0, + /*configurable=*/ + false); + builtInProp(Promise, "resolve", function Promise$resolve(msg) { + var Constructor = this; // spec mandated checks + // note: best "isPromise" check that's practical for now + + if (msg && typeof msg == "object" && msg.__NPO__ === 1) { + return msg; + } + + return new Constructor(function executor(resolve, reject) { + if (typeof resolve != "function" || typeof reject != "function") { + throw TypeError("Not a function"); + } + + resolve(msg); + }); + }); + builtInProp(Promise, "reject", function Promise$reject(msg) { + return new this(function executor(resolve, reject) { + if (typeof resolve != "function" || typeof reject != "function") { + throw TypeError("Not a function"); + } + + reject(msg); + }); + }); + builtInProp(Promise, "all", function Promise$all(arr) { + var Constructor = this; // spec mandated checks + + if (ToString.call(arr) != "[object Array]") { + return Constructor.reject(TypeError("Not an array")); + } + + if (arr.length === 0) { + return Constructor.resolve([]); + } + + return new Constructor(function executor(resolve, reject) { + if (typeof resolve != "function" || typeof reject != "function") { + throw TypeError("Not a function"); + } + + var len = arr.length, + msgs = Array(len), + count = 0; + iteratePromises(Constructor, arr, function resolver(idx, msg) { + msgs[idx] = msg; + + if (++count === len) { + resolve(msgs); + } + }, reject); + }); + }); + builtInProp(Promise, "race", function Promise$race(arr) { + var Constructor = this; // spec mandated checks + + if (ToString.call(arr) != "[object Array]") { + return Constructor.reject(TypeError("Not an array")); + } + + return new Constructor(function executor(resolve, reject) { + if (typeof resolve != "function" || typeof reject != "function") { + throw TypeError("Not a function"); + } + + iteratePromises(Constructor, arr, function resolver(idx, msg) { + resolve(msg); + }, reject); + }); + }); + return Promise; + }); + }); + + /** + * @module lib/callbacks + */ + var callbackMap = new WeakMap(); + /** + * Store a callback for a method or event for a player. + * + * @param {Player} player The player object. + * @param {string} name The method or event name. + * @param {(function(this:Player, *): void|{resolve: function, reject: function})} callback + * The callback to call or an object with resolve and reject functions for a promise. + * @return {void} + */ + + function storeCallback(player, name, callback) { + var playerCallbacks = callbackMap.get(player.element) || {}; + + if (!(name in playerCallbacks)) { + playerCallbacks[name] = []; + } + + playerCallbacks[name].push(callback); + callbackMap.set(player.element, playerCallbacks); + } + /** + * Get the callbacks for a player and event or method. + * + * @param {Player} player The player object. + * @param {string} name The method or event name + * @return {function[]} + */ + + function getCallbacks(player, name) { + var playerCallbacks = callbackMap.get(player.element) || {}; + return playerCallbacks[name] || []; + } + /** + * Remove a stored callback for a method or event for a player. + * + * @param {Player} player The player object. + * @param {string} name The method or event name + * @param {function} [callback] The specific callback to remove. + * @return {boolean} Was this the last callback? + */ + + function removeCallback(player, name, callback) { + var playerCallbacks = callbackMap.get(player.element) || {}; + + if (!playerCallbacks[name]) { + return true; + } // If no callback is passed, remove all callbacks for the event + + + if (!callback) { + playerCallbacks[name] = []; + callbackMap.set(player.element, playerCallbacks); + return true; + } + + var index = playerCallbacks[name].indexOf(callback); + + if (index !== -1) { + playerCallbacks[name].splice(index, 1); + } + + callbackMap.set(player.element, playerCallbacks); + return playerCallbacks[name] && playerCallbacks[name].length === 0; + } + /** + * Return the first stored callback for a player and event or method. + * + * @param {Player} player The player object. + * @param {string} name The method or event name. + * @return {function} The callback, or false if there were none + */ + + function shiftCallbacks(player, name) { + var playerCallbacks = getCallbacks(player, name); + + if (playerCallbacks.length < 1) { + return false; + } + + var callback = playerCallbacks.shift(); + removeCallback(player, name, callback); + return callback; + } + /** + * Move callbacks associated with an element to another element. + * + * @param {HTMLElement} oldElement The old element. + * @param {HTMLElement} newElement The new element. + * @return {void} + */ + + function swapCallbacks(oldElement, newElement) { + var playerCallbacks = callbackMap.get(oldElement); + callbackMap.set(newElement, playerCallbacks); + callbackMap.delete(oldElement); + } + + /** + * @module lib/postmessage + */ + /** + * Parse a message received from postMessage. + * + * @param {*} data The data received from postMessage. + * @return {object} + */ + + function parseMessageData(data) { + if (typeof data === 'string') { + try { + data = JSON.parse(data); + } catch (error) { + // If the message cannot be parsed, throw the error as a warning + console.warn(error); + return {}; + } + } + + return data; + } + /** + * Post a message to the specified target. + * + * @param {Player} player The player object to use. + * @param {string} method The API method to call. + * @param {object} params The parameters to send to the player. + * @return {void} + */ + + function postMessage(player, method, params) { + if (!player.element.contentWindow || !player.element.contentWindow.postMessage) { + return; + } + + var message = { + method: method + }; + + if (params !== undefined) { + message.value = params; + } // IE 8 and 9 do not support passing messages, so stringify them + + + var ieVersion = parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/, '$1')); + + if (ieVersion >= 8 && ieVersion < 10) { + message = JSON.stringify(message); + } + + player.element.contentWindow.postMessage(message, player.origin); + } + /** + * Parse the data received from a message event. + * + * @param {Player} player The player that received the message. + * @param {(Object|string)} data The message data. Strings will be parsed into JSON. + * @return {void} + */ + + function processData(player, data) { + data = parseMessageData(data); + var callbacks = []; + var param; + + if (data.event) { + if (data.event === 'error') { + var promises = getCallbacks(player, data.data.method); + promises.forEach(function (promise) { + var error = new Error(data.data.message); + error.name = data.data.name; + promise.reject(error); + removeCallback(player, data.data.method, promise); + }); + } + + callbacks = getCallbacks(player, "event:".concat(data.event)); + param = data.data; + } else if (data.method) { + var callback = shiftCallbacks(player, data.method); + + if (callback) { + callbacks.push(callback); + param = data.value; + } + } + + callbacks.forEach(function (callback) { + try { + if (typeof callback === 'function') { + callback.call(player, param); + return; + } + + callback.resolve(param); + } catch (e) {// empty + } + }); + } + + /** + * @module lib/embed + */ + var oEmbedParameters = ['autopause', 'autoplay', 'background', 'byline', 'color', 'controls', 'dnt', 'height', 'id', 'interactive_params', 'keyboard', 'loop', 'maxheight', 'maxwidth', 'muted', 'playsinline', 'portrait', 'responsive', 'speed', 'texttrack', 'title', 'transparent', 'url', 'width']; + /** + * Get the 'data-vimeo'-prefixed attributes from an element as an object. + * + * @param {HTMLElement} element The element. + * @param {Object} [defaults={}] The default values to use. + * @return {Object} + */ + + function getOEmbedParameters(element) { + var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return oEmbedParameters.reduce(function (params, param) { + var value = element.getAttribute("data-vimeo-".concat(param)); + + if (value || value === '') { + params[param] = value === '' ? 1 : value; + } + + return params; + }, defaults); + } + /** + * Create an embed from oEmbed data inside an element. + * + * @param {object} data The oEmbed data. + * @param {HTMLElement} element The element to put the iframe in. + * @return {HTMLIFrameElement} The iframe embed. + */ + + function createEmbed(_ref, element) { + var html = _ref.html; + + if (!element) { + throw new TypeError('An element must be provided'); + } + + if (element.getAttribute('data-vimeo-initialized') !== null) { + return element.querySelector('iframe'); + } + + var div = document.createElement('div'); + div.innerHTML = html; + element.appendChild(div.firstChild); + element.setAttribute('data-vimeo-initialized', 'true'); + return element.querySelector('iframe'); + } + /** + * Make an oEmbed call for the specified URL. + * + * @param {string} videoUrl The vimeo.com url for the video. + * @param {Object} [params] Parameters to pass to oEmbed. + * @param {HTMLElement} element The element. + * @return {Promise} + */ + + function getOEmbedData(videoUrl) { + var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var element = arguments.length > 2 ? arguments[2] : undefined; + return new Promise(function (resolve, reject) { + if (!isVimeoUrl(videoUrl)) { + throw new TypeError("\u201C".concat(videoUrl, "\u201D is not a vimeo.com url.")); + } + + var url = "https://vimeo.com/api/oembed.json?url=".concat(encodeURIComponent(videoUrl)); + + for (var param in params) { + if (params.hasOwnProperty(param)) { + url += "&".concat(param, "=").concat(encodeURIComponent(params[param])); + } + } + + var xhr = 'XDomainRequest' in window ? new XDomainRequest() : new XMLHttpRequest(); + xhr.open('GET', url, true); + + xhr.onload = function () { + if (xhr.status === 404) { + reject(new Error("\u201C".concat(videoUrl, "\u201D was not found."))); + return; + } + + if (xhr.status === 403) { + reject(new Error("\u201C".concat(videoUrl, "\u201D is not embeddable."))); + return; + } + + try { + var json = JSON.parse(xhr.responseText); // Check api response for 403 on oembed + + if (json.domain_status_code === 403) { + // We still want to create the embed to give users visual feedback + createEmbed(json, element); + reject(new Error("\u201C".concat(videoUrl, "\u201D is not embeddable."))); + return; + } + + resolve(json); + } catch (error) { + reject(error); + } + }; + + xhr.onerror = function () { + var status = xhr.status ? " (".concat(xhr.status, ")") : ''; + reject(new Error("There was an error fetching the embed code from Vimeo".concat(status, "."))); + }; + + xhr.send(); + }); + } + /** + * Initialize all embeds within a specific element + * + * @param {HTMLElement} [parent=document] The parent element. + * @return {void} + */ + + function initializeEmbeds() { + var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; + var elements = [].slice.call(parent.querySelectorAll('[data-vimeo-id], [data-vimeo-url]')); + + var handleError = function handleError(error) { + if ('console' in window && console.error) { + console.error("There was an error creating an embed: ".concat(error)); + } + }; + + elements.forEach(function (element) { + try { + // Skip any that have data-vimeo-defer + if (element.getAttribute('data-vimeo-defer') !== null) { + return; + } + + var params = getOEmbedParameters(element); + var url = getVimeoUrl(params); + getOEmbedData(url, params, element).then(function (data) { + return createEmbed(data, element); + }).catch(handleError); + } catch (error) { + handleError(error); + } + }); + } + /** + * Resize embeds when messaged by the player. + * + * @param {HTMLElement} [parent=document] The parent element. + * @return {void} + */ + + function resizeEmbeds() { + var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; + + // Prevent execution if users include the player.js script multiple times. + if (window.VimeoPlayerResizeEmbeds_) { + return; + } + + window.VimeoPlayerResizeEmbeds_ = true; + + var onMessage = function onMessage(event) { + if (!isVimeoUrl(event.origin)) { + return; + } // 'spacechange' is fired only on embeds with cards + + + if (!event.data || event.data.event !== 'spacechange') { + return; + } + + var iframes = parent.querySelectorAll('iframe'); + + for (var i = 0; i < iframes.length; i++) { + if (iframes[i].contentWindow !== event.source) { + continue; + } // Change padding-bottom of the enclosing div to accommodate + // card carousel without distorting aspect ratio + + + var space = iframes[i].parentElement; + space.style.paddingBottom = "".concat(event.data.data[0].bottom, "px"); + break; + } + }; + + window.addEventListener('message', onMessage); + } + /** + * Add chapters to existing metadata for Google SEO + * + * @param {HTMLElement} [parent=document] The parent element. + * @return {void} + */ + + function initAppendVideoMetadata() { + var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; + + // Prevent execution if users include the player.js script multiple times. + if (window.VimeoSeoMetadataAppended) { + return; + } + + window.VimeoSeoMetadataAppended = true; + + var onMessage = function onMessage(event) { + if (!isVimeoUrl(event.origin)) { + return; + } + + var data = parseMessageData(event.data); + + if (!data || data.event !== 'ready') { + return; + } + + var iframes = parent.querySelectorAll('iframe'); + + for (var i = 0; i < iframes.length; i++) { + var iframe = iframes[i]; // Initiate appendVideoMetadata if iframe is a Vimeo embed + + var isValidMessageSource = iframe.contentWindow === event.source; + + if (isVimeoEmbed(iframe.src) && isValidMessageSource) { + var player = new Player(iframe); + player.callMethod('appendVideoMetadata', window.location.href); + } + } + }; + + window.addEventListener('message', onMessage); + } + /** + * Seek to time indicated by vimeo_t query parameter if present in URL + * + * @param {HTMLElement} [parent=document] The parent element. + * @return {void} + */ + + function checkUrlTimeParam() { + var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document; + + // Prevent execution if users include the player.js script multiple times. + if (window.VimeoCheckedUrlTimeParam) { + return; + } + + window.VimeoCheckedUrlTimeParam = true; + + var handleError = function handleError(error) { + if ('console' in window && console.error) { + console.error("There was an error getting video Id: ".concat(error)); + } + }; + + var onMessage = function onMessage(event) { + if (!isVimeoUrl(event.origin)) { + return; + } + + var data = parseMessageData(event.data); + + if (!data || data.event !== 'ready') { + return; + } + + var iframes = parent.querySelectorAll('iframe'); + + for (var i = 0; i < iframes.length; i++) { + var iframe = iframes[i]; + var isValidMessageSource = iframe.contentWindow === event.source; + + if (isVimeoEmbed(iframe.src) && isValidMessageSource) { + (function () { + var player = new Player(iframe); + player.getVideoId().then(function (videoId) { + var matches = new RegExp("[?&]vimeo_t_".concat(videoId, "=([^&#]*)")).exec(window.location.href); + + if (matches && matches[1]) { + var sec = decodeURI(matches[1]); + player.setCurrentTime(sec); + } + + return; + }).catch(handleError); + })(); + } + } + }; + + window.addEventListener('message', onMessage); + } + + /* MIT License + + Copyright (c) Sindre Sorhus (sindresorhus.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + Terms */ + function initializeScreenfull() { + var fn = function () { + var val; + var fnMap = [['requestFullscreen', 'exitFullscreen', 'fullscreenElement', 'fullscreenEnabled', 'fullscreenchange', 'fullscreenerror'], // New WebKit + ['webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'], // Old WebKit + ['webkitRequestFullScreen', 'webkitCancelFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'], ['mozRequestFullScreen', 'mozCancelFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'], ['msRequestFullscreen', 'msExitFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']]; + var i = 0; + var l = fnMap.length; + var ret = {}; + + for (; i < l; i++) { + val = fnMap[i]; + + if (val && val[1] in document) { + for (i = 0; i < val.length; i++) { + ret[fnMap[0][i]] = val[i]; + } + + return ret; + } + } + + return false; + }(); + + var eventNameMap = { + fullscreenchange: fn.fullscreenchange, + fullscreenerror: fn.fullscreenerror + }; + var screenfull = { + request: function request(element) { + return new Promise(function (resolve, reject) { + var onFullScreenEntered = function onFullScreenEntered() { + screenfull.off('fullscreenchange', onFullScreenEntered); + resolve(); + }; + + screenfull.on('fullscreenchange', onFullScreenEntered); + element = element || document.documentElement; + var returnPromise = element[fn.requestFullscreen](); + + if (returnPromise instanceof Promise) { + returnPromise.then(onFullScreenEntered).catch(reject); + } + }); + }, + exit: function exit() { + return new Promise(function (resolve, reject) { + if (!screenfull.isFullscreen) { + resolve(); + return; + } + + var onFullScreenExit = function onFullScreenExit() { + screenfull.off('fullscreenchange', onFullScreenExit); + resolve(); + }; + + screenfull.on('fullscreenchange', onFullScreenExit); + var returnPromise = document[fn.exitFullscreen](); + + if (returnPromise instanceof Promise) { + returnPromise.then(onFullScreenExit).catch(reject); + } + }); + }, + on: function on(event, callback) { + var eventName = eventNameMap[event]; + + if (eventName) { + document.addEventListener(eventName, callback); + } + }, + off: function off(event, callback) { + var eventName = eventNameMap[event]; + + if (eventName) { + document.removeEventListener(eventName, callback); + } + } + }; + Object.defineProperties(screenfull, { + isFullscreen: { + get: function get() { + return Boolean(document[fn.fullscreenElement]); + } + }, + element: { + enumerable: true, + get: function get() { + return document[fn.fullscreenElement]; + } + }, + isEnabled: { + enumerable: true, + get: function get() { + // Coerce to boolean in case of old WebKit + return Boolean(document[fn.fullscreenEnabled]); + } + } + }); + return screenfull; + } + + var playerMap = new WeakMap(); + var readyMap = new WeakMap(); + var screenfull = {}; + + var Player = /*#__PURE__*/function () { + /** + * Create a Player. + * + * @param {(HTMLIFrameElement|HTMLElement|string|jQuery)} element A reference to the Vimeo + * player iframe, and id, or a jQuery object. + * @param {object} [options] oEmbed parameters to use when creating an embed in the element. + * @return {Player} + */ + function Player(element) { + var _this = this; + + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + _classCallCheck(this, Player); + + /* global jQuery */ + if (window.jQuery && element instanceof jQuery) { + if (element.length > 1 && window.console && console.warn) { + console.warn('A jQuery object with multiple elements was passed, using the first element.'); + } + + element = element[0]; + } // Find an element by ID + + + if (typeof document !== 'undefined' && typeof element === 'string') { + element = document.getElementById(element); + } // Not an element! + + + if (!isDomElement(element)) { + throw new TypeError('You must pass either a valid element or a valid id.'); + } // Already initialized an embed in this div, so grab the iframe + + + if (element.nodeName !== 'IFRAME') { + var iframe = element.querySelector('iframe'); + + if (iframe) { + element = iframe; + } + } // iframe url is not a Vimeo url + + + if (element.nodeName === 'IFRAME' && !isVimeoUrl(element.getAttribute('src') || '')) { + throw new Error('The player element passed isn’t a Vimeo embed.'); + } // If there is already a player object in the map, return that + + + if (playerMap.has(element)) { + return playerMap.get(element); + } + + this._window = element.ownerDocument.defaultView; + this.element = element; + this.origin = '*'; + var readyPromise = new npo_src(function (resolve, reject) { + _this._onMessage = function (event) { + if (!isVimeoUrl(event.origin) || _this.element.contentWindow !== event.source) { + return; + } + + if (_this.origin === '*') { + _this.origin = event.origin; + } + + var data = parseMessageData(event.data); + var isError = data && data.event === 'error'; + var isReadyError = isError && data.data && data.data.method === 'ready'; + + if (isReadyError) { + var error = new Error(data.data.message); + error.name = data.data.name; + reject(error); + return; + } + + var isReadyEvent = data && data.event === 'ready'; + var isPingResponse = data && data.method === 'ping'; + + if (isReadyEvent || isPingResponse) { + _this.element.setAttribute('data-ready', 'true'); + + resolve(); + return; + } + + processData(_this, data); + }; + + _this._window.addEventListener('message', _this._onMessage); + + if (_this.element.nodeName !== 'IFRAME') { + var params = getOEmbedParameters(element, options); + var url = getVimeoUrl(params); + getOEmbedData(url, params, element).then(function (data) { + var iframe = createEmbed(data, element); // Overwrite element with the new iframe, + // but store reference to the original element + + _this.element = iframe; + _this._originalElement = element; + swapCallbacks(element, iframe); + playerMap.set(_this.element, _this); + return data; + }).catch(reject); + } + }); // Store a copy of this Player in the map + + readyMap.set(this, readyPromise); + playerMap.set(this.element, this); // Send a ping to the iframe so the ready promise will be resolved if + // the player is already ready. + + if (this.element.nodeName === 'IFRAME') { + postMessage(this, 'ping'); + } + + if (screenfull.isEnabled) { + var exitFullscreen = function exitFullscreen() { + return screenfull.exit(); + }; + + this.fullscreenchangeHandler = function () { + if (screenfull.isFullscreen) { + storeCallback(_this, 'event:exitFullscreen', exitFullscreen); + } else { + removeCallback(_this, 'event:exitFullscreen', exitFullscreen); + } // eslint-disable-next-line + + + _this.ready().then(function () { + postMessage(_this, 'fullscreenchange', screenfull.isFullscreen); + }); + }; + + screenfull.on('fullscreenchange', this.fullscreenchangeHandler); + } + + return this; + } + /** + * Get a promise for a method. + * + * @param {string} name The API method to call. + * @param {Object} [args={}] Arguments to send via postMessage. + * @return {Promise} + */ + + + _createClass(Player, [{ + key: "callMethod", + value: function callMethod(name) { + var _this2 = this; + + var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return new npo_src(function (resolve, reject) { + // We are storing the resolve/reject handlers to call later, so we + // can’t return here. + // eslint-disable-next-line promise/always-return + return _this2.ready().then(function () { + storeCallback(_this2, name, { + resolve: resolve, + reject: reject + }); + postMessage(_this2, name, args); + }).catch(reject); + }); + } + /** + * Get a promise for the value of a player property. + * + * @param {string} name The property name + * @return {Promise} + */ + + }, { + key: "get", + value: function get(name) { + var _this3 = this; + + return new npo_src(function (resolve, reject) { + name = getMethodName(name, 'get'); // We are storing the resolve/reject handlers to call later, so we + // can’t return here. + // eslint-disable-next-line promise/always-return + + return _this3.ready().then(function () { + storeCallback(_this3, name, { + resolve: resolve, + reject: reject + }); + postMessage(_this3, name); + }).catch(reject); + }); + } + /** + * Get a promise for setting the value of a player property. + * + * @param {string} name The API method to call. + * @param {mixed} value The value to set. + * @return {Promise} + */ + + }, { + key: "set", + value: function set(name, value) { + var _this4 = this; + + return new npo_src(function (resolve, reject) { + name = getMethodName(name, 'set'); + + if (value === undefined || value === null) { + throw new TypeError('There must be a value to set.'); + } // We are storing the resolve/reject handlers to call later, so we + // can’t return here. + // eslint-disable-next-line promise/always-return + + + return _this4.ready().then(function () { + storeCallback(_this4, name, { + resolve: resolve, + reject: reject + }); + postMessage(_this4, name, value); + }).catch(reject); + }); + } + /** + * Add an event listener for the specified event. Will call the + * callback with a single parameter, `data`, that contains the data for + * that event. + * + * @param {string} eventName The name of the event. + * @param {function(*)} callback The function to call when the event fires. + * @return {void} + */ + + }, { + key: "on", + value: function on(eventName, callback) { + if (!eventName) { + throw new TypeError('You must pass an event name.'); + } + + if (!callback) { + throw new TypeError('You must pass a callback function.'); + } + + if (typeof callback !== 'function') { + throw new TypeError('The callback must be a function.'); + } + + var callbacks = getCallbacks(this, "event:".concat(eventName)); + + if (callbacks.length === 0) { + this.callMethod('addEventListener', eventName).catch(function () {// Ignore the error. There will be an error event fired that + // will trigger the error callback if they are listening. + }); + } + + storeCallback(this, "event:".concat(eventName), callback); + } + /** + * Remove an event listener for the specified event. Will remove all + * listeners for that event if a `callback` isn’t passed, or only that + * specific callback if it is passed. + * + * @param {string} eventName The name of the event. + * @param {function} [callback] The specific callback to remove. + * @return {void} + */ + + }, { + key: "off", + value: function off(eventName, callback) { + if (!eventName) { + throw new TypeError('You must pass an event name.'); + } + + if (callback && typeof callback !== 'function') { + throw new TypeError('The callback must be a function.'); + } + + var lastCallback = removeCallback(this, "event:".concat(eventName), callback); // If there are no callbacks left, remove the listener + + if (lastCallback) { + this.callMethod('removeEventListener', eventName).catch(function (e) {// Ignore the error. There will be an error event fired that + // will trigger the error callback if they are listening. + }); + } + } + /** + * A promise to load a new video. + * + * @promise LoadVideoPromise + * @fulfill {number} The video with this id or url successfully loaded. + * @reject {TypeError} The id was not a number. + */ + + /** + * Load a new video into this embed. The promise will be resolved if + * the video is successfully loaded, or it will be rejected if it could + * not be loaded. + * + * @param {number|string|object} options The id of the video, the url of the video, or an object with embed options. + * @return {LoadVideoPromise} + */ + + }, { + key: "loadVideo", + value: function loadVideo(options) { + return this.callMethod('loadVideo', options); + } + /** + * A promise to perform an action when the Player is ready. + * + * @todo document errors + * @promise LoadVideoPromise + * @fulfill {void} + */ + + /** + * Trigger a function when the player iframe has initialized. You do not + * need to wait for `ready` to trigger to begin adding event listeners + * or calling other methods. + * + * @return {ReadyPromise} + */ + + }, { + key: "ready", + value: function ready() { + var readyPromise = readyMap.get(this) || new npo_src(function (resolve, reject) { + reject(new Error('Unknown player. Probably unloaded.')); + }); + return npo_src.resolve(readyPromise); + } + /** + * A promise to add a cue point to the player. + * + * @promise AddCuePointPromise + * @fulfill {string} The id of the cue point to use for removeCuePoint. + * @reject {RangeError} the time was less than 0 or greater than the + * video’s duration. + * @reject {UnsupportedError} Cue points are not supported with the current + * player or browser. + */ + + /** + * Add a cue point to the player. + * + * @param {number} time The time for the cue point. + * @param {object} [data] Arbitrary data to be returned with the cue point. + * @return {AddCuePointPromise} + */ + + }, { + key: "addCuePoint", + value: function addCuePoint(time) { + var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + return this.callMethod('addCuePoint', { + time: time, + data: data + }); + } + /** + * A promise to remove a cue point from the player. + * + * @promise AddCuePointPromise + * @fulfill {string} The id of the cue point that was removed. + * @reject {InvalidCuePoint} The cue point with the specified id was not + * found. + * @reject {UnsupportedError} Cue points are not supported with the current + * player or browser. + */ + + /** + * Remove a cue point from the video. + * + * @param {string} id The id of the cue point to remove. + * @return {RemoveCuePointPromise} + */ + + }, { + key: "removeCuePoint", + value: function removeCuePoint(id) { + return this.callMethod('removeCuePoint', id); + } + /** + * A representation of a text track on a video. + * + * @typedef {Object} VimeoTextTrack + * @property {string} language The ISO language code. + * @property {string} kind The kind of track it is (captions or subtitles). + * @property {string} label The human‐readable label for the track. + */ + + /** + * A promise to enable a text track. + * + * @promise EnableTextTrackPromise + * @fulfill {VimeoTextTrack} The text track that was enabled. + * @reject {InvalidTrackLanguageError} No track was available with the + * specified language. + * @reject {InvalidTrackError} No track was available with the specified + * language and kind. + */ + + /** + * Enable the text track with the specified language, and optionally the + * specified kind (captions or subtitles). + * + * When set via the API, the track language will not change the viewer’s + * stored preference. + * + * @param {string} language The two‐letter language code. + * @param {string} [kind] The kind of track to enable (captions or subtitles). + * @return {EnableTextTrackPromise} + */ + + }, { + key: "enableTextTrack", + value: function enableTextTrack(language, kind) { + if (!language) { + throw new TypeError('You must pass a language.'); + } + + return this.callMethod('enableTextTrack', { + language: language, + kind: kind + }); + } + /** + * A promise to disable the active text track. + * + * @promise DisableTextTrackPromise + * @fulfill {void} The track was disabled. + */ + + /** + * Disable the currently-active text track. + * + * @return {DisableTextTrackPromise} + */ + + }, { + key: "disableTextTrack", + value: function disableTextTrack() { + return this.callMethod('disableTextTrack'); + } + /** + * A promise to pause the video. + * + * @promise PausePromise + * @fulfill {void} The video was paused. + */ + + /** + * Pause the video if it’s playing. + * + * @return {PausePromise} + */ + + }, { + key: "pause", + value: function pause() { + return this.callMethod('pause'); + } + /** + * A promise to play the video. + * + * @promise PlayPromise + * @fulfill {void} The video was played. + */ + + /** + * Play the video if it’s paused. **Note:** on iOS and some other + * mobile devices, you cannot programmatically trigger play. Once the + * viewer has tapped on the play button in the player, however, you + * will be able to use this function. + * + * @return {PlayPromise} + */ + + }, { + key: "play", + value: function play() { + return this.callMethod('play'); + } + /** + * Request that the player enters fullscreen. + * @return {Promise} + */ + + }, { + key: "requestFullscreen", + value: function requestFullscreen() { + if (screenfull.isEnabled) { + return screenfull.request(this.element); + } + + return this.callMethod('requestFullscreen'); + } + /** + * Request that the player exits fullscreen. + * @return {Promise} + */ + + }, { + key: "exitFullscreen", + value: function exitFullscreen() { + if (screenfull.isEnabled) { + return screenfull.exit(); + } + + return this.callMethod('exitFullscreen'); + } + /** + * Returns true if the player is currently fullscreen. + * @return {Promise} + */ + + }, { + key: "getFullscreen", + value: function getFullscreen() { + if (screenfull.isEnabled) { + return npo_src.resolve(screenfull.isFullscreen); + } + + return this.get('fullscreen'); + } + /** + * Request that the player enters picture-in-picture. + * @return {Promise} + */ + + }, { + key: "requestPictureInPicture", + value: function requestPictureInPicture() { + return this.callMethod('requestPictureInPicture'); + } + /** + * Request that the player exits picture-in-picture. + * @return {Promise} + */ + + }, { + key: "exitPictureInPicture", + value: function exitPictureInPicture() { + return this.callMethod('exitPictureInPicture'); + } + /** + * Returns true if the player is currently picture-in-picture. + * @return {Promise} + */ + + }, { + key: "getPictureInPicture", + value: function getPictureInPicture() { + return this.get('pictureInPicture'); + } + /** + * A promise to unload the video. + * + * @promise UnloadPromise + * @fulfill {void} The video was unloaded. + */ + + /** + * Return the player to its initial state. + * + * @return {UnloadPromise} + */ + + }, { + key: "unload", + value: function unload() { + return this.callMethod('unload'); + } + /** + * Cleanup the player and remove it from the DOM + * + * It won't be usable and a new one should be constructed + * in order to do any operations. + * + * @return {Promise} + */ + + }, { + key: "destroy", + value: function destroy() { + var _this5 = this; + + return new npo_src(function (resolve) { + readyMap.delete(_this5); + playerMap.delete(_this5.element); + + if (_this5._originalElement) { + playerMap.delete(_this5._originalElement); + + _this5._originalElement.removeAttribute('data-vimeo-initialized'); + } + + if (_this5.element && _this5.element.nodeName === 'IFRAME' && _this5.element.parentNode) { + // If we've added an additional wrapper div, remove that from the DOM. + // If not, just remove the iframe element. + if (_this5.element.parentNode.parentNode && _this5._originalElement && _this5._originalElement !== _this5.element.parentNode) { + _this5.element.parentNode.parentNode.removeChild(_this5.element.parentNode); + } else { + _this5.element.parentNode.removeChild(_this5.element); + } + } // If the clip is private there is a case where the element stays the + // div element. Destroy should reset the div and remove the iframe child. + + + if (_this5.element && _this5.element.nodeName === 'DIV' && _this5.element.parentNode) { + _this5.element.removeAttribute('data-vimeo-initialized'); + + var iframe = _this5.element.querySelector('iframe'); + + if (iframe && iframe.parentNode) { + // If we've added an additional wrapper div, remove that from the DOM. + // If not, just remove the iframe element. + if (iframe.parentNode.parentNode && _this5._originalElement && _this5._originalElement !== iframe.parentNode) { + iframe.parentNode.parentNode.removeChild(iframe.parentNode); + } else { + iframe.parentNode.removeChild(iframe); + } + } + } + + _this5._window.removeEventListener('message', _this5._onMessage); + + if (screenfull.isEnabled) { + screenfull.off('fullscreenchange', _this5.fullscreenchangeHandler); + } + + resolve(); + }); + } + /** + * A promise to get the autopause behavior of the video. + * + * @promise GetAutopausePromise + * @fulfill {boolean} Whether autopause is turned on or off. + * @reject {UnsupportedError} Autopause is not supported with the current + * player or browser. + */ + + /** + * Get the autopause behavior for this player. + * + * @return {GetAutopausePromise} + */ + + }, { + key: "getAutopause", + value: function getAutopause() { + return this.get('autopause'); + } + /** + * A promise to set the autopause behavior of the video. + * + * @promise SetAutopausePromise + * @fulfill {boolean} Whether autopause is turned on or off. + * @reject {UnsupportedError} Autopause is not supported with the current + * player or browser. + */ + + /** + * Enable or disable the autopause behavior of this player. + * + * By default, when another video is played in the same browser, this + * player will automatically pause. Unless you have a specific reason + * for doing so, we recommend that you leave autopause set to the + * default (`true`). + * + * @param {boolean} autopause + * @return {SetAutopausePromise} + */ + + }, { + key: "setAutopause", + value: function setAutopause(autopause) { + return this.set('autopause', autopause); + } + /** + * A promise to get the buffered property of the video. + * + * @promise GetBufferedPromise + * @fulfill {Array} Buffered Timeranges converted to an Array. + */ + + /** + * Get the buffered property of the video. + * + * @return {GetBufferedPromise} + */ + + }, { + key: "getBuffered", + value: function getBuffered() { + return this.get('buffered'); + } + /** + * @typedef {Object} CameraProperties + * @prop {number} props.yaw - Number between 0 and 360. + * @prop {number} props.pitch - Number between -90 and 90. + * @prop {number} props.roll - Number between -180 and 180. + * @prop {number} props.fov - The field of view in degrees. + */ + + /** + * A promise to get the camera properties of the player. + * + * @promise GetCameraPromise + * @fulfill {CameraProperties} The camera properties. + */ + + /** + * For 360° videos get the camera properties for this player. + * + * @return {GetCameraPromise} + */ + + }, { + key: "getCameraProps", + value: function getCameraProps() { + return this.get('cameraProps'); + } + /** + * A promise to set the camera properties of the player. + * + * @promise SetCameraPromise + * @fulfill {Object} The camera was successfully set. + * @reject {RangeError} The range was out of bounds. + */ + + /** + * For 360° videos set the camera properties for this player. + * + * @param {CameraProperties} camera The camera properties + * @return {SetCameraPromise} + */ + + }, { + key: "setCameraProps", + value: function setCameraProps(camera) { + return this.set('cameraProps', camera); + } + /** + * A representation of a chapter. + * + * @typedef {Object} VimeoChapter + * @property {number} startTime The start time of the chapter. + * @property {object} title The title of the chapter. + * @property {number} index The place in the order of Chapters. Starts at 1. + */ + + /** + * A promise to get chapters for the video. + * + * @promise GetChaptersPromise + * @fulfill {VimeoChapter[]} The chapters for the video. + */ + + /** + * Get an array of all the chapters for the video. + * + * @return {GetChaptersPromise} + */ + + }, { + key: "getChapters", + value: function getChapters() { + return this.get('chapters'); + } + /** + * A promise to get the currently active chapter. + * + * @promise GetCurrentChaptersPromise + * @fulfill {VimeoChapter|undefined} The current chapter for the video. + */ + + /** + * Get the currently active chapter for the video. + * + * @return {GetCurrentChaptersPromise} + */ + + }, { + key: "getCurrentChapter", + value: function getCurrentChapter() { + return this.get('currentChapter'); + } + /** + * A promise to get the color of the player. + * + * @promise GetColorPromise + * @fulfill {string} The hex color of the player. + */ + + /** + * Get the color for this player. + * + * @return {GetColorPromise} + */ + + }, { + key: "getColor", + value: function getColor() { + return this.get('color'); + } + /** + * A promise to set the color of the player. + * + * @promise SetColorPromise + * @fulfill {string} The color was successfully set. + * @reject {TypeError} The string was not a valid hex or rgb color. + * @reject {ContrastError} The color was set, but the contrast is + * outside of the acceptable range. + * @reject {EmbedSettingsError} The owner of the player has chosen to + * use a specific color. + */ + + /** + * Set the color of this player to a hex or rgb string. Setting the + * color may fail if the owner of the video has set their embed + * preferences to force a specific color. + * + * @param {string} color The hex or rgb color string to set. + * @return {SetColorPromise} + */ + + }, { + key: "setColor", + value: function setColor(color) { + return this.set('color', color); + } + /** + * A representation of a cue point. + * + * @typedef {Object} VimeoCuePoint + * @property {number} time The time of the cue point. + * @property {object} data The data passed when adding the cue point. + * @property {string} id The unique id for use with removeCuePoint. + */ + + /** + * A promise to get the cue points of a video. + * + * @promise GetCuePointsPromise + * @fulfill {VimeoCuePoint[]} The cue points added to the video. + * @reject {UnsupportedError} Cue points are not supported with the current + * player or browser. + */ + + /** + * Get an array of the cue points added to the video. + * + * @return {GetCuePointsPromise} + */ + + }, { + key: "getCuePoints", + value: function getCuePoints() { + return this.get('cuePoints'); + } + /** + * A promise to get the current time of the video. + * + * @promise GetCurrentTimePromise + * @fulfill {number} The current time in seconds. + */ + + /** + * Get the current playback position in seconds. + * + * @return {GetCurrentTimePromise} + */ + + }, { + key: "getCurrentTime", + value: function getCurrentTime() { + return this.get('currentTime'); + } + /** + * A promise to set the current time of the video. + * + * @promise SetCurrentTimePromise + * @fulfill {number} The actual current time that was set. + * @reject {RangeError} the time was less than 0 or greater than the + * video’s duration. + */ + + /** + * Set the current playback position in seconds. If the player was + * paused, it will remain paused. Likewise, if the player was playing, + * it will resume playing once the video has buffered. + * + * You can provide an accurate time and the player will attempt to seek + * to as close to that time as possible. The exact time will be the + * fulfilled value of the promise. + * + * @param {number} currentTime + * @return {SetCurrentTimePromise} + */ + + }, { + key: "setCurrentTime", + value: function setCurrentTime(currentTime) { + return this.set('currentTime', currentTime); + } + /** + * A promise to get the duration of the video. + * + * @promise GetDurationPromise + * @fulfill {number} The duration in seconds. + */ + + /** + * Get the duration of the video in seconds. It will be rounded to the + * nearest second before playback begins, and to the nearest thousandth + * of a second after playback begins. + * + * @return {GetDurationPromise} + */ + + }, { + key: "getDuration", + value: function getDuration() { + return this.get('duration'); + } + /** + * A promise to get the ended state of the video. + * + * @promise GetEndedPromise + * @fulfill {boolean} Whether or not the video has ended. + */ + + /** + * Get the ended state of the video. The video has ended if + * `currentTime === duration`. + * + * @return {GetEndedPromise} + */ + + }, { + key: "getEnded", + value: function getEnded() { + return this.get('ended'); + } + /** + * A promise to get the loop state of the player. + * + * @promise GetLoopPromise + * @fulfill {boolean} Whether or not the player is set to loop. + */ + + /** + * Get the loop state of the player. + * + * @return {GetLoopPromise} + */ + + }, { + key: "getLoop", + value: function getLoop() { + return this.get('loop'); + } + /** + * A promise to set the loop state of the player. + * + * @promise SetLoopPromise + * @fulfill {boolean} The loop state that was set. + */ + + /** + * Set the loop state of the player. When set to `true`, the player + * will start over immediately once playback ends. + * + * @param {boolean} loop + * @return {SetLoopPromise} + */ + + }, { + key: "setLoop", + value: function setLoop(loop) { + return this.set('loop', loop); + } + /** + * A promise to set the muted state of the player. + * + * @promise SetMutedPromise + * @fulfill {boolean} The muted state that was set. + */ + + /** + * Set the muted state of the player. When set to `true`, the player + * volume will be muted. + * + * @param {boolean} muted + * @return {SetMutedPromise} + */ + + }, { + key: "setMuted", + value: function setMuted(muted) { + return this.set('muted', muted); + } + /** + * A promise to get the muted state of the player. + * + * @promise GetMutedPromise + * @fulfill {boolean} Whether or not the player is muted. + */ + + /** + * Get the muted state of the player. + * + * @return {GetMutedPromise} + */ + + }, { + key: "getMuted", + value: function getMuted() { + return this.get('muted'); + } + /** + * A promise to get the paused state of the player. + * + * @promise GetLoopPromise + * @fulfill {boolean} Whether or not the video is paused. + */ + + /** + * Get the paused state of the player. + * + * @return {GetLoopPromise} + */ + + }, { + key: "getPaused", + value: function getPaused() { + return this.get('paused'); + } + /** + * A promise to get the playback rate of the player. + * + * @promise GetPlaybackRatePromise + * @fulfill {number} The playback rate of the player on a scale from 0.5 to 2. + */ + + /** + * Get the playback rate of the player on a scale from `0.5` to `2`. + * + * @return {GetPlaybackRatePromise} + */ + + }, { + key: "getPlaybackRate", + value: function getPlaybackRate() { + return this.get('playbackRate'); + } + /** + * A promise to set the playbackrate of the player. + * + * @promise SetPlaybackRatePromise + * @fulfill {number} The playback rate was set. + * @reject {RangeError} The playback rate was less than 0.5 or greater than 2. + */ + + /** + * Set the playback rate of the player on a scale from `0.5` to `2`. When set + * via the API, the playback rate will not be synchronized to other + * players or stored as the viewer's preference. + * + * @param {number} playbackRate + * @return {SetPlaybackRatePromise} + */ + + }, { + key: "setPlaybackRate", + value: function setPlaybackRate(playbackRate) { + return this.set('playbackRate', playbackRate); + } + /** + * A promise to get the played property of the video. + * + * @promise GetPlayedPromise + * @fulfill {Array} Played Timeranges converted to an Array. + */ + + /** + * Get the played property of the video. + * + * @return {GetPlayedPromise} + */ + + }, { + key: "getPlayed", + value: function getPlayed() { + return this.get('played'); + } + /** + * A promise to get the qualities available of the current video. + * + * @promise GetQualitiesPromise + * @fulfill {Array} The qualities of the video. + */ + + /** + * Get the qualities of the current video. + * + * @return {GetQualitiesPromise} + */ + + }, { + key: "getQualities", + value: function getQualities() { + return this.get('qualities'); + } + /** + * A promise to get the current set quality of the video. + * + * @promise GetQualityPromise + * @fulfill {string} The current set quality. + */ + + /** + * Get the current set quality of the video. + * + * @return {GetQualityPromise} + */ + + }, { + key: "getQuality", + value: function getQuality() { + return this.get('quality'); + } + /** + * A promise to set the video quality. + * + * @promise SetQualityPromise + * @fulfill {number} The quality was set. + * @reject {RangeError} The quality is not available. + */ + + /** + * Set a video quality. + * + * @param {string} quality + * @return {SetQualityPromise} + */ + + }, { + key: "setQuality", + value: function setQuality(quality) { + return this.set('quality', quality); + } + /** + * A promise to get the seekable property of the video. + * + * @promise GetSeekablePromise + * @fulfill {Array} Seekable Timeranges converted to an Array. + */ + + /** + * Get the seekable property of the video. + * + * @return {GetSeekablePromise} + */ + + }, { + key: "getSeekable", + value: function getSeekable() { + return this.get('seekable'); + } + /** + * A promise to get the seeking property of the player. + * + * @promise GetSeekingPromise + * @fulfill {boolean} Whether or not the player is currently seeking. + */ + + /** + * Get if the player is currently seeking. + * + * @return {GetSeekingPromise} + */ + + }, { + key: "getSeeking", + value: function getSeeking() { + return this.get('seeking'); + } + /** + * A promise to get the text tracks of a video. + * + * @promise GetTextTracksPromise + * @fulfill {VimeoTextTrack[]} The text tracks associated with the video. + */ + + /** + * Get an array of the text tracks that exist for the video. + * + * @return {GetTextTracksPromise} + */ + + }, { + key: "getTextTracks", + value: function getTextTracks() { + return this.get('textTracks'); + } + /** + * A promise to get the embed code for the video. + * + * @promise GetVideoEmbedCodePromise + * @fulfill {string} The `