Empty question fix

This commit is contained in:
mrfry 2021-01-14 17:10:30 +01:00
parent 09a04c4ae7
commit b5d5f20b79
6 changed files with 284 additions and 31 deletions

View file

@ -0,0 +1,48 @@
{
"subj": "2020/21/1 - Digitális rendszerek - NIXDR0HBNE/DR0_EA",
"version": "2.0.1.13",
"id": "0347000752702",
"quiz": [
{
"Q": "\n",
"A": "A helyes válasz: Bináris lefele számláló.",
"data": {
"type": "image",
"images": [
"wHFd9y6nWIHCAAAAABJRU5ErkJggg="
]
}
},
{
"Q": "\n",
"A": "D.\n\njobbra létető regiszter\n",
"data": {
"type": "image",
"images": [
"AcLnpIDsSgLsAAAAAElFTkSuQmCC"
]
}
},
{
"Q": "A regiszter feladata\n",
"A": "A.\n\nvezérlési feladatok\n",
"data": {
"type": "simple"
}
},
{
"Q": "A regiszter feladata\n",
"A": "D.\n\nÁtmeneti tárolás\n",
"data": {
"type": "simple"
}
},
{
"Q": "signal d : STD_LOGIC_VECTOR(3 downto 0);\n\nsignal q : STD_LOGIC_VECTOR(3 downto 0);\n\nsignal clk: STD_LOGIC;\n\n…\n\nprocess\n\nBegin\n\n  if (clear = 1) then\n\n  q <= ”0000”;\n\n  elsif (clk`event and clk = 1) then\n   q <= d;\nend if;\n\nend process;\n\n\n",
"A": "B.\n\ntároló regiszter\n",
"data": {
"type": "simple"
}
}
]
}

View file

@ -0,0 +1,78 @@
{
"subj": "2020/21/1 - Pénzügyek alapjai - GGEPU1GFNE/PA-GY2",
"version": "2.0.1.18",
"id": "0672665270899",
"location": "https://elearning.uni-obuda.hu/asd",
"quiz": [
{
"Q": "540.000 Ft-ot elhelyezünk bankbetét formájában 30 napra 18%-os kamatláb mellett. Az év napjait 365-tel számolja. Mekkora lesz a kamatjövedelem, amit felvehetünk a betétünk után (kerekítve)?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "Önnek 3 év múlva 3.000.000 Ft-ra lesz szüksége. Mennyi pénzt helyezzen el ma ahhoz 12% kamatláb mellett, hogy ezt a tervét megvalósítsa, ha a bank a kamatokat négy havonta tőkésíti?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "Egy kereskedelmi bank évi 6% betéti kamatot ajánl, a kamatok félévenkénti tőkésítése mellett. Hány forintot kellene „ma” elhelyezni, ha azt szeretnénk, hogy 10 év múlva 20.000.000 Ft-unk legyen?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "Hány forinttal rendelkeznénk 2,5 év múlva, ha ma elhelyeznénk 500.000 Ft-ot és a bank a kamatokat havonta tőkésítené 12%-os kamatláb mellett?\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "Bankbetét formájában elhelyezünk 90.000 Ft-ot 3 évre, 14%-os kamatra. Mennyi pénzünk lesz három év múlva, ha a bank kamatos kamattal számol?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "300.000 Ft-ot helyezünk el a számlánkon lekötött betét formájában 16%-os kamatláb mellett két évre negyedéves tőkésítés mellett. Mekkora összeggel rendelkezünk a befektetés lejártakor?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "Mennyi pénz lesz 900.000 Ft-ból 3 év alatt 15%-os kamatláb esetén, ha a kamatok tőkésítésére nem kerül sor a futamidő alatt?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "200.000 Ft-ot szeretne elhelyezni 10%-os kamatláb mellett a bankba féléves tőkésítés mellett. Mekkora összeget vehet fel egy év múlva?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "Hány forintunk lenne a bankszámlán 25 év múlva, ha ma elhelyezünk 250.000 Ft-on a bankszámlán, és a bank évi 4%-os kamatot ígér, félévenkénti tőkésítéssel?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "Mennyi pénzt helyezzünk el ma bankbetét formájában, ha azt szeretnénk, hogy négy év múlva 220.000 Ft-unk legyen 8% kamatláb mellett?\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
}
]
}

