Info |
---|
The following queries are SAMPLES. As a consumer of the Scope GraphQL API, you can design and use any properly formed query to retrieve the data that you require. For more information, see “Introduction to the Scope GraphQL API“. |
Table of Contents | ||||
---|---|---|---|---|
|
Scenario Sessions with Quiz Data
Problem
As an analyst, I want to returns scenario sessions but also include any quiz related data.
Solution
Adding in filters into the scenario session events associated with the session will allow for only quiz data related events to be returned.
...
Code Block |
---|
query { scenarioSessions(first: 25) { nodes { id databaseId duration endedAt externalData startedAt endedAt duration sessionType completedSteps { nodes { id } } parts(first: 1, orderBy: { attribute: "startedAt", direction: DESC}) { nodes { databaseId createdBy { id name } userInfo { latitude longitude deviceOs deviceModel devicePlatform } } } scenario { id name organization { slug } } scenarioRelease { version sdkVersion workInstructionType type sequences { nodes { id name scenarioSteps(first: 1000) { nodes { id name orderIndex type scenarioSequence { id name } items(first: 1000) { nodes { id description type } } } } } } } steps(first: 1000, orderBy: {attribute: "startedAt", direction: ASC}) { nodes { id completed duration completedItems { nodes { id } } scenarioStep { id name type orderIndex scenarioSequence { id name } items(first: 1000) { nodes { id description type } } } scenarioSessionEvents( first: 1000 eventTypes: [QUIZ_ITEM_COMPLETE, CHECKLIST_ITEM_COMPLETE, SCREENSHOT_CAPTURED] orderBy: {attribute: "startedAt", direction: DESC} ) { nodes { barcode startedAt type value photo { fileUrl } scenarioStepItem { id } } } } } } } } |
Retrieve Scenario Sessions from Public (or Private) Scenarios
Problem
As an analyst, I only want to retrieve the sessions of a scenario that is publicly visible (or private).
Solution
Adding in the publicVisibility argument into the scenarios query allows for the scenarios to be filtered appropriately.
Code Block |
---|
query { scenarios(first: 100, scenariosQueryArguments: { publicVisibility: true }) { nodes { sessions(first: 10) { nodes { id databaseId startedAt endedAt organization { id databaseId name } scenario { id databaseId name } user { id databaseId name username } } } } } } |
Session Data that excludes certain email domains
Problem
As an analyst, I want a list of scenario sessions that are not created by user with an email domain like public.scope.com
and are sorted by the scenario ID.
Solution
Unfortunately, our current API does not offer a way to filter by exclusion. However, it does provide a way to filter by inclusion, meaning that the query can be used to grab all sessions with a particular email domain. The query is grabbing the scenarios first, so the sessions will automatically be sorted by the scenario ID. However, scenarios and sessions must be paginated due to performance reasons:
Code Block |
---|
query { scenarios(first: 100, afterIndex: -1) { nodes { id databaseId name sessions(first: 25, afterIndex: -1, fullText: "@scopear.com") { nodes { id databaseId startedAt endedAt organization { id databaseId name } scenario { id databaseId name } user { id databaseId name username } } } } } } |
Scenario Session Step Data With Detailed Information
Problem
I want to retrieve scenario sessions but with lots of detailed information.
Solution
By adding to the data returned from the query, a lot of details can be shown for each scenario session. However, the results should be paginated for performance reasons.
Code Block |
---|
query { scenarioSessions(first: 25, afterIndex: -1, fullText: "@scopear.com") { nodes { id databaseId startedAt endedAt duration organization { id databaseId name } scenario { id databaseId name } steps(first: 1000) { nodes { scenarioSessionPart { databaseId id userInfo { longitude latitude } } scenarioStep { orderIndex name } } } user { id databaseId name email } } } } |
Session Data Retrieval
Problem
As an analyst, I want to know which users have completed a particular Scenario so that I can issue credit to the users relating to the associated learning module in my system-of-record.
Solution
I will use a GraphQL client to retrieve Scenario Session data from the Scope GraphQL API which is not otherwise available in the Scope CMS user interface.
Procedure
...
The GraphiQL client application is installed and configured to communicate with the Scope GraphQL API (see “Exploring the Graph”)
The following query is executed:
Code Block query { node(id: "INSERT_ID_OF_SCENARIO") { ... on Scenario { sessions { nodes { id state user { id name } } } } } }
The JSON response is reformatted to CSV (using any relevant tool) for merge with system-of-record data and/or reporting.
Retrieving A Single Scenario Session’s Data
Code Block |
---|
query SampleScenarioSessionNodeQueryDemonstratingImportantFields($id: ID!) { node(id: $id) { ... on ScenarioSession { startedAt endedAt duration idleDuration numberOfStepsPossible numberOfStepsViewed percentOfStepsViewed state externalData # NOTE: this is where query params passed from the System of Record can be found scenarioRelease { author { id name } publishedAt scenario { author { id name } description name originGroup { id name } publishedAt } type version } events { nodes { id createdAt receivedAt type externalData } } steps { nodes { scenarioStep { name orderIndex scenarioSequence { name } } } } } } } |
Retrieving All Scenario Session Data
Code Block |
---|
query SampleAllScenarioSessionsQueryDemonstratingImportantFields { viewer { organization { scenarioSessions { nodes { startedAt endedAt duration idleDuration numberOfStepsPossible numberOfStepsViewed percentOfStepsViewed state externalData # NOTE: this is where query params passed from the System of Record can be found scenarioRelease { author { id name } publishedAt scenario { author { id name } description name originGroup { id name } publishedAt } type version } events { nodes { id createdAt receivedAt type externalData } } steps { nodes { scenarioStep { name orderIndex scenarioSequence { name } } } } } } } } } |
...