aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/views/StyleProviderQuiz.tsx31
-rw-r--r--src/client/views/nodes/ComparisonBox.tsx18
2 files changed, 22 insertions, 27 deletions
diff --git a/src/client/views/StyleProviderQuiz.tsx b/src/client/views/StyleProviderQuiz.tsx
index db9ab831a..bcb4b4ec1 100644
--- a/src/client/views/StyleProviderQuiz.tsx
+++ b/src/client/views/StyleProviderQuiz.tsx
@@ -19,6 +19,7 @@ import { FieldViewProps } from './nodes/FieldView';
import { ImageBox } from './nodes/ImageBox';
import { ImageUtility } from './nodes/imageEditor/imageEditorUtils/ImageHandler';
import './StyleProviderQuiz.scss';
+import { Networking } from '../Network';
export namespace styleProviderQuiz {
enum quizMode {
@@ -46,7 +47,7 @@ export namespace styleProviderQuiz {
* @param texts
*/
async function createBoxes(img: ImageBox, boxes: [[[number, number]]], texts: [string]) {
- img.Document._quizBoxes = new List<Doc>([]);
+ img.Document.quizBoxes = new List<Doc>([]);
for (let i = 0; i < boxes.length; i++) {
const coords = boxes[i] ? boxes[i] : [];
const width = coords[1][0] - coords[0][0];
@@ -67,7 +68,7 @@ export namespace styleProviderQuiz {
newCol.forceActive = true;
newCol.quiz = text;
newCol[DocData][Doc.LayoutFieldKey(newCol) + '_transform'] = 'none';
- Doc.AddDocToList(img.Document, '_quizBoxes', newCol);
+ Doc.AddDocToList(img.Document, 'quizBoxes', newCol);
img.addDocument(newCol);
// img._loading = false;
}
@@ -85,21 +86,12 @@ export namespace styleProviderQuiz {
if (!quizBoxes.length) {
imgBox.Loading = true;
- const img = {
- file: i ? i : imgBox.paths[0],
- drag: i ? 'drag' : 'full',
- smart: quiz,
- };
- const response = await axios.post('http://localhost:105/labels/', img, {
- headers: {
- 'Content-Type': 'application/json',
- },
- });
- if (response.data['boxes'].length != 0) {
- createBoxes(imgBox, response.data['boxes'], response.data['text']);
- } else {
- imgBox.Loading = false;
+ const response = await Networking.PostToServer('/labels', { file: i ? i : imgBox.paths[0], drag: i ? 'drag' : 'full', smart: quiz });
+ const parsedResponse = JSON.parse(response.result.replace(/'/g, '"'));
+ if (parsedResponse['boxes'].length != 0) {
+ createBoxes(imgBox, parsedResponse['boxes'], parsedResponse['text']);
}
+ imgBox.Loading = false;
} else quizBoxes.forEach(box => (box.hidden = false));
}
@@ -254,6 +246,7 @@ export namespace styleProviderQuiz {
function check(img: ImageBox) {
//this._loading = true;
imgQuizBoxes(img).forEach(async doc => {
+ console.log(doc[DocData].title);
const input = StrCast(doc[DocData].title);
if (imgQuizMode(img) == quizMode.SMART && input) {
const questionText = 'Question: What was labeled in this image?';
@@ -271,7 +264,9 @@ export namespace styleProviderQuiz {
doc.backgroundColor = '#' + hexSent.hexNumber;
} else {
const match = compareWords(input, StrCast(doc.quiz).trim());
- doc.backgroundColor = match ? '#11c249' : '#eb2d2d';
+ if (input) {
+ doc.backgroundColor = match ? '#11c249' : '#eb2d2d';
+ }
}
});
//this._loading = false;
@@ -289,7 +284,7 @@ export namespace styleProviderQuiz {
*/
function exitQuizMode(img: ImageBox) {
img.Document._quizMode = quizMode.NONE;
- DocListCast(img.Document._quizBoxes).forEach(box => {
+ DocListCast(img.Document.quizBoxes).forEach(box => {
box.hidden = true;
});
}
diff --git a/src/client/views/nodes/ComparisonBox.tsx b/src/client/views/nodes/ComparisonBox.tsx
index 5315612e1..3067cd3e3 100644
--- a/src/client/views/nodes/ComparisonBox.tsx
+++ b/src/client/views/nodes/ComparisonBox.tsx
@@ -725,7 +725,7 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
/* renders front(qustion) and back(answer) at the same time, then on user input replaces the answer with a GPT analysis of the answer */
renderAsQuiz = (text: string) => (
- <div className={`comparisonBox${this._props.isContentActive() ? '-interactive' : ''}`}>
+ <div className={`comparisonBox${this._props.isContentActive() ? '-interactive' : ''}`} style={{ width: '80%', height: '93%' }}>
<p style={{ color: 'white', padding: 10 }}>{text}</p>
<p style={{ display: text === '' ? 'flex' : 'none', color: 'white', marginLeft: '10px' }}>Return to all flashcards and add text to both sides. </p>
<div className="input-box">
@@ -745,18 +745,18 @@ export class ComparisonBox extends ViewBoxAnnotatableComponent<FieldViewProps>()
</div>
<div>
<div className="submit-button">
- <div className="submit-buttonschema-header-button" onPointerDown={e => this.openContextMenu(e.clientX, e.clientY, false)}>
+ {/* <div className="submit-buttonschema-header-button" onPointerDown={e => this.openContextMenu(e.clientX, e.clientY, false)}>
<FontAwesomeIcon color="white" icon="caret-down" />
- </div>
- <button className="submit-buttonrecord" onClick={this._listening ? this.stopListening : this.startListening} style={{ background: this._listening ? 'lightgray' : '' }}>
+ </div> */}
+ {/* <button className="submit-buttonrecord" onClick={this._listening ? this.stopListening : this.startListening} style={{ background: this._listening ? 'lightgray' : '' }}>
{<FontAwesomeIcon icon="microphone" size="lg" />}
- </button>
- <div className="submit-buttonschema-header-button" onPointerDown={e => this.openContextMenu(e.clientX, e.clientY, true)} style={{ left: '50px', zIndex: '100' }}>
+ </button> */}
+ {/* <div className="submit-buttonschema-header-button" onPointerDown={e => this.openContextMenu(e.clientX, e.clientY, true)} style={{ left: '50px', zIndex: '100' }}>
<FontAwesomeIcon color="white" icon="caret-down" />
- </div>
- <button className="submit-buttonpronunciation" onClick={this.evaluatePronunciation}>
+ </div> */}
+ {/* <button className="submit-buttonpronunciation" onClick={this.evaluatePronunciation}>
Evaluate Pronunciation
- </button>
+ </button> */}
<button className="submit-buttonsubmit" type="button" onClick={this._renderSide === this.backKey ? () => this.animateFlipping(this.frontKey) : this.handleRenderGPTClick}>
{this._renderSide === this.backKey ? 'Redo the Question' : 'Submit'}
</button>