@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
131 lines (107 loc) • 2.45 kB
Markdown
content_id: "121077945"
title: DeepEquals
# DeepEquals
DeepEquals asserts that an object or an array are exactly the same, with the
object or array only allowing primitives as the values of the keys (no arrays
or objects). Because of this, two different scoringData are allowed:
## scoring_data as object:
```js
{
"value": {
"choice_uuid1": "answer_uuid1",
"choice_uuid2": "answer_uuid2",
"choice_uuid3": "answer_uuid3",
}
}
```
## scoring_data as array:
```js
{
"value": ["uuid1", "uuid2", "uuid3"]
}
```
## With Object
### Correct Case
#### user_response:
```js
{
"value": {
"choice_uuid1": "answer_uuid1",
"choice_uuid2": "answer_uuid2",
"choice_uuid3": "answer_uuid3",
}
}
```
#### scored_data
```js
{
"value": [
{id: "choice_uuid1", value: "answer_uuid1", resultScore: 1, userResponded: 'answer_uuid1'},
{id: "choice_uuid2", value: "answer_uuid2", resultScore: 1, userResponded: 'answer_uuid2'},
{id: "choice_uuid3", value: "answer_uuid3", resultScore: 1, userResponded: 'answer_uuid3'}
],
"correct": true
}
```
### Incorrect Case
#### user_response:
```js
{
"value": {
"choice_uuid1": "answer_uuid1",
"choice_uuid2": "answer_uuid2",
"choice_uuid3": "answer_uuid3",
}
}
```
#### scored_data
```js
{
"value": [
{id: "choice_uuid1", value: "answer_uuid1", resultScore: 1, userResponded: 'answer_uuid1'},
{id: "choice_uuid2", value: "answer_uuid2", resultScore: 0, userResponded: 'answer_uuid3'},
{id: "choice_uuid3", value: "answer_uuid3", resultScore: 0, userResponded: 'answer_uuid2'}
],
"correct": false
}
```
## With Array
### Correct Case
#### user_response:
```js
{
"value": ["uuid1", "uuid2", "uuid3"]
}
```
#### scored_data
The id in an array will be the index as the value appeared in the scoredData.
```js
{
"value": [
{id: 0, value: "uuid1", resultScore: 1, userResponded: "uuid1"},
{id: 1, value: "uuid2", resultScore: 1, userResponded: "uuid2"},
{id: 2, value: "uuid3", resultScore: 1, userResponded: "uuid3"}
],
"correct": true
}
```
### Incorrect Case
#### user_response:
```js
{
"value": ["uuid2", "uuid1", "uuid3"]
}
```
#### scored_data
```js
{
"value": [
{id: 0, value: "uuid1", resultScore: 0, userResponded: "uuid2"},
{id: 1, value: "uuid2", resultScore: 0, userResponded: "uuid1"},
{id: 2, value: "uuid3", resultScore: 1, userResponded: "uuid3"}
],
"correct": false
}
```