From 7450785c11a31ad1d033437e91589dcd0ee0a6ab Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Tue, 17 Oct 2023 17:28:07 -0400 Subject: [PATCH] Walmart new script for muiltiple ids (activities, learning paths, courses). Talkspace script to update their workato recipe. --- .../_widget_achievements.html.liquid | 120 ++++++++++++++++++ .../dashboard.html.liquid | 68 ++++++++++ CustomerNotes/Aiim/Aiim.md | 8 +- Scripts/API_Tests/get_cat_lp_course_ids.py | 105 +++++++++++++++ Scripts/API_Tests/get_category_ids.py | 5 +- .../API_Tests/get_courses_w_descriptions.py | 43 ++++--- 6 files changed, 326 insertions(+), 23 deletions(-) create mode 100644 Custom_Templates/customer_templates/BLVD Learning Library/_widget_achievements.html.liquid create mode 100644 Custom_Templates/customer_templates/BLVD Learning Library/dashboard.html.liquid create mode 100644 Scripts/API_Tests/get_cat_lp_course_ids.py diff --git a/Custom_Templates/customer_templates/BLVD Learning Library/_widget_achievements.html.liquid b/Custom_Templates/customer_templates/BLVD Learning Library/_widget_achievements.html.liquid new file mode 100644 index 00000000..daef2374 --- /dev/null +++ b/Custom_Templates/customer_templates/BLVD Learning Library/_widget_achievements.html.liquid @@ -0,0 +1,120 @@ +{% comment %} + For this widget to work you must import Slick CSS and JS +{% endcomment %} + +
+
+
+ {% if courses.enrolled.any? %} +
+ + View All + {% else %} + {% capture message %} + {% t shared.zero_state.courses.index, + key: current_school.course_vocabulary + %} + {% endcapture %} + {% include "courses_zero_state", message: message %} + {% endif %} +
+
+
+
+ + + + diff --git a/Custom_Templates/customer_templates/BLVD Learning Library/dashboard.html.liquid b/Custom_Templates/customer_templates/BLVD Learning Library/dashboard.html.liquid new file mode 100644 index 00000000..d7be335e --- /dev/null +++ b/Custom_Templates/customer_templates/BLVD Learning Library/dashboard.html.liquid @@ -0,0 +1,68 @@ +{% include "header" %} +{% include "course_version_outdated_alert", courses: courses.enrolled %} +{% include "sub_navigation" %} +
+
+
+ {% if features.learning_paths? %} +
+ {% t shared.learning_paths %} +
+ {% include "learning_paths_index", items: learning_paths.enrolled %} + {% endif %} +
+ {% t shared.course_vocabulary.plural, key: current_school.course_vocabulary %} +
+ {% include "courses_index", class: "col-xs-12 col-sm-6 np-stretch-content" %} +
+ +
+
+
My Points
+
+
+

{{ current_person.properties.learner_points }}

+

Points

