Skip to content

Commit

Permalink
Merge pull request #81 from clpetersonucf/feature/score-screen-and-fixes
Browse files Browse the repository at this point in the history
Adventure score screen and conditional question polish
  • Loading branch information
clpetersonucf authored Jun 25, 2024
2 parents c36114b + 7424564 commit e20eaf7
Show file tree
Hide file tree
Showing 22 changed files with 2,120 additions and 1,070 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"version": "2.4.1",
"dependencies": {
"materia-widget-development-kit": "^3.0.1",
"materia-widget-development-kit": "^3.0.2",
"micromarkdown": "^0.3.0"
},
"scripts": {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/_guides/creator.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ For any destination type besides Hotspot, selecting the **Add Media** button cha

If you choose to upload an image, the image uploader will be displayed, where you can upload images from your computer, or select an image you've previously uploaded to Materia. Once you've selected an image or video, you can use the **Swap with Question** button below the media to switch the arrangement of the image and question text. Narrative and End Point destinations allow you to choose between vertical as well as horizontal arrangements. Select **Change Media** to choose a different image or video.

### (Advanced) Conditional Text Based on Number of Visits
You have the option of creating different question text each time a player visits a destination. Click on the "Advanced Question Editor" at the top right of the node creation screen to open the editor.

![conditional questions](assets/create_widget_adventure_conditional_questions.png "conditional questions")

1. Add question text
2. Change required number of visits

It will always display the question text with the most required number of visits met. For example, if a player has visited the node 2 times, it will display the second question above. If a player has visited the node 6 times, it will display the third question above.

## Inventory System ##

Optionally, you can choose to use the inventory system. The inventory system allows you to give the player items or remove items from the player's inventory for each destination they visit.
Expand Down Expand Up @@ -283,6 +293,13 @@ The advanced options allow you to set the required item amount to be within a sp
2. Set the maximum number the player can have of this item to select this answer.
3. (Default) Set the maximum to have no cap.

### (Advanced) Conditional Question Text Based on Items
Once you have created items, an option will appear in the Advanced Question Editor to require items for each question text. You can require players to have certain items in their inventory in order to see different questions by clicking on the "Edit Required Items" button. This menu will operate similarly to the required items for answers from above.

![conditional questions](assets/create_widget_adventure_conditional_questions_items.png "conditional questions")

It will always display the question text with the most requirements met. For example, if the first question requires the player to have a hat, but the second question requires the player to have a hat AND a vinyl, it will display the second question if the player has both.

### Example Tree Using Inventory System ###

![adventure tree with items](assets/create_widget_adventure_tree_with_items.png "adventure tree with items")
Expand Down
61 changes: 39 additions & 22 deletions src/_score/score_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,33 @@ public function check_answer($log)
continue;
}

# make sure we have the right qset item that matches the provided log, return associated finalScore
if (trim($log->text) == trim($item['questions'][0]['text']))
# newer qsets (post- custom score screen will provide the node id as the log's item id)
# in older qsets, item id will always be 0 for FINAL_SCORE_FROM_CLIENT log types
if ($log->item_id)
{
if (isset($this->inst->qset->data['options']['scoreMode']) && $this->inst->qset->data['options']['scoreMode'] == 'Non-Scoring')
if ($log->item_id == $item['options']['id'])
{
return 100;
if (isset($this->inst->qset->data['options']['scoreMode']) && $this->inst->qset->data['options']['scoreMode'] == 'Non-Scoring')
{
return 100;
}
else
{
return $item['options']['finalScore'];
}
}
else
}
else {
if (trim($log->text) == trim($item['questions'][0]['text']))
{
return $item['options']['finalScore'];
if (isset($this->inst->qset->data['options']['scoreMode']) && $this->inst->qset->data['options']['scoreMode'] == 'Non-Scoring')
{
return 100;
}
else
{
return $item['options']['finalScore'];
}
}
}
}
Expand Down Expand Up @@ -78,23 +95,23 @@ protected function details_for_question_answered($log)
$score = $this->check_answer($log);

return [
'id' => $log->item_id,
'data' => [
$this->get_ss_question($log, $q),
$this->get_ss_answer($log, $q)
$this->get_ss_answer($log, $q),
$log->value
],
'data_style' => ['question', 'response', 'answer'],
'data_style' => ['question', 'response'],
'score' => $score,
'feedback' => $this->get_feedback($log, $q->answers),
'type' => $log->type,
'style' => $this->get_detail_style($score),
'tag' => 'div',
'symbol' => '%',
'graphic' => 'score',
'display_score' => false
];
}


protected function get_score_details()
{
$details = [];
Expand All @@ -116,28 +133,28 @@ protected function get_score_details()
break;

case Session_Log::TYPE_FINAL_SCORE_FROM_CLIENT:
$destination_table[] = [
'data' => [$log->text],
'data_style' => ['node_text'],
$details[] = [
'node_id' => $log->item_id,
'data' => [
$log->text,
$this->check_answer($log)
],
'data_style' => ['text', 'score'],
'score' => $this->check_answer($log),
'type' => $log->type,
'style' => 'single_column',
'tag' => 'p',
'style' => 'final_score',
'symbol' => '%',
'graphic' => 'none',
'display_score' => false
'graphic' => 'score',
'display_score' => false,
'older_qset' => $log->item_id == 0 && $log->text != 'Blank Destination! Be sure to edit or remove this node before publishing.' ? true : false,
'blank_node' => $log->item_id == 0 && $log->text == 'Blank Destination! Be sure to edit or remove this node before publishing.' ? true : false,
];
break;
}
}

// return an array of tables
return [
[
'title' => 'Where did you end up?',
'header' => [],
'table' => $destination_table,
],
[
'title' => 'Responses:',
'header' => ['Question Score', 'The Question', 'Your Response'],
Expand Down
Loading

0 comments on commit e20eaf7

Please sign in to comment.