### Welcome Widget Context Override Example - JavaScript Source: https://community.d2l.com/brightspace/kb/articles/23035-homepage-widget-expansion-pack-configuration-variables Provides an example of overriding the context for the Welcome Widget using a JavaScript object. It specifies roles, like 'editor', that have permissions to edit the widget's content and setup. ```javascript var roleDefinitions = { "editor": ["Role1", "Role2" ] }; ``` -------------------------------- ### Authenticated GET Request Helper (Python) Source: https://community.d2l.com/brightspace/kb/articles/1252-brightspace-data-sets-differential-data-sets-client-example A helper function to make authenticated GET requests to Brightspace APIs. It handles setting the 'Authorization' header with a Bearer token and includes basic error handling for non-200 status codes. ```python def get_with_auth(endpoint, access_token): headers = {'Authorization': 'Bearer {}'.format(token_response['access_token'])} response = requests.get(endpoint, headers=headers) if response.status_code != 200: logger.error('Status code: %s; content: %s', response.status_code, response.text) response.raise_for_status() return response ``` -------------------------------- ### Sample LTI 1.0 Launch Request from Brightspace (HTML) Source: https://community.d2l.com/brightspace/kb/articles/23559-lti-1-1-1-0-security-settings An example of a legacy LTI 1.0 launch request originating from Brightspace. This HTML form includes numerous hidden input fields representing various LTI parameters, security settings, and Brightspace-specific extensions. ```html
``` -------------------------------- ### Create Temporary Table and Copy CSV Data using SQL Source: https://community.d2l.com/brightspace/kb/articles/1105-brightspace-data-sets-headless-non-interactive-client-example Creates a temporary table in PostgreSQL with the same structure as the target table but no data. It then uses the COPY expert command to efficiently load data from a CSV stream into this temporary table. ```sql cur.execute( ''' CREATE TEMP TABLE tmp_{table} AS SELECT * FROM {table} LIMIT 0; ''' .format(table=table) ) cur.copy_expert( ''' COPY tmp_{table} FROM STDIN WITH (FORMAT CSV, HEADER); ''' .format(table=table), csv_data ) ``` -------------------------------- ### Excel Formulas for Virtual Classroom Data Analysis Source: https://community.d2l.com/brightspace/kb/articles/1386-getting-started-using-virtual-classroom-partner-data-sets These Excel formulas are used to parse date components from a 'ScheduledDate' field (assumed to be in M2) to calculate the week number. They extract month, year, and day, then use the WEEKNUM function to determine the week of the year. ```Excel P: (Start Month) =MID(M2,6,2) Q: (Start Year) =LEFT(M2,4) R: (Start Date) =MID(M2,9,2) S: (Week Number) =IF(ISERROR(WEEKNUM(DATE(Q2,P2,R2),1)),"",WEEKNUM(DATE(Q2,P2,R2),1)) ```