Rapid Refresh API

This page outlines endpoints relevant to Rapid Refresh analytics

Endpoints available in the Rapid Refresh API

The Rapid Refresh API contains the following endpoints. 

  • ​GET /v2​/rapid-refresh: Get a list of all Rapid Refresh quizzes in your account. 
  • GET /v2​/rapid-refresh/{id}: Get all details about a specific Rapid Refresh quiz in your account. This includes but is not limited to information such as the quiz title, start date, end date, language, question text and answers, and the correct responses. 
  • ​GET /v2​/rapid-refresh/answers: Get a list of all Rapid Refresh slides answers from your learners. 

Endpoints available to build a user group hierarchy

This section outlines the steps to build the user group hierarchy. This can be used to link rapid refresh quizzes with the corresponding user group. 

Building the user group hierarchy can be achieved using two Public API endpoints:

Steps for building the user group hierarchy

Start by using the first endpoint to fetch a flattened list of your user groups to serve as your base. From here they can be iterated over to find user groups where hasChildren is true which can then be used to call the second endpoint to find its children. This can be done recursively until the user group hierarchy has been built.

 

A C# example is provided below:

 

EdApp User Group Response

public class EdAppUserGroupResponse
{
public string Id { get; set; }

public string Name { get; set; }

public string InviteCode { get; set; }

public bool HasChildren { get; set; }
}

 

EdApp Gateway

public async Task<EdAppPaginatedResponse<EdAppUserGroupResponse>> GetPaginatedUserGroupsAsync()
=> await _flurlClient
.Request()
.AppendPathSegment("v2/usergroups")
.GetJsonAsync<EdAppPaginatedResponse<EdAppUserGroupResponse>>();

public async Task<EdAppPaginatedResponse<EdAppUserGroupResponse>> GetUserGroupChildrenAsync(string userGroupId)
=> await _flurlClient
.Request()
.AppendPathSegments("v2/usergroups", userGroupId, "children")
.GetJsonAsync<EdAppPaginatedResponse<EdAppUserGroupResponse>>();

 

User Groups Response

public class UserGroupsResponse
{
public string Id { get; set; }

public string Name { get; set; }

public string InviteCode { get; set; }

public IEnumerable<UserGroupsResponse> Children { get; set; }
}

 

User Group Service

public class UserGroupService : IUserGroupService
{
private readonly IEdAppGateway _edAppGateway;

public UserGroupService(IEdAppGateway edAppGateway)
{
_edAppGateway = edAppGateway;
}

public async Task<IEnumerable<UserGroupsResponse>> GetUserGroupHierarchyAsync()
{
// Get paginated flattened user groups from the EdApp API
var userGroups = await _edAppGateway.GetPaginatedUserGroupsAsync();

// Iterate items to build hierarchy
var tasks = userGroups.Items.Select(userGroup => Task.Run(async () => new UserGroupsResponse
{
Id = userGroup.Id,
Name = userGroup.Name,
InviteCode = userGroup.InviteCode,
Children = await GetUserGroupChildren(userGroup)
}))
.ToList();

// Await tasks and select results
await Task.WhenAll(tasks);
var result = tasks.Select(task => task.Result).ToList();

// Aggregate nested User Groups IDs and filter them out from the root so they only appear within the hierarchy
var nestedUserGroupIds = result.Aggregate(new List<string>(), AggregateNestedUserGroupIds);
return result.Where(x => !nestedUserGroupIds.Contains(x.Id));
}

private static List<string> AggregateNestedUserGroupIds(List<string> nestedUserGroupIds, UserGroupsResponse userGroup)
{
// Iterate over each child adding it's ID to the nested User Group IDs list.
// Recursively call method to get all nested User Group IDs
foreach (var child in userGroup.Children)
{
nestedUserGroupIds.Add(child.Id);
AggregateNestedUserGroupIds(nestedUserGroupIds, child);
}

return nestedUserGroupIds;
}
private async Task<IEnumerable<UserGroupsResponse>> GetUserGroupChildren(EdAppUserGroupResponse edAppUserGroup)
{
// If the User Group has no children return empty
if (!edAppUserGroup.HasChildren)
{
return Enumerable.Empty<UserGroupsResponse>();
}

// Fetch the user groups children from the EdApp API
var children = (await _edAppGateway.GetUserGroupChildrenAsync(edAppUserGroup.Id)).Items;

// Iterate over the children to build the new response and recursively find a child children where applicable
var tasks = children.Select(child => Task.Run(async () => new UserGroupsResponse
{
Id = child.Id,
Name = child.Name,
InviteCode = child.InviteCode,
Children = await GetUserGroupChildren(child)
}))
.ToList();

// Await all tasks and select results to return
await Task.WhenAll(tasks);
return tasks.Select(task => task.Result);
}
}