Skip to content

Commit

Permalink
Untitled, unsaved instance names now update to prompt topic when gene…
Browse files Browse the repository at this point in the history
…rating qsets
  • Loading branch information
clpetersonucf committed Aug 23, 2024
1 parent 67f252f commit e4c2dcd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 4 additions & 1 deletion fuel/app/classes/materia/api/v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,10 @@ static public function question_set_generate($inst_id, $widget_id, $topic, $incl
if ($num_questions < 1) $num_questions = 8;
if ($num_questions > 32) $num_questions = 32;

return Widget_Question_Generator::generate_qset($inst, $widget, $topic, $include_images, $num_questions, $build_off_existing);
return [
...Widget_Question_Generator::generate_qset($inst, $widget, $topic, $include_images, $num_questions, $build_off_existing),
'title' => $topic
];
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/components/question-generator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ const QsetGenerator = () => {
num_questions: numQuestions,
build_off_existing: buildOffExisting,
successFunc: (result) => {
let created_at = new Date().toISOString()
window.parent.Materia.Creator.onQsetReselectionComplete(
JSON.stringify(result.qset),
true, // is generated
result.version,
created_at
result.title
)
setLoading(false)
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/question-history.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const QuestionHistory = () => {
JSON.stringify(save.data),
false, // is generated
save.version,
save.created_at
null
)
}
})
Expand Down
10 changes: 5 additions & 5 deletions src/components/widget-creator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ const WidgetCreator = ({instId, widgetId, minHeight='', minWidth=''}) => {
setInstance({
...instance,
qset: creatorState.reloadWithQset,
...( creatorState.reloadWithQset.title && { name: creatorState.reloadWithQset.title }), // fancy syntax to only apply the name property when reloadWithQset.title is set
...( ! instIdRef.current && { preSaveSpecialCondition: true }) // fancy syntax to ensure preSaveSpecialCondition is only applied when instIdRef.current is unavailable
})
}
Expand Down Expand Up @@ -603,7 +604,8 @@ const WidgetCreator = ({instId, widgetId, minHeight='', minWidth=''}) => {
},

// When a new qset is selected from the prior saves list or generated
onQsetReselectionComplete(qset, showGenerationConfirm = false, version = 1) {
onQsetReselectionComplete(qset, showGenerationConfirm = false, version = 1, title = null) {
console.log(title)
if (!qset) {
setCreatorState({
...creatorState,
Expand All @@ -616,8 +618,6 @@ const WidgetCreator = ({instId, widgetId, minHeight='', minWidth=''}) => {
} else {

requestSave('history')
console.log(qset)

let parsedQsetData = JSON.parse(qset)

setCreatorState({
Expand All @@ -628,11 +628,11 @@ const WidgetCreator = ({instId, widgetId, minHeight='', minWidth=''}) => {
data: parsedQsetData,
version: version,
id: parsedQsetData.id,
...(title && { title: title }),
},
// cachedQset: instance.qset,
showActionBar: false,
showRollbackConfirm: showGenerationConfirm ? false : true,
showGenerationConfirm: showGenerationConfirm
showGenerationConfirm: showGenerationConfirm,
})
}
},
Expand Down

0 comments on commit e4c2dcd

Please sign in to comment.