In this post, we will outline the steps to send a quiz into Kaizala. For this post, we will store the questions in Excel Online. You can always send a quiz from any source (be it a SharePoint List or a database) by configuring the API parameters properly.
Read data from Excel Online
For this example, we will create a quiz where each question has 4 options and one correct answer. The question will be the first column of the excel, followed by 4 options and the last column will denote the correct option number. For example if the first option is correct, the last column should store a value 1. The data has to be stored in a table in a .xlsx document.
For reading data from an Excel file and pushing it to Kaizala, we will be using Microsoft Flow with a schedule based trigger. If we want to send out the quiz everyday, we will keep a schedule at a cadence of 1 day as the trigger in Flow. You can import the Flow we will be using in this example from here to follow alongside this post.
The first step is to read the individual rows in Excel and create each question with appropriate parameters as expected by Kaizala. For this we read the questions from the Excel in Flow as shown below:
Before we go into the action-body, we have defined few variables which the user can configure like the title of the quiz, the description and whether we want to show correct answer after every question:
Creating the Quiz Action Body
The action-body of the quiz package expects the following details:
- title: the title of the quiz
- questions: an array of questions for the quiz (discussed later)
- properties: properties of the quiz including correct answers (discussed later)
- isLocationRequested: whether the quiz expects the participants to share their location
- validity: how long after the quiz has been published can people respond to it (in hours).
- isSenderOnly: who can see the details of people who have responded. Setting it to false means that apart from the sender, the admin of the group can also see the responses.
The questions array is an array of question objects apart from 3 default questions that Quiz expects:
Since these don’t need to be changed, we have added them to the Questions array after reading the questions in Flow. Apart from these, the actual questions have the following details:
- type: whether it is has single/multiple answer correct.
- Options: an array of objects, each of which has id and title representing the options for the question.
For every row in the Excel, we parse and compose the question object and add it to the questions array:
The properties array consist of various properties of the quiz card. Default properties include:
Following properties need to be configured while creating the question objects:
- TrainingProperty: A comma separated string having a list of the questions [e.g. “Q0, Q1”]
- Qi – tells which property contains the answer of question i
- Pi – has an array denoting the correct answer to the question it is linked to.
- TrainingPropertyCount : Number of questions
- TrainingQuestionCount : Number of questions
The Qi and Pi pair for a question Qi looks like this:
For each question that we read from Excel, we have to configure Qi and Pi. Hence, inside the same Apply to Each block as shown in Fig 4, we add these properties as shown below:
Consolidating the Quiz Action Body
Finally, with all sub-parts defined, we create the action body for sending the Quiz:
Now, we are ready to send the quiz in a group. We can use the quiz package id com.microsoft. kaizala.miniapps.oob.quiz.GA to send the quiz to the group.
So, we looked at how you can use Microsoft Flow to read questions from a data store and send it to Kaizala. The Flow is shared here for you to import and try out. Please comment below for queries or reach out to firstname.lastname@example.org for design related questions.
The property and question types do not need to be changed in the Flow. Below are what the numbers depict for questions and properties: