Add default question block structure and validation for properties in question editor
This commit is contained in:
@@ -268,6 +268,14 @@
|
||||
currentContent = JSON.parse(JSON.stringify(question_editor.get().json));
|
||||
}
|
||||
|
||||
if (!currentContent) {
|
||||
currentContent = {
|
||||
title: questionBlockTitleInput.value || "Case Questions",
|
||||
type: "object",
|
||||
properties: {}
|
||||
};
|
||||
}
|
||||
|
||||
if (!currentContent.properties) {
|
||||
currentContent.properties = {};
|
||||
current_question_number = 1;
|
||||
@@ -402,9 +410,13 @@
|
||||
} catch {
|
||||
currentContent = JSON.parse(JSON.stringify(question_editor.get().json));
|
||||
}
|
||||
if (!currentContent || !currentContent.properties) {
|
||||
console.warn('No properties found in the current content.');
|
||||
return;
|
||||
}
|
||||
const properties = currentContent.properties || {};
|
||||
|
||||
// Sort questions by propertyOrder
|
||||
// Sort questions by propertyOrder
|
||||
const sortedKeys = Object.keys(properties).sort((a, b) => {
|
||||
const orderA = properties[a].propertyOrder !== undefined ? properties[a].propertyOrder : 1000;
|
||||
const orderB = properties[b].propertyOrder !== undefined ? properties[b].propertyOrder : 1000;
|
||||
|
||||
Reference in New Issue
Block a user