View file

@ -0,0 +1,96 @@
{
"subj": "2020/21/1 - Pénzügyek alapjai - GGEPU1GFNE/PA-GY2",
"version": "2.0.1.18",
"id": "0672665270899",
"location": "https://elearning.uni-obuda.hu/asd",
"quiz": [
{
"Q": "",
"A": "",
"data": {
"type": "simple"
}
},
{
"Q": "\n\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "",
"A": "\n\n\n\n",
"data": {
"type": "simple"
}
},
{
"Q": "\n\n\n\n",
"A": "",
"data": {
"type": "simple"
}
},
{
"Q": "",
"A": "",
"data": {
"type": "image",
"images": [
"Cu_Ag.jpg"
]
}
},
{
"Q": "\n\n\n\n",
"A": "\n\n\n\n",
"data": {
"type": "image",
"images": [
"Cu_Ag.jpg"
]
}
},
{
"Q": "",
"A": "\n\n\n\n",
"data": {
"type": "image",
"images": [
"Cu_Ag.jpg"
]
}
},
{
"Q": "\n\n\n\n",
"A": "",
"data": {
"type": "image",
"images": [
"Cu_Ag.jpg"
]
}
},
{
"Q": "This should be valid",
"A": "\n\n\n\n",
"data": {
"type": "image",
"images": [
"Cu_Ag.jpg"
]
}
},
{
"Q": "This should be valid",
"A": "",
"data": {
"type": "image",
"images": [
"Cu_Ag.jpg"
]
}
}
]
}

View file

@ -0,0 +1,14 @@
{
"subj": "2020/21/1 - Digitális rendszerek - AMXDR0IBNE/E",
"version": "2.0.1.13",
"id": "1586202966729",
"quiz": [
{
"Q": "Adott egy háromváltozós függvény, amely akkor 0 értékű, ha a 3 változóból legalább 2, 0 értékű. Válassza ki  a konjunktív kanonikus alakban szereplő maxtermeket amelyek ÉS kapcsolata adja az Y függvényt!",
"A": "A helyes válaszok: nC+B+A, C+nB+A, C+B+nA, C+B+A",
"data": {
"type": "simple"
}
}
]
}

View file

