diff options
| author | bobzel <zzzman@gmail.com> | 2024-10-07 21:47:05 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2024-10-07 21:47:05 -0400 |
| commit | 504b8059ff4e162e089177e366a312dd583d5cff (patch) | |
| tree | 9cda666d7a5249ffda5e8c86e77ba9526053bd15 /src/client/views/StyleProviderQuiz.tsx | |
| parent | 11244a698bce594982ee5dca55b9695bb774451c (diff) | |
moved some more quiz functions to styleProviderQuiz
Diffstat (limited to 'src/client/views/StyleProviderQuiz.tsx')
| -rw-r--r-- | src/client/views/StyleProviderQuiz.tsx | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/client/views/StyleProviderQuiz.tsx b/src/client/views/StyleProviderQuiz.tsx index 8973ada95..1f2ad1485 100644 --- a/src/client/views/StyleProviderQuiz.tsx +++ b/src/client/views/StyleProviderQuiz.tsx @@ -83,7 +83,7 @@ export namespace styleProviderQuiz { imgBox.Document._quizMode = quiz; const quizBoxes = DocListCast(imgBox.Document.quizBoxes); if (!quizBoxes.length) { - // this._loading = true; + imgBox.Loading = true; const img = { file: i ? i : imgBox.paths[0], @@ -98,7 +98,7 @@ export namespace styleProviderQuiz { if (response.data['boxes'].length != 0) { createBoxes(imgBox, response.data['boxes'], response.data['text']); } else { - // this._loading = false; + imgBox.Loading = false; } } else quizBoxes.forEach(box => (box.hidden = false)); } @@ -121,7 +121,7 @@ export namespace styleProviderQuiz { * Create flashcards from an image. */ async function getImageDesc(img: ImageBox) { - // this._loading = true; + img.Loading = true; try { const hrefBase64 = await createCanvas(img); const response = await gptImageLabel(hrefBase64, 'Make flashcards out of this image with each question and answer labeled as "question" and "answer". Do not label each flashcard and do not include asterisks: '); @@ -129,7 +129,7 @@ export namespace styleProviderQuiz { } catch (error) { console.log('Error', error); } - // this._loading = false; + img.Loading = false; } /** @@ -241,14 +241,21 @@ export namespace styleProviderQuiz { return { error: 'The input string does not match the expected format.' }; } } + function imgQuizBoxes(img: ImageBox) { + return DocListCast(img.Document.quizBoxes); + } + function imgQuizMode(img: ImageBox) { + return StrCast(img.Document._quizMode); + } + /** * Check whether the contents of the label boxes on an image are correct. */ function check(img: ImageBox) { //this._loading = true; - img.quizBoxes.forEach(async doc => { + imgQuizBoxes(img).forEach(async doc => { const input = StrCast(doc[DocData].title); - if (img.quizMode == quizMode.SMART && input) { + if (imgQuizMode(img) == quizMode.SMART && input) { const questionText = 'Question: What was labeled in this image?'; const rubricText = ' Rubric: ' + StrCast(doc.quiz); const queryText = @@ -271,7 +278,7 @@ export namespace styleProviderQuiz { } function redo(img: ImageBox) { - img.quizBoxes.forEach(doc => { + imgQuizBoxes(img).forEach(doc => { doc[DocData].title = ''; doc.backgroundColor = '#e4e4e4'; }); |
