The Query Builder

Understanding the query builder is the key to understanding the Learning Record Store. The query builder is a tool that you'll see throughout the Learning Record Store. It's used to filter xAPI statements, allowing you to pinpoint the data that you're interested in.

mceclip0.png


The classic query builder

mceclip1.png

The new version of the query builder


Where is it used?

The query builder is used throughout the Learning Record Store. It's the key to selecting which data you want to be displayed where. For example, you can see it being used in a bar chart visualization:
mceclip0.png

The first place you'll find the query builder is on the Source page:
Query_Builder.gif

On the source page, the query builder filters every xAPI statement in your Learning Record Store. The query builder is on the left and the filtered statements will appear on the right.
Two options are available for the filtered statements:

Today Only - adds a timestamp filter for the current day (00:00 → 23:59) hence showing learning activities that take place today.
This can help drastically reduce the amount of data returned and is the convenient button for adding a lower bound on the timestamp manually.

Sort dropdown - sort by timestamp or stored, both descending. Using stored hides the statements with future timestamp as it only shows latest statements that are stored on the LRS.

 

The classic query builder

In the example below we wanted to see which learning experiences had been completed by a specific user. We did this by using the Who and Did filters. On the right hand side you can see a list of statements about which learning experiences the specified user has completed:
mceclip2.png
Each of these headings contains a selection of filtering options which reveal themselves when you click the corresponding plus button.
Who - used to locate specific learners using their user IDs, names, email address, etc.
Did - used to identify specific xAPI verbs that relate to what the learner did. E.g. Opened, Joined, Completed (click here to read more.)
What - the content that this action was taken on/with.
Where - additional context relating to the content - e.g. the platform it happened on. 
Metadata - GS Learning specific info that can be found in some xAPI statements.
Result - used to filter by scores achieved in assessments, passes/fails, etc.
When - when the statement was sent.
Store - if you have multiple stores in your Learning Record Store, you can use this to filter them. 
Classic_query_builder_1.png
The In/Out toggle dictates whether your criteria should be included or excluded. For example, if you put in
someone’s name and set the toggle to ‘out’ then that person is not included in the results from your query.
Classic_Query_Builder_2.gif
This button opens up the manual query builder. This allows you to manually type in a query if you’re already very familiar with xAPI. It’s also useful if you want to copy your query and send it to someone else or if you want to use it as a custom xAPI trigger (click here to read more). Classic_Query_Builder_3.gif
If you’ve built a query that you would like to use again, you can load it and save it using the Load a Query and Save buttons.  Classic_Query_Builder_4.gif
The Try New Version toggle swaps the Query Builder to the new version, which is documented on the following page. Classic_Query_Builder_5.gif

 

The new query builder

Use the Include from... dropdown menu to select the kind of criteria you would like to add to your query.
New_Query_Builder_1.gif
Select the criteria you want to include from the next
dropdown menu.
New_Query_Builder_2.gif
Click Add parameter and you’ll see your new parameter appear in the section below. You can click the red X to remove this parameter.
New_Query_Builder_3.gif
Click EXCLUDE to build a parameter that excludes rather than includes your criteria.
New_Query_Builder_4.gif
Click RANGE to build a parameter parameter based on a range
of data. E.g. including statements from 2020 - 2021 or a score
of 9-15.
New_Query_Builder_5.gif
Use the Load a Query and
Save buttons to save and load queries you want to use again.
New_Query_Builder_6.gif

 

 

Using the Exact Input option

This feature allows you to create queries in the new query builder from exactly what you've typed in, even if it doesn't appear as a prompt in the dropdown list. In some instances, the ability for the query builder to display prompts in the drop-down elements is suppressed for performance reasons. In these cases, utilizing the Exact Input approach to building queries may be necessary.

Remember, the Exact Input option is only available when using the new version of the query builder.
LRS_QB_NewVersion.png
In the first dropdown ‘include from’ select which part of the statement you want to use to build your query person, verb, object, etc. In this example, we select "verb". LRS_QB_InputFrom.png

In the second drop down type or paste in the parameter/object ID of the object you are writing the query condition for.

In our example below we want to build a query that shows users who have completed a course so we type in the verb ID for "completed". (http://adlnet.gov/expapi/verbs/completed)

LRS_QB_ParameterObjectID.png

Click on the ‘Use Exact Input’ option in the dropdown and it will update the parameter/object ID in the proper ID format based on what you typed.

LRS_QB_UseExactInput.png
Click the add parameter button and it constructs a query that finds the statement. In this example, our results show users who have completed courses LRS_QB_CompletedCourses.png
Another way to build your query is to use the URL from the course you want to find statements for. Below is the URL for the course Creativity & Problem Solving
LRS_QB_URL.png
For this example, we select the object in the first dropdown, as we want to query a course, and paste the URL into the second dropdown.
LRS_QB_URL2.png
Click on 'Use Exact Input' and then Add parameter and you will see results for people who have completed or launched the course. LRS_QB_CompletedCourses2.png

 

See a demonstration of this process here.

What is entered into the second dropdown may require some knowledge of the statements and how they work.  We have given two examples of what to input and have included these examples with others in the section below to help users. 

  • The URL from a course you want to include in your query. If you have access to your LXP then you can get the course URL and use this in your query as we have shown in our example above.
    • https://thepool.thelpacademy.com/courses/lls-creativity-problem-solving-Sept2023/home#object/913940
  • You can use the generic verb ID for the activity you want to include in your query. Some examples of verb ID’s we use in our LXP are below including completed which we have shown in our example above.
    • User completes level - http://adlnet.gov/expapi/verbs/completed
    • A user is enrolled on to a course/Learning Experience - http://activitystrea.ms/schema/1.0/join
    • User views a resource on a Learning Experience - http://id.tincanapi.com/verb/viewed
  • There is a comprehensive list of more activity verb IDs (xAPI statements) that LP use here. These can all be used to help build your query.

 Note

This option is not available for Person and Store conditions as the suggested options do not come from the QBCV collection but from the personas and stores collections respectively.