@ -97,7 +97,7 @@ export function processIncomingRequest(
dryRun: boolean, dryRun: boolean,
user: User user: User
): Promise<Array<Result>> { ): Promise<Array<Result>> {
logger.DebugLog('Processing incoming request', 'actions', 1) logger.DebugLog('Processing incoming request', 'isadding', 1)
if (recievedData === undefined) { if (recievedData === undefined) {
logger.Log('\tRecieved data is undefined!', logger.GetColor('redbg')) logger.Log('\tRecieved data is undefined!', logger.GetColor('redbg'))
@ -116,7 +116,7 @@ export function processIncomingRequest(
towrite += towrite +=
'\n------------------------------------------------------------------------------\n' '\n------------------------------------------------------------------------------\n'
utils.AppendToFile(towrite, recDataFile) utils.AppendToFile(towrite, recDataFile)
logger.DebugLog('recDataFile written', 'actions', 1) logger.DebugLog('recDataFile written', 'isadding', 1)
} catch (err) { } catch (err) {
logger.Log('Error writing recieved data.') logger.Log('Error writing recieved data.')
} }
@ -147,13 +147,13 @@ function processIncomingRequestUsingDb(
try { try {
const recievedQuestions = [] const recievedQuestions = []
logger.DebugLog('recievedData JSON parsed', 'actions', 1) logger.DebugLog('recievedData JSON parsed', 'isadding', 1)
logger.DebugLog(recievedData, 'actions', 3) logger.DebugLog(recievedData, 'isadding', 3)
const allQLength = recievedData.quiz.length const allQLength = recievedData.quiz.length
const questionSearchPromises = [] const questionSearchPromises = []
recievedData.quiz.forEach((question) => { recievedData.quiz.forEach((question) => {
logger.DebugLog('Question:', 'actions', 2) logger.DebugLog('Question:', 'isadding', 2)
logger.DebugLog(question, 'actions', 2) logger.DebugLog(question, 'isadding', 2)
const currentQuestion = createQuestion( const currentQuestion = createQuestion(
question.Q, question.Q,
question.A, question.A,
@ -161,10 +161,11 @@ function processIncomingRequestUsingDb(
) )
logger.DebugLog( logger.DebugLog(
'Searching for question in subj ' + recievedData.subj, 'Searching for question in subj ' + recievedData.subj,
'actions', 'isadding',
3 3
) )
logger.DebugLog(currentQuestion, 'actions', 3) logger.DebugLog(currentQuestion, 'isadding', 3)
if (isQuestionValid(currentQuestion)) {
recievedQuestions.push(currentQuestion) recievedQuestions.push(currentQuestion)
// This here searches only in relevant subjects, and not all subjects // This here searches only in relevant subjects, and not all subjects
questionSearchPromises.push( questionSearchPromises.push(
@ -179,6 +180,10 @@ function processIncomingRequestUsingDb(
}, },
}) })
) )
} else {
logger.DebugLog('Question isnt valid', 'isadding', 1)
logger.DebugLog(currentQuestion, 'isadding', 1)
}
}) })
Promise.all(questionSearchPromises) Promise.all(questionSearchPromises)
@ -199,22 +204,22 @@ function processIncomingRequestUsingDb(
const sName = getSubjNameWithoutYear(recievedData.subj) const sName = getSubjNameWithoutYear(recievedData.subj)
logger.DebugLog( logger.DebugLog(
'Adding question with subjName: ' + sName + ' :', 'Adding question with subjName: ' + sName + ' :',
'actions', 'isadding',
3 3
) )
logger.DebugLog(currentQuestion, 'actions', 3) logger.DebugLog(currentQuestion, 'isadding', 3)
addQuestion(qdb.data, sName, currentQuestion) addQuestion(qdb.data, sName, currentQuestion)
}) })
currWrites++ currWrites++
logger.DebugLog( logger.DebugLog(
'currWrites for data.json: ' + currWrites, 'currWrites for data.json: ' + currWrites,
'actions', 'isadding',
1 1
) )
if (currWrites >= writeAfter && !dryRun) { if (currWrites >= writeAfter && !dryRun) {
currWrites = 0 currWrites = 0
logger.DebugLog('Writing data.json', 'actions', 1) logger.DebugLog('Writing data.json', 'isadding', 1)
utils.WriteFile(JSON.stringify(qdb.data), qdb.path) utils.WriteFile(JSON.stringify(qdb.data), qdb.path)
} }
} }
@ -226,10 +231,10 @@ function processIncomingRequestUsingDb(
allQLength allQLength
) )
logger.DebugLog('New Questions:', 'actions', 2) logger.DebugLog('New Questions:', 'isadding', 2)
logger.DebugLog(allQuestions, 'actions', 2) logger.DebugLog(allQuestions, 'isadding', 2)
logger.DebugLog('ProcessIncomingRequest done', 'actions', 1) logger.DebugLog('ProcessIncomingRequest done', 'isadding', 1)
resolve({ resolve({
newQuestions: allQuestions.length, newQuestions: allQuestions.length,
qdbName: qdb.name, qdbName: qdb.name,
@ -263,6 +268,16 @@ function processIncomingRequestUsingDb(
}) })
} }
function isQuestionValid(question: Question) {
if (!question.Q) {
return false
}
if (!question.Q && question.data.type !== 'image') {
return false
}
return true
}
export function shouldSearchDataFile(df: DataFile, testUrl: string): Boolean { export function shouldSearchDataFile(df: DataFile, testUrl: string): Boolean {
if (typeof df.shouldSearch === 'string' && df.shouldSearch === 'always') { if (typeof df.shouldSearch === 'string' && df.shouldSearch === 'always') {
return true return true

View file

@ -126,7 +126,9 @@ function compareString(string1: string, string2: string) {
} }
function answerPreProcessor(value: string) { function answerPreProcessor(value: string) {
assert(value) if (!value) {
return value
}
return removeStuff(value, commonUselessAnswerParts) return removeStuff(value, commonUselessAnswerParts)
} }
@ -208,7 +210,7 @@ function createQuestion(
): Question { ): Question {
return { return {
Q: simplifyQuestion(question), Q: simplifyQuestion(question),
A: answer ? simplifyAnswer(answer) : null, A: answer ? simplifyAnswer(answer) : undefined,
data: data, data: data,
} }
} }