Walmart new script for muiltiple ids (activities, learning paths, courses). Talkspace script to update their workato recipe.
This commit is contained in:
@ -0,0 +1,120 @@
|
||||
{% comment %}
|
||||
For this widget to work you must import Slick CSS and JS
|
||||
{% endcomment %}
|
||||
|
||||
<div class="np-dashboard-resources">
|
||||
<div class="np-card">
|
||||
<div class="np-card-container np-dashboard-border">
|
||||
{% if courses.enrolled.any? %}
|
||||
<div class="np-card-content-achievements">
|
||||
<div class="achievements-carousel">
|
||||
{% for course in courses.enrolled %}
|
||||
{% if course.progress == 100 %}
|
||||
<div>
|
||||
<div class="np-card-content-title col-12">
|
||||
{{ course.name }}
|
||||
</div>
|
||||
<div class="col-12 ">
|
||||
<img class="np-achievement-icon" src="{{ course.properties.course_badge }}" />
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<a href="#" class="np-view-all-achievements">View All</a>
|
||||
{% else %}
|
||||
{% capture message %}
|
||||
{% t shared.zero_state.courses.index,
|
||||
key: current_school.course_vocabulary
|
||||
%}
|
||||
{% endcapture %}
|
||||
{% include "courses_zero_state", message: message %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
$('.achivements-carousel').slick({
|
||||
slidesToShow: 1,
|
||||
slidesToScroll: 1,
|
||||
dots: false,
|
||||
infinite: true,
|
||||
autoplay: false,
|
||||
autoplaySpeed: 5000,
|
||||
cssEase: 'linear',
|
||||
prevArrow: '<i class="fal fa-chevron-left"></i>',
|
||||
nextArrow: '<i class="fal fa-chevron-right"></i>',
|
||||
responsive: [{
|
||||
breakpoint: 991,
|
||||
settings: {
|
||||
|
||||
dots: false
|
||||
}
|
||||
}]
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.achievements-carousel{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.np-card-content-achievements .np-card-content-title {
|
||||
font-size: 0.937rem;
|
||||
text-align:center;
|
||||
font-weight:500;
|
||||
}
|
||||
|
||||
.np-achievement-icon {
|
||||
color: #bec2c6;
|
||||
margin:14px auto 26px;
|
||||
width:130px;
|
||||
}
|
||||
|
||||
.np-card-content-achievements .slick-slider {
|
||||
width:100%;
|
||||
max-width: 375px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.np-view-all-achievements {
|
||||
color:#2BB24C;
|
||||
font-size:0.75rem;
|
||||
text-transform:uppercase;
|
||||
text-align:center;
|
||||
text-decoration:none;
|
||||
margin-bottom:1.5rem;
|
||||
}
|
||||
|
||||
.np-card-content-achievements {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 2rem 2rem .5rem;
|
||||
}
|
||||
|
||||
.slick-arrow {
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
opacity: 0.5;
|
||||
font-size: 1.5rem;
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
top: 50%;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.slick-arrow.fa-chevron-left { left:0 }
|
||||
.slick-arrow.fa-chevron-right { right:0; }
|
||||
|
||||
@media (min-width:1024px) {
|
||||
.np-card-content-achievements .slick-slider {
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@ -0,0 +1,68 @@
|
||||
{% include "header" %}
|
||||
{% include "course_version_outdated_alert", courses: courses.enrolled %}
|
||||
{% include "sub_navigation" %}
|
||||
<main class="np-main np-dashboard np-subpage-container np-max-width">
|
||||
<div class="row np-flex-center">
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
{% if features.learning_paths? %}
|
||||
<div class="np-dashboard-resources-title">
|
||||
{% t shared.learning_paths %}
|
||||
</div>
|
||||
{% include "learning_paths_index", items: learning_paths.enrolled %}
|
||||
{% endif %}
|
||||
<div class="np-dashboard-resources-title">
|
||||
{% t shared.course_vocabulary.plural, key: current_school.course_vocabulary %}
|
||||
</div>
|
||||
{% include "courses_index", class: "col-xs-12 col-sm-6 np-stretch-content" %}
|
||||
</div>
|
||||
|
||||
<div class="np-grid-spacing col-xs-12 col-sm-4">
|
||||
<div>
|
||||
<div class="np-dashboard-resources-title">My Points</div>
|
||||
<div class="np-card">
|
||||
<div class="np-card-container np-dashboard-border" style="text-align: center;">
|
||||
<h1 class="user-point-num" style="margin-bottom: 1rem;">{{ current_person.properties.learner_points }}</h1>
|
||||
<h3 class="user-point-label" style="margin-top: 1rem;">Points</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% assign courseCompletedCouter = 0 %}
|
||||
{% for course in courses.enrolled %}
|
||||
{% if course.progress == 100 %}
|
||||
{% assign courseCompletedCouter = courseCompletedCouter | plus: 1 %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<div class="achievements-box" style="{% if courseCompletedCouter > 0%}display: block !important;{% endif %}">
|
||||
<div class="np-dashboard-resources-title">Recent Achievements</div>
|
||||
{% include "widget_achievements" %}
|
||||
</div>
|
||||
|
||||
{% if features.training_events? %}
|
||||
<div>
|
||||
<div class="np-dashboard-resources-title">
|
||||
{% t .upcoming_events %}
|
||||
</div>
|
||||
{% include "training_events_dashboard" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
{% include "footer" %}
|
||||
|
||||
<style>
|
||||
.achievements-box{
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 767px){
|
||||
.user-point-num{
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.user-point-label{
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -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!
|
||||
|
||||
105
Scripts/API_Tests/get_cat_lp_course_ids.py
Normal file
105
Scripts/API_Tests/get_cat_lp_course_ids.py
Normal file
@ -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()
|
||||
@ -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"
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user