@brightspace-ui/htmleditor
Advanced tools
Comparing version 2.75.5 to 2.75.6
@@ -980,2 +980,7 @@ import '@brightspace-ui/core/components/alert/alert-toast.js'; | ||
_saveActivity(e) { | ||
const genAI = this.shadowRoot.querySelector('d2l-generate-question-panel'); | ||
if (genAI) { | ||
genAI.notifySave(); | ||
} | ||
this._stepIndex = 2; | ||
@@ -982,0 +987,0 @@ this.requestUpdate('_stepIndex', 1); |
@@ -60,2 +60,3 @@ import { LlmController } from '../llm-controller.js'; | ||
this._resetState(); | ||
this._resetGenerationTracking(); | ||
} | ||
@@ -211,2 +212,9 @@ | ||
this.generationCount = 0; | ||
const event = new CustomEvent('d2l-genai-question-discard', { | ||
bubbles: true, | ||
composed: true, | ||
}); | ||
this.host.dispatchEvent(event); | ||
} | ||
@@ -213,0 +221,0 @@ |
@@ -66,2 +66,3 @@ import './generate-question-editor.js'; | ||
@d2l-genai-question-generated="${this._generatedQuestion}" | ||
@d2l-genai-question-discard="${this._discardQuestion}" | ||
template-index="${this.templateIndex}" | ||
@@ -79,2 +80,6 @@ session-id="${this._telemetry.sessionId}" | ||
notifySave() { | ||
this._telemetry.saved(); | ||
} | ||
willUpdate() { | ||
@@ -84,2 +89,6 @@ this.api.determineHidden(); | ||
_discardQuestion() { | ||
this._telemetry.discardQuestion(); | ||
} | ||
_feedback() { | ||
@@ -86,0 +95,0 @@ if (this.api.showFeedback) { |
@@ -7,3 +7,4 @@ import { requestInstance } from '@brightspace-ui/core/mixins/provider-mixin.js'; | ||
questionGenerated: 'QuestionGenerated', | ||
feedback: 'Feedback' | ||
feedback: 'Feedback', | ||
accepted: 'Accepted' | ||
}; | ||
@@ -43,6 +44,15 @@ | ||
this.sessionId = randomUUID(); | ||
this._lastSentQuestionEventGenerationId = null; | ||
this._lastSentQuestionEventGenerationId = this.generationId = null; | ||
this.lmsVersion = document.documentElement.getAttribute('data-app-version'); | ||
} | ||
discardQuestion() { | ||
this.generationId = this._lastSentQuestionEventGenerationId = null; | ||
this.sourceText = null; | ||
this.generatedContent = null; | ||
this.generationCount = 0; | ||
this.questionType = null; | ||
this.backendVersion = null; | ||
} | ||
generatedQuestion(e) { | ||
@@ -89,2 +99,10 @@ this.generationId = e.generationId; | ||
saved() { | ||
if (!this.generationId) { | ||
return; | ||
} | ||
this._sendQuestionEvent(); | ||
this._sendTelemetryEvent(actions.accepted); | ||
} | ||
_sendQuestionEvent() { | ||
@@ -91,0 +109,0 @@ if (this._lastSentQuestionEventGenerationId === this.generationId) { |
@@ -382,2 +382,11 @@ import '@brightspace-ui/core/components/button/button.js'; | ||
let firstAnswer = true; | ||
const createBlanksFromLlm = () => { | ||
const processedQuestion = this.activityData.questions[0].text.replaceAll('(', '[').replaceAll(')', ']').trim(); | ||
this._updateValue('questions:0:text', processedQuestion); | ||
this.questionText = processedQuestion; | ||
this._processBlanks(); | ||
firstAnswer = false; | ||
}; | ||
const processContent = (chunkValue) => { | ||
@@ -390,7 +399,3 @@ content = content + chunkValue; | ||
if (firstAnswer) { | ||
const processedQuestion = this.activityData.questions[0].text.replaceAll('(', '[').replaceAll(')', ']').trim(); | ||
this._updateValue('questions:0:text', processedQuestion); | ||
this.questionText = processedQuestion; | ||
this._processBlanks(); | ||
firstAnswer = false; | ||
createBlanksFromLlm(); | ||
} | ||
@@ -433,2 +438,8 @@ answerId = content.match(fields.answerIdRegex)[0]; | ||
if (firstAnswer) { | ||
// Occurs when a question is generated with answer placeholders but no possible answers after it | ||
// We should still update blanks so they can manually input correct and alternative answers. | ||
createBlanksFromLlm(); | ||
} | ||
this._updateActivity(); | ||
@@ -435,0 +446,0 @@ |
@@ -545,3 +545,3 @@ import '@brightspace-ui/core/components/alert/alert-toast.js'; | ||
</div> | ||
<input ?disabled=${disabled} class="d2l-input-checkbox" type="checkbox" id="${answer.id}" data-property="${property.correctAnswers}" ?checked=${live(this._getPropertyValue(property.correctAnswers).includes(answer.id))} @change="${this._change}" aria-label="${this._getPropertyValue(property.correctAnswers).includes(answer.id) ? this.localize('practice:questions:answerCorrect', { text: answer.text }) : this.localize('practice:questions:answerIncorrect', { text: answer.text })}"> | ||
<input ?disabled=${disabled} class="d2l-input-checkbox" type="checkbox" id="${answer.id}" data-property="${property.correctAnswers}" .checked=${live(this._getPropertyValue(property.correctAnswers).includes(answer.id))} @change="${this._change}" aria-label="${this._getPropertyValue(property.correctAnswers).includes(answer.id) ? this.localize('practice:questions:answerCorrect', { text: answer.text }) : this.localize('practice:questions:answerIncorrect', { text: answer.text })}"> | ||
<div class="d2l-answer-content"> | ||
@@ -548,0 +548,0 @@ <d2l-input-textarea ?disabled=${disabled} data-property="${property.property}:${index}:text" data-type="textarea" .value="${live(this._getPropertyValue(`${property.property}:${index}:text`))}" placeholder="${answer.placeholder}" ?required="${property.required}" label-hidden label="${this.localize('practice:questions:answer')}" rows="2" @change="${this._change}"></d2l-input-textarea> |
@@ -511,3 +511,3 @@ import '@brightspace-ui/core/components/alert/alert-toast.js'; | ||
<div class="d2l-checkbox"> | ||
<input class="d2l-input-checkbox" type="checkbox" id="${answer.id}" data-property="${property.correctAnswers}" ?checked="${this.activityData.questions[0].correctAnswers.indexOf(answer.id) > -1}" @change="${this._change}" aria-label="${this._getPropertyValue(property.correctAnswers).includes(answer.id) ? this.localize('practice:questions:answerCorrect', { text: answer.text }) : this.localize('practice:questions:answerIncorrect', { text: answer.text })}"></d2l-input-checkbox> | ||
<input class="d2l-input-checkbox" type="checkbox" id="${answer.id}" data-property="${property.correctAnswers}" .checked="${this.activityData.questions[0].correctAnswers.indexOf(answer.id) > -1}" @change="${this._change}" aria-label="${this._getPropertyValue(property.correctAnswers).includes(answer.id) ? this.localize('practice:questions:answerCorrect', { text: answer.text }) : this.localize('practice:questions:answerIncorrect', { text: answer.text })}"></d2l-input-checkbox> | ||
</div> | ||
@@ -514,0 +514,0 @@ <div class="d2l-answer-content"> |
@@ -400,3 +400,3 @@ import '@brightspace-ui/core/components/alert/alert-toast.js'; | ||
<div class="d2l-answer"> | ||
<input class="d2l-input-checkbox" type="checkbox" id="${answer.id}" data-property="${property.correctAnswers}" ?checked=${live(this._getPropertyValue(property.correctAnswers).includes(answer.id))} @change="${this._change}" aria-label="${this._getPropertyValue(property.correctAnswers).includes(answer.id) ? this.localize('practice:questions:answerCorrect', { text: (answer.id === 0 ? this.localize('practice:trueFalse:true') : this.localize('practice:trueFalse:false')) }) : this.localize('practice:questions:answerIncorrect', { text: (answer.id === 0 ? this.localize('practice:trueFalse:true') : this.localize('practice:trueFalse:false')) })}"> | ||
<input class="d2l-input-checkbox" type="checkbox" id="${answer.id}" data-property="${property.correctAnswers}" .checked=${live(this._getPropertyValue(property.correctAnswers).includes(answer.id))} @change="${this._change}" aria-label="${this._getPropertyValue(property.correctAnswers).includes(answer.id) ? this.localize('practice:questions:answerCorrect', { text: (answer.id === 0 ? this.localize('practice:trueFalse:true') : this.localize('practice:trueFalse:false')) }) : this.localize('practice:questions:answerIncorrect', { text: (answer.id === 0 ? this.localize('practice:trueFalse:true') : this.localize('practice:trueFalse:false')) })}"> | ||
<label aria-hidden="true" for=${answer.id}>${(answer.id === 0 ? this.localize('practice:trueFalse:true') : this.localize('practice:trueFalse:false'))}</label> | ||
@@ -403,0 +403,0 @@ </div> |
{ | ||
"name": "@brightspace-ui/htmleditor", | ||
"description": "An HTML editor that integrates with Brightspace", | ||
"version": "2.75.5", | ||
"version": "2.75.6", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/BrightspaceUI/htmleditor.git", |
2260060
42076