Method Signature
constructorio . quizzes . getQuizResultsConfig ( quizId , parameters ? , networkParameters ? )
Retrieves the configuration for how quiz results should be displayed, including title, description, and response summary settings.
Parameters
The ID of the quiz to get results configuration for.
Optional parameters for the request. The version ID of the quiz. If not provided, the latest version will be used.
Network-specific parameters. Request timeout in milliseconds.
Response
Returns a Promise that resolves to a QuizResultsConfigResponse object.
The version ID of the quiz.
Additional metadata for the quiz.
Configuration for displaying quiz results. Desktop viewport configuration. Title configuration. Whether the title should be displayed.
The title text to display.
Description configuration. Whether the description should be displayed.
The description text to display.
Summary of user responses configuration. Whether the response summary should be displayed.
Template text for the summary.
Separator between items (e.g., ”, ”).
Separator before the last item (e.g., ” and ”).
Examples
Basic Usage
const config = await constructorio . quizzes . getQuizResultsConfig ( 'product-finder-quiz' );
console . log ( 'Quiz results configuration:' , config . results_config );
With Specific Quiz Version
const config = await constructorio . quizzes . getQuizResultsConfig ( 'product-finder-quiz' , {
quizVersionId: 'v2.0'
});
console . log ( 'Version:' , config . quiz_version_id );
Displaying Results Based on Config
const config = await constructorio . quizzes . getQuizResultsConfig ( 'product-finder-quiz' );
const resultsConfig = config . results_config . desktop ;
// Check if title should be shown
if ( resultsConfig . title . is_active ) {
displayTitle ( resultsConfig . title . text );
}
// Check if description should be shown
if ( resultsConfig . description . is_active ) {
displayDescription ( resultsConfig . description . text );
}
// Check if response summary should be shown
if ( resultsConfig . response_summary . is_active ) {
const summary = buildResponseSummary (
userAnswers ,
resultsConfig . response_summary . items_separator ,
resultsConfig . response_summary . last_separator
);
displaySummary ( summary );
}
Building Response Summary
function buildResponseSummary ( answers , itemsSeparator , lastSeparator ) {
if ( answers . length === 0 ) return '' ;
if ( answers . length === 1 ) return answers [ 0 ];
const allButLast = answers . slice ( 0 , - 1 ). join ( itemsSeparator );
const last = answers [ answers . length - 1 ];
return ` ${ allButLast }${ lastSeparator }${ last } ` ;
}
const config = await constructorio . quizzes . getQuizResultsConfig ( 'style-quiz' );
const userSelections = [ 'Modern' , 'Minimalist' , 'Scandinavian' ];
const summary = buildResponseSummary (
userSelections ,
config . results_config . desktop . response_summary . items_separator ,
config . results_config . desktop . response_summary . last_separator
);
// Result: "Modern, Minimalist and Scandinavian"
Complete Quiz Results Page
async function renderQuizResultsPage ( quizId , quizSessionId , answers ) {
// Get configuration
const config = await constructorio . quizzes . getQuizResultsConfig ( quizId );
// Get results
const results = await constructorio . quizzes . getQuizResults ( quizId , {
quizSessionId ,
answers
});
const desktopConfig = config . results_config . desktop ;
// Render title
if ( desktopConfig . title . is_active ) {
document . getElementById ( 'results-title' ). textContent = desktopConfig . title . text ;
}
// Render description
if ( desktopConfig . description . is_active ) {
document . getElementById ( 'results-description' ). textContent = desktopConfig . description . text ;
}
// Render response summary
if ( desktopConfig . response_summary . is_active ) {
const selectedOptions = results . quiz_selected_options
. filter ( opt => opt . is_matched )
. map ( opt => opt . value );
const summary = buildResponseSummary (
selectedOptions ,
desktopConfig . response_summary . items_separator ,
desktopConfig . response_summary . last_separator
);
document . getElementById ( 'response-summary' ). textContent =
desktopConfig . response_summary . text . replace ( '{answers}' , summary );
}
// Render products
renderProducts ( results . response . results );
}
With Error Handling
try {
const config = await constructorio . quizzes . getQuizResultsConfig ( 'product-finder-quiz' );
if ( config . results_config ) {
applyQuizConfiguration ( config . results_config );
}
} catch ( error ) {
console . error ( 'Failed to load quiz configuration:' , error );
// Use default configuration
useDefaultConfiguration ();
}
Custom Network Timeout
const config = await constructorio . quizzes . getQuizResultsConfig (
'product-finder-quiz' ,
{},
{ timeout: 5000 }
);
Use Cases
Custom Results Page UI
Use the configuration to customize the quiz results page display based on quiz-specific settings configured in the Constructor.io dashboard.
Response Summary Display
Build a summary of user answers using the configured separators to show users what they selected.
Responsive Design
Use the desktop configuration to determine how to display results on different viewports.
Error Handling
try {
const config = await constructorio . quizzes . getQuizResultsConfig ( 'my-quiz' );
console . log ( 'Configuration loaded successfully' );
} catch ( error ) {
console . error ( 'Error loading quiz configuration:' , error );
}