Added texttype to Question objects
This commit is contained in:
Родитель
9d00d36a4b
Коммит
0e30061946
|
@ -17,5 +17,7 @@ namespace Assessment.App.Database.Model
|
||||||
public List<string> Options { get; set; }
|
public List<string> Options { get; set; }
|
||||||
|
|
||||||
public int Answer { get; set; }
|
public int Answer { get; set; }
|
||||||
|
|
||||||
|
public string TextType{get;set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,5 +10,7 @@ namespace Assessment.App.Functions.Student.Dto
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public List<string> Options { get; set; }
|
public List<string> Options { get; set; }
|
||||||
public int ChosenOption { get; set; }
|
public int ChosenOption { get; set; }
|
||||||
|
|
||||||
|
public string TextType{get;set;}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -131,6 +131,7 @@ namespace Assessment.App.Functions.Student
|
||||||
Description = item.Description,
|
Description = item.Description,
|
||||||
Options = item.Options,
|
Options = item.Options,
|
||||||
ChosenOption = chosenOption,
|
ChosenOption = chosenOption,
|
||||||
|
TextType=item.TextType
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,8 @@ namespace Assessment.App.Functions.Teacher
|
||||||
Name = questionItem.Name,
|
Name = questionItem.Name,
|
||||||
Options = questionItem.Options,
|
Options = questionItem.Options,
|
||||||
LastModified = DateTime.UtcNow,
|
LastModified = DateTime.UtcNow,
|
||||||
|
TextType = questionItem.TextType
|
||||||
|
|
||||||
});
|
});
|
||||||
return new OkObjectResult(new CreateQuestionResponse() {Id = id});
|
return new OkObjectResult(new CreateQuestionResponse() {Id = id});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import React from "react";
|
|
||||||
import {
|
import {
|
||||||
ChoiceGroup,
|
ChoiceGroup,
|
||||||
IChoiceGroupOption,
|
IChoiceGroupOption,
|
||||||
|
@ -15,6 +14,9 @@ import {Col, Container, Row} from "react-grid-system";
|
||||||
const optionRootClass = mergeStyles({display: 'flex', alignItems: 'baseline'});
|
const optionRootClass = mergeStyles({display: 'flex', alignItems: 'baseline'});
|
||||||
const textFieldStyles: Partial<ITextFieldStyles> = {fieldGroup: {width: 350}};
|
const textFieldStyles: Partial<ITextFieldStyles> = {fieldGroup: {width: 350}};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface EditQuestionComponentProps {
|
interface EditQuestionComponentProps {
|
||||||
question: Question;
|
question: Question;
|
||||||
setQuestion: (f: (oldValue: Question) => Question) => void;
|
setQuestion: (f: (oldValue: Question) => Question) => void;
|
||||||
|
@ -100,6 +102,24 @@ export const EditQuestionComponent = (
|
||||||
setQuestion(q => ({...q, description: newValue || ''}))
|
setQuestion(q => ({...q, description: newValue || ''}))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<br/>
|
||||||
|
<Row>
|
||||||
|
<Col md={2}>
|
||||||
|
<Label style={{textAlign: "left"}}>Text format</Label>
|
||||||
|
</Col>
|
||||||
|
<Col md={6}>
|
||||||
|
<TextField
|
||||||
|
id="textType-input"
|
||||||
|
rows={1}
|
||||||
|
value={question.textType}
|
||||||
|
onChange={(_: any, newValue?: string) =>
|
||||||
|
setQuestion(q => ({...q, textType: newValue || ''}))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
@ -3,12 +3,23 @@ import {StudentQuestion} from '../model/StudentQuestion';
|
||||||
import {ChoiceGroup, IChoiceGroupOption} from '@fluentui/react/lib/ChoiceGroup';
|
import {ChoiceGroup, IChoiceGroupOption} from '@fluentui/react/lib/ChoiceGroup';
|
||||||
import { Label } from "@fluentui/react";
|
import { Label } from "@fluentui/react";
|
||||||
import { getTheme } from '@fluentui/react';
|
import { getTheme } from '@fluentui/react';
|
||||||
|
import parse from 'html-react-parser';
|
||||||
|
|
||||||
interface StudentQuestionComponentProps {
|
interface StudentQuestionComponentProps {
|
||||||
question: StudentQuestion;
|
question: StudentQuestion;
|
||||||
selectedOption: number;
|
selectedOption: number;
|
||||||
setSelectedOption: (choice: number) => void;
|
setSelectedOption: (choice: number) => void;
|
||||||
}
|
}
|
||||||
|
var getDisplay = (x:string, texttype:string)=> {
|
||||||
|
console.log("text type is");
|
||||||
|
console.log(texttype);
|
||||||
|
if (texttype === "html" || texttype === "text/html"){
|
||||||
|
x = x.replaceAll('\\n','<br>')
|
||||||
|
return parse(x)
|
||||||
|
}
|
||||||
|
// Need to handle case where texttype is markdown
|
||||||
|
return x
|
||||||
|
}
|
||||||
|
|
||||||
export const StudentQuestionComponent = (
|
export const StudentQuestionComponent = (
|
||||||
{question, selectedOption, setSelectedOption}: StudentQuestionComponentProps
|
{question, selectedOption, setSelectedOption}: StudentQuestionComponentProps
|
||||||
|
@ -31,7 +42,8 @@ export const StudentQuestionComponent = (
|
||||||
<br/>
|
<br/>
|
||||||
<div style={{margin: '30px', textAlign: 'left'}}>
|
<div style={{margin: '30px', textAlign: 'left'}}>
|
||||||
<Label style={{textAlign: 'left', fontSize: '25px'}}>Question</Label>
|
<Label style={{textAlign: 'left', fontSize: '25px'}}>Question</Label>
|
||||||
<p>{question.description}</p>
|
<p>{getDisplay(question.description, question.textType)}</p>
|
||||||
|
{console.log(question)}
|
||||||
<ChoiceGroup
|
<ChoiceGroup
|
||||||
selectedKey={selectedOption.toString()}
|
selectedKey={selectedOption.toString()}
|
||||||
onChange={(_: any, option) => {
|
onChange={(_: any, option) => {
|
||||||
|
|
|
@ -188,6 +188,7 @@ export class FakeRepository implements IRepository {
|
||||||
lastModified: new Date(),
|
lastModified: new Date(),
|
||||||
options: ["True", "False"],
|
options: ["True", "False"],
|
||||||
answer: 0,
|
answer: 0,
|
||||||
|
textType:"text",
|
||||||
},
|
},
|
||||||
'1': {
|
'1': {
|
||||||
id: '1',
|
id: '1',
|
||||||
|
@ -200,6 +201,7 @@ export class FakeRepository implements IRepository {
|
||||||
"Deep learning is used in robots",
|
"Deep learning is used in robots",
|
||||||
],
|
],
|
||||||
answer: 1,
|
answer: 1,
|
||||||
|
textType:"text"
|
||||||
},
|
},
|
||||||
'2': {
|
'2': {
|
||||||
id: '2',
|
id: '2',
|
||||||
|
@ -212,6 +214,7 @@ export class FakeRepository implements IRepository {
|
||||||
"Both of the above",
|
"Both of the above",
|
||||||
],
|
],
|
||||||
answer: 2,
|
answer: 2,
|
||||||
|
textType:"text"
|
||||||
},
|
},
|
||||||
'3': {
|
'3': {
|
||||||
id: '3',
|
id: '3',
|
||||||
|
@ -225,6 +228,7 @@ export class FakeRepository implements IRepository {
|
||||||
"All of the above",
|
"All of the above",
|
||||||
],
|
],
|
||||||
answer: 3,
|
answer: 3,
|
||||||
|
textType:"text"
|
||||||
},
|
},
|
||||||
'4': {
|
'4': {
|
||||||
id: '4',
|
id: '4',
|
||||||
|
@ -238,6 +242,7 @@ export class FakeRepository implements IRepository {
|
||||||
"Software Models",
|
"Software Models",
|
||||||
],
|
],
|
||||||
answer: 1,
|
answer: 1,
|
||||||
|
textType:"text"
|
||||||
},
|
},
|
||||||
'5': {
|
'5': {
|
||||||
id: '5',
|
id: '5',
|
||||||
|
@ -251,6 +256,7 @@ export class FakeRepository implements IRepository {
|
||||||
"5",
|
"5",
|
||||||
],
|
],
|
||||||
answer: 2,
|
answer: 2,
|
||||||
|
textType:"text"
|
||||||
},
|
},
|
||||||
'6': {
|
'6': {
|
||||||
id: '6',
|
id: '6',
|
||||||
|
@ -264,6 +270,7 @@ export class FakeRepository implements IRepository {
|
||||||
"Self-regulation",
|
"Self-regulation",
|
||||||
],
|
],
|
||||||
answer: 0,
|
answer: 0,
|
||||||
|
textType:"text"
|
||||||
},
|
},
|
||||||
'7': {
|
'7': {
|
||||||
id: '7',
|
id: '7',
|
||||||
|
@ -277,6 +284,7 @@ export class FakeRepository implements IRepository {
|
||||||
"All of the above",
|
"All of the above",
|
||||||
],
|
],
|
||||||
answer: 3,
|
answer: 3,
|
||||||
|
textType:"text"
|
||||||
},
|
},
|
||||||
'8': {
|
'8': {
|
||||||
id: '8',
|
id: '8',
|
||||||
|
@ -290,6 +298,7 @@ export class FakeRepository implements IRepository {
|
||||||
"All of the above",
|
"All of the above",
|
||||||
],
|
],
|
||||||
answer: 3,
|
answer: 3,
|
||||||
|
textType:"text"
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,4 +5,5 @@ export interface Question {
|
||||||
lastModified: Date,
|
lastModified: Date,
|
||||||
options: string[],
|
options: string[],
|
||||||
answer: number,
|
answer: number,
|
||||||
|
textType:string,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,5 @@ export interface StudentQuestion {
|
||||||
description: string,
|
description: string,
|
||||||
options: string[],
|
options: string[],
|
||||||
chosenOption: number,
|
chosenOption: number,
|
||||||
|
textType:string,
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { parse, GIFTQuestion, TextChoice, TextFormat } from "gift-pegjs";
|
||||||
import { ParsedQuestionBank } from "./ParsedQuestionBank";
|
import { ParsedQuestionBank } from "./ParsedQuestionBank";
|
||||||
import { AssessmentAppParser } from "./Parser";
|
import { AssessmentAppParser } from "./Parser";
|
||||||
import { Question } from "../Question";
|
import { Question } from "../Question";
|
||||||
import * as React from "react";
|
|
||||||
|
|
||||||
// Currently only parses in MCQs and TFs
|
// Currently only parses in MCQs and TFs
|
||||||
export class GiftParser extends AssessmentAppParser{
|
export class GiftParser extends AssessmentAppParser{
|
||||||
|
@ -40,6 +39,7 @@ export class GiftParser extends AssessmentAppParser{
|
||||||
lastModified: new Date (),
|
lastModified: new Date (),
|
||||||
options: answerTexts,
|
options: answerTexts,
|
||||||
answer: correctAnswer,
|
answer: correctAnswer,
|
||||||
|
textType:stem.format
|
||||||
}
|
}
|
||||||
questions.push(question);
|
questions.push(question);
|
||||||
|
|
||||||
|
@ -51,10 +51,11 @@ export class GiftParser extends AssessmentAppParser{
|
||||||
const question: Question = {
|
const question: Question = {
|
||||||
id: "",
|
id: "",
|
||||||
name: this.removeTags(stem.text),
|
name: this.removeTags(stem.text),
|
||||||
description: this.removeTags(stem.text),
|
description: stem.text,
|
||||||
lastModified: new Date (),
|
lastModified: new Date (),
|
||||||
options: ["True", "False"],
|
options: ["True", "False"],
|
||||||
answer: ans? 0:1,
|
answer: ans? 0:1,
|
||||||
|
textType:stem.format
|
||||||
}
|
}
|
||||||
questions.push(question);
|
questions.push(question);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@ export class MicrosoftOSCParser extends AssessmentAppParser{
|
||||||
var answerTexts = Array();
|
var answerTexts = Array();
|
||||||
var correctAnswer = 0;
|
var correctAnswer = 0;
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
console.log("Read a new question");
|
|
||||||
console.log(question.questionText);
|
|
||||||
for (let option of question.answerOptions){
|
for (let option of question.answerOptions){
|
||||||
answerTexts.push(option.answerText)
|
answerTexts.push(option.answerText)
|
||||||
if (option.isCorrect == "true"){
|
if (option.isCorrect == "true"){
|
||||||
|
@ -35,6 +33,7 @@ export class MicrosoftOSCParser extends AssessmentAppParser{
|
||||||
lastModified: new Date (),
|
lastModified: new Date (),
|
||||||
options: answerTexts,
|
options: answerTexts,
|
||||||
answer: correctAnswer,
|
answer: correctAnswer,
|
||||||
|
textType:"text"
|
||||||
}
|
}
|
||||||
questions.push(questionToSave);
|
questions.push(questionToSave);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ export class OriginalAppParser extends AssessmentAppParser{
|
||||||
lastModified: new Date (),
|
lastModified: new Date (),
|
||||||
options: rawQuestion.options,
|
options: rawQuestion.options,
|
||||||
answer: rawQuestion.answer,
|
answer: rawQuestion.answer,
|
||||||
|
textType: rawQuestion.textType
|
||||||
}
|
}
|
||||||
questions.push(question);
|
questions.push(question);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ export class QTIParser extends AssessmentAppParser{
|
||||||
continue; // As we currently only support MCQs
|
continue; // As we currently only support MCQs
|
||||||
}
|
}
|
||||||
var questionText = currQuestion['presentation']['material']['mattext']['#text'];
|
var questionText = currQuestion['presentation']['material']['mattext']['#text'];
|
||||||
questionText = this.removeTags(questionText); // Clean any html tags
|
|
||||||
questionText = questionText.split('\n')[1];
|
questionText = questionText.split('\n')[1];
|
||||||
|
|
||||||
// Get all options
|
// Get all options
|
||||||
|
@ -48,6 +47,7 @@ export class QTIParser extends AssessmentAppParser{
|
||||||
lastModified: new Date (),
|
lastModified: new Date (),
|
||||||
options: answerTexts,
|
options: answerTexts,
|
||||||
answer: correctAnswer,
|
answer: correctAnswer,
|
||||||
|
textType:currQuestion['presentation']['material']['mattext']['@_texttype'],
|
||||||
}
|
}
|
||||||
questions.push(question);
|
questions.push(question);
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ export const NewQuestionPage = () => {
|
||||||
lastModified: new Date(),
|
lastModified: new Date(),
|
||||||
options: ['', ''],
|
options: ['', ''],
|
||||||
answer: -1,
|
answer: -1,
|
||||||
|
textType:""
|
||||||
});
|
});
|
||||||
const {bankId} = useParams<NewQuestionPageParams>();
|
const {bankId} = useParams<NewQuestionPageParams>();
|
||||||
const repositoryContext = React.useContext(RepositoryContext);
|
const repositoryContext = React.useContext(RepositoryContext);
|
||||||
|
|
|
@ -23,6 +23,7 @@ export const QuestionPage = () => {
|
||||||
lastModified: new Date(),
|
lastModified: new Date(),
|
||||||
options: ['', ''],
|
options: ['', ''],
|
||||||
answer: -1,
|
answer: -1,
|
||||||
|
textType:"text"
|
||||||
});
|
});
|
||||||
const [savedQuestion, setSavedQuestion] = useState<Question>({
|
const [savedQuestion, setSavedQuestion] = useState<Question>({
|
||||||
id: "",
|
id: "",
|
||||||
|
@ -31,6 +32,7 @@ export const QuestionPage = () => {
|
||||||
lastModified: new Date(),
|
lastModified: new Date(),
|
||||||
options: ['', ''],
|
options: ['', ''],
|
||||||
answer: -1,
|
answer: -1,
|
||||||
|
textType:"text"
|
||||||
})
|
})
|
||||||
const {id} = useParams<QuestionPageParams>();
|
const {id} = useParams<QuestionPageParams>();
|
||||||
const repositoryContext = React.useContext(RepositoryContext);
|
const repositoryContext = React.useContext(RepositoryContext);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче