Welcome to the UKRI Digital Research Skills Catalyst
A national hub for researcher and innovator development.
Boost your digital research skills, accelerate your research impact—discover 80+ learning resources, events, and expert-led training in one central hub with the UKRI Digital Research Skills Catalyst. Find out more here.
Code
# This cell loads the CSV data directly from the Google sheet via its published CSV-specific URL.# We need to load in Python, as OJS doesn't have a caching system.# Once loaded, we "publish" the variable globally to OJS.import pandas as pdcourse_data_cached = pd.read_csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vRSrvsfFfVwokza_WP9JIzd4Wfg6OKPBJcwelLTqYn1SgigZXnfcU6_apN5gWTMF79n4CRQFNOJ5w6M/pub?gid=1012757406&single=true&output=csv")ojs_define(course_data_cached = course_data_cached)
// Trim the search querysearch_query = (search_terms ??"").toLowerCase().trim()
Code
viewof search_terms = Inputs.text({placeholder:"Search Training Resources..."})viewof search_all = Inputs.button("Show All")
Code
// This updates the search to be "*" on pressing the "show all" button{ search_all;if (search_all >0) {const search_element = viewof search_terms; search_element.value="*";const reset_button = viewof reset_filters; reset_button.value+=1; reset_button.dispatchEvent(newEvent("input", {bubbles:true})); search_element.dispatchEvent(newEvent("input", {bubbles:true})); }}
Code
// Performs filtering of the complete (`course_data`) data into the filtered (`course_filtered`) set.course_filtered = {// 1: If the current search term is empty, and no filters are set, return featured coursesif(!search_query &&!selected_audience && (selected_resource_type ?? []).length===0&& (selected_time ?? []).length===0&& (selected_provider ?? []).length===0 ) {return course_data.filter(row => row.featured==="yes") }// 2: If the current search term is "*", then return everything:if (search_query ==="*") {return course_data }// 3: There is another search term, so filter on it:return course_data.filter(row => (!selected_audience ||!row.audience|| row.audience.includes(selected_audience)) && ((selected_resource_type ?? []).length===0|| (selected_resource_type ?? []).includes(row.learningResourceType)) && ((selected_time ?? []).length===0|| (selected_time ?? []).includes(row.approxTimeRequired)) && ((selected_provider ?? []).length===0|| (selected_provider ?? []).includes(row.provider)) && (!search_query || row.headline.toLowerCase().includes(search_query) || (row.description&& row.description.includes(search_query)) || (row.projectFunding&& row.projectFunding.includes(search_query)) || (row.identifier&& row.identifier.includes(search_query)) ) )}
Code
// This cell implements a show/hide button for extra filters.// This works via a JavaScript function that finds and toggles the div display style.{const toggleLink =document.createElement("a"); toggleLink.id="toggle-filters"; toggleLink.href="#"; toggleLink.textContent="show filters"; toggleLink.addEventListener("click", (event) => {event.preventDefault();const filter_div =document.getElementById("search-filters");if (filter_div.style.display==="none") { toggleLink.textContent="hide filters"; filter_div.style.display="block" } else { toggleLink.textContent="show filters"; filter_div.style.display="none" } });return toggleLink;}