From 44d84d7143932f03958a0942236c71ef5927920c Mon Sep 17 00:00:00 2001 From: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> Date: Tue, 5 Sep 2023 23:10:24 +0300 Subject: [PATCH] feat(Mahara tech): adding quiz detection (#7611) * feat(Mahara-Tech): add presence * feat(Mahara-Tech): add presence * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update util.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update metadata.json Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update websites/M/Mahara-Tech/metadata.json Co-authored-by: Daniel Lau <32113157+theusaf@users.noreply.github.com> Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update metadata.json Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update websites/M/Mahara-Tech/metadata.json Co-authored-by: Daniel Lau <32113157+theusaf@users.noreply.github.com> Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update metadata.json Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update metadata.json Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update metadata.json Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update presence.ts Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> * Update metadata.json Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> --------- Signed-off-by: Youssef Ayman <62572632+ELJoOker2004@users.noreply.github.com> Co-authored-by: Daniel Lau <32113157+theusaf@users.noreply.github.com> --- websites/M/Mahara-Tech/metadata.json | 4 ++-- websites/M/Mahara-Tech/presence.ts | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/websites/M/Mahara-Tech/metadata.json b/websites/M/Mahara-Tech/metadata.json index bcd92d2ce19b..ab98e87e8545 100644 --- a/websites/M/Mahara-Tech/metadata.json +++ b/websites/M/Mahara-Tech/metadata.json @@ -9,7 +9,7 @@ "en": "Maharatech is an online learning platform, offering high-quality courses authored by Information Technology Institute ITI" }, "url": "maharatech.gov.eg", - "version": "1.0.1", + "version": "1.1.0", "logo": "https://cdn.rcd.gg/PreMiD/websites/M/Mahara-Tech/assets/logo.png", "thumbnail": "https://cdn.rcd.gg/PreMiD/websites/M/Mahara-Tech/assets/thumbnail.png", "color": "#8d1f28", @@ -37,4 +37,4 @@ "value": true } ] -} \ No newline at end of file +} diff --git a/websites/M/Mahara-Tech/presence.ts b/websites/M/Mahara-Tech/presence.ts index 3e761afe4839..985a1f9ee4c2 100644 --- a/websites/M/Mahara-Tech/presence.ts +++ b/websites/M/Mahara-Tech/presence.ts @@ -95,6 +95,31 @@ const presence = new Presence({ ], }, + { + path: /^\/mod\/quiz\/*/, + + smallImageKey: () => Assets.Writing, + smallImageText: () => "taking a quiz...", + + details: () => document.title, + state: () => { + return document.querySelector("h4.title.float-left").textContent; + }, + buttons: () => [ + { + label: "View Course", + url: (() => { + const href = document + .querySelector( + ".btn.btn-primary.ccn-btn-backtocourse.float-left" + ) + .getAttribute("href"); + return href; + })(), + }, + ], + }, + { path: /^\/course\/(.*)/,