Gauntlet-Incept MCP
by Birdsmith
- src
- utils
/**
* QTI Utilities
*
* This file provides utilities for interacting with the 1EdTech Extended QTI Implementation,
* which is used to store generated content in a standardized format.
*/
/**
* Save content to the QTI database
*
* @param {string} content - The content to save
* @param {Object} tags - The tags for the content
* @param {string} contentType - The type of content (question or article)
* @returns {string} The ID of the saved content
*/
async function saveToQTI(content, tags, contentType) {
try {
// TODO: Implement actual QTI API call
console.log(`Saving ${contentType} to QTI database with tags:`, tags);
// Placeholder implementation
const id = `${contentType}_${Date.now()}`;
console.log(`Saved ${contentType} with ID: ${id}`);
return id;
} catch (error) {
console.error(`Error saving ${contentType} to QTI:`, error);
throw new Error(`Failed to save ${contentType} to QTI: ${error.message}`);
}
}
/**
* Convert a question to QTI format
*
* @param {string} question - The question content
* @param {Object} tags - The tags for the question
* @returns {Object} The question in QTI format
*/
function questionToQTI(question, tags) {
// TODO: Implement actual conversion logic
// Placeholder implementation
const qtiQuestion = {
'qti-assessment-item': {
identifier: `q_${Date.now()}`,
title: 'Question',
'adaptive': false,
'time-dependent': false,
'qti-item-body': {
'qti-block-quote': {
content: question
}
},
'qti-response-declaration': {
identifier: 'RESPONSE',
cardinality: 'single',
'base-type': 'identifier'
},
metadata: {
subject: tags.subject,
grade: tags.grade,
standard: tags.standard,
lesson: tags.lesson,
difficulty: tags.difficulty
}
}
};
return qtiQuestion;
}
/**
* Convert an article to QTI format
*
* @param {string} article - The article content
* @param {Object} tags - The tags for the article
* @returns {Object} The article in QTI format
*/
function articleToQTI(article, tags) {
// TODO: Implement actual conversion logic
// Placeholder implementation
const qtiArticle = {
'qti-assessment-stimulus': {
identifier: `a_${Date.now()}`,
title: 'Article',
'qti-stimulus-body': {
'qti-block-quote': {
content: article
}
},
metadata: {
subject: tags.subject,
grade: tags.grade,
standard: tags.standard,
lesson: tags.lesson
}
}
};
return qtiArticle;
}
/**
* Create a QTI test part (lesson)
*
* @param {string} lessonId - The ID of the lesson
* @param {string} lessonTitle - The title of the lesson
* @param {string} articleId - The ID of the article for this lesson
* @param {Array} questionIds - The IDs of the questions for this lesson
* @returns {Object} The lesson in QTI format
*/
function createQTITestPart(lessonId, lessonTitle, articleId, questionIds) {
// TODO: Implement actual conversion logic
// Placeholder implementation
const qtiTestPart = {
identifier: `tp_${lessonId}`,
title: lessonTitle,
'navigation-mode': 'linear',
'submission-mode': 'individual',
'qti-assessment-section': [
{
identifier: `s_article_${lessonId}`,
title: 'Article Section',
'qti-assessment-item-ref': [
{
identifier: `ref_${articleId}`,
href: `../articles/${articleId}.xml`
}
]
},
{
identifier: `s_questions_${lessonId}`,
title: 'Question Bank Section',
'qti-assessment-item-ref': questionIds.map(qId => ({
identifier: `ref_${qId}`,
href: `../questions/${qId}.xml`
}))
}
]
};
return qtiTestPart;
}
/**
* Create a QTI assessment test (course)
*
* @param {string} courseId - The ID of the course
* @param {string} courseTitle - The title of the course
* @param {Array} testParts - The test parts (lessons) for this course
* @returns {Object} The course in QTI format
*/
function createQTIAssessmentTest(courseId, courseTitle, testParts) {
// TODO: Implement actual conversion logic
// Placeholder implementation
const qtiAssessmentTest = {
'qti-assessment-test': {
identifier: `at_${courseId}`,
title: courseTitle,
'test-part-mode': 'linear',
'qti-test-part': testParts
}
};
return qtiAssessmentTest;
}
module.exports = {
saveToQTI,
questionToQTI,
articleToQTI,
createQTITestPart,
createQTIAssessmentTest
};