+
+
+
+ + {% assign courseCompletedCouter = 0 %} + {% for course in courses.enrolled %} + {% if course.progress == 100 %} + {% assign courseCompletedCouter = courseCompletedCouter | plus: 1 %} + {% endif %} + {% endfor %} +
+
Recent Achievements
+ {% include "widget_achievements" %} +
+ + {% if features.training_events? %} +
+
+ {% t .upcoming_events %} +
+ {% include "training_events_dashboard" %} +
+ {% endif %} +
+
+
+{% include "footer" %} + + \ No newline at end of file diff --git a/CustomerNotes/Aiim/Aiim.md b/CustomerNotes/Aiim/Aiim.md index 8d0db9aa..c2e7a9bc 100644 --- a/CustomerNotes/Aiim/Aiim.md +++ b/CustomerNotes/Aiim/Aiim.md @@ -66,7 +66,7 @@ _Analytics:_ Certs sends out credential name - it should share course/lp name instead of cert name LinkedIn metrics for who has added the cert to their profile. -DONE: Send Georgina the pricing for OpenSesame. +DONE: Send Georgina the pricing for OpenSesame[.](2023-10-17_..md) ## 08/25/2023 @@ -90,3 +90,9 @@ Notes: * The activity name will be: 2023 Beta CIP Exam DONE: Request to hide the EOQ screen from this quiz. Make sure AIIM removes the milestone. + +## 10/17/2023 + +### Check in with Georgina + +* No current issues, everything working well! diff --git a/Scripts/API_Tests/get_cat_lp_course_ids.py b/Scripts/API_Tests/get_cat_lp_course_ids.py new file mode 100644 index 00000000..5b9c730e --- /dev/null +++ b/Scripts/API_Tests/get_cat_lp_course_ids.py @@ -0,0 +1,105 @@ +import csv +import os +import Apikeys +import requests + +APIKEY = Apikeys.walmartprod +CMD = "touch ~/Downloads/Spark_Categories.csv" +HEADERS = { + "accept": "application/json", + "X-Api-Key": APIKEY, +} + + +def get_categories(): + """ + Function to get the category Name and IDs and adding them to a list of tuples + """ + os.system("touch ~/Downloads/Spark_Categories.csv") + url = "https://api2.northpass.com/v2/categories?limit=100" + response = requests.get(url, headers=HEADERS) + response = response.json() + + for item in response["data"]: + cat_tupe = (item["id"], item["attributes"]["name"]) + with open( + "/Users/normrasmussen/Downloads/Spark_Categories.csv", "a", newline="" + ) as csvfile: + writer = csv.writer( + csvfile, delimiter=",", quotechar="|", quoting=csv.QUOTE_MINIMAL + ) + writer.writerow(cat_tupe) + + +def get_courses(): + """ + Function to get the course name, ids, and activity names and ids to a list. + """ + + count = 0 + + while True: + count += 1 + url = f"https://api2.northpass.com/v2/courses?page={count}" + + response = requests.get(url, headers=HEADERS) + response = response.json() + nextlink = response["links"] + + for item in response["data"]: + status = item["attributes"]["status"] + if status == "live": + courses = (item["id"], item["attributes"]["name"]) + get_activities(courses) + + if "next" not in nextlink: + break + + +def get_activities(courses): + """ + Function that exists within a for loop! + This function is to get the category Name and IDs and adding them to a list of tuples + and writes them to a csv + """ + os.system("touch ~/Downloads/Spark_Courses.csv") + course_list = [] + course_uuid, _ = courses + url = f"https://api2.northpass.com/v2/courses/{course_uuid}/activities" + response = requests.get(url, headers=HEADERS) + response = response.json() + + for data in response["data"]: + activity_tupe = (data["id"], data["attributes"]["title"]) + course_list.append(activity_tupe) + courses = (courses, course_list) + with open("/Users/normrasmussen/Downloads/Spark_Courses.csv", "a") as csvfile: + writer = csv.writer( + csvfile, delimiter=",", quotechar="|", quoting=csv.QUOTE_MINIMAL + ) + writer.writerow(courses) + + +def get_learning_paths(): + """ + Function to get the Learning Path Name and IDs and adding them to a list of tuples + """ + os.system("touch ~/Downloads/Spark_LPs.csv") + url = "https://api2.northpass.com/v2/learning_paths" + response = requests.get(url, headers=HEADERS) + response = response.json() + + for data in response["data"]: + lps = (data["id"], data["attributes"]["name"]) + print(lps) + with open("/Users/normrasmussen/Downloads/Spark_LPs.csv", "a") as csvfile: + writer = csv.writer( + csvfile, delimiter=",", quotechar="|", quoting=csv.QUOTE_MINIMAL + ) + writer.writerow(lps) + + +if __name__ == "__main__": + get_categories() + get_courses() + get_learning_paths() diff --git a/Scripts/API_Tests/get_category_ids.py b/Scripts/API_Tests/get_category_ids.py index 15fe18ba..b57ce779 100644 --- a/Scripts/API_Tests/get_category_ids.py +++ b/Scripts/API_Tests/get_category_ids.py @@ -1,8 +1,7 @@ -import requests -import Apikeys import csv -import time import os +import Apikeys +import requests apikey = Apikeys.walmartprod cmd = "touch ~/Downloads/Spark_Categories.csv" diff --git a/Scripts/API_Tests/get_courses_w_descriptions.py b/Scripts/API_Tests/get_courses_w_descriptions.py index 828a9f21..721dcc68 100644 --- a/Scripts/API_Tests/get_courses_w_descriptions.py +++ b/Scripts/API_Tests/get_courses_w_descriptions.py @@ -6,8 +6,11 @@ import requests import pandas as pd import Apikeys -APIKEY = Apikeys.walmartprod - +APIKEY = Apikeys.talkspace_1099 +COURSES = ["Getting Started at Talkspace (ICP - 2023)", + "Getting Started at Talkspace (Prescriber)", + "Getting Started at Talkspace (Associate ICP)", + "Talkspace Managed Care Plans"] def get_course(): """ @@ -20,8 +23,7 @@ def get_course(): while True: count += 1 - url = f"https://api2.northpass.com/v2/courses?page={count}" - print(url) + url = f"https://api.northpass.com/v2/courses?page={count}" headers = {"accept": "application/json", "X-Api-Key": APIKEY} response = requests.get(url, headers=headers) data = response.json() @@ -32,22 +34,25 @@ def get_course(): if status == "live": uuid = response["id"] name = response["attributes"]["name"] - full_description = response["attributes"]["full_description"] - course_dict = { - "id": uuid, - "name": name, - "status": status, - "full_description": full_description, - } + if name in COURSES: + # full_description = response["attributes"]["full_description"] + course_dict = { + "id": uuid, + "name": name, + # "status": status, + # "full_description": full_description, + } - try: - courses.append(course_dict) - except TypeError as e: - print(f"Error: {e}") - finally: - write_to_csv(courses) - else: - pass + try: + courses.append(course_dict) + except TypeError as e: + print(f"Error: {e}") + finally: + # write_to_csv(courses) + pass + else: + pass + print(courses) if "next" not in nextlink: break