mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
POST-ing to /ask
This commit is contained in:
parent
82b1bd075c
commit
0140095322
1 changed files with 21 additions and 38 deletions
|
@ -315,8 +315,8 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
getQuizData()
|
getQuizData()
|
||||||
.then(res => {
|
.then(readQuestions => {
|
||||||
if (res.length === 0) {
|
if (readQuestions.length === 0) {
|
||||||
ShowMessage(
|
ShowMessage(
|
||||||
{
|
{
|
||||||
m: texts.unableToParseTestQuestion,
|
m: texts.unableToParseTestQuestion,
|
||||||
|
@ -332,47 +332,30 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const promises = []
|
const questions = readQuestions.map(question => {
|
||||||
res.forEach(question => {
|
return {
|
||||||
const questionObj = {
|
Q: question.question,
|
||||||
q: question.question,
|
|
||||||
data: question.data,
|
data: question.data,
|
||||||
subj: getCurrentSubjectName(),
|
|
||||||
}
|
}
|
||||||
promises.push(
|
|
||||||
new Promise(resolve => {
|
|
||||||
GetXHRQuestionAnswer(questionObj).then(res => {
|
|
||||||
resolve({
|
|
||||||
answers: res,
|
|
||||||
question: question,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// const questions = res.map(question => {
|
post('ask', {
|
||||||
// return {
|
questions: questions,
|
||||||
// q: question.question,
|
subj: getCurrentSubjectName(),
|
||||||
// data: question.data,
|
location: location.href,
|
||||||
// subj: getCurrentSubjectName(),
|
version: info().script.version,
|
||||||
// }
|
cid: cid,
|
||||||
// })
|
uid: uid,
|
||||||
|
}).then(results => {
|
||||||
// console.log(questions)
|
|
||||||
// post('ask', {
|
|
||||||
// questions: questions,
|
|
||||||
// location: location.href,
|
|
||||||
// version: info().script.version,
|
|
||||||
// cid: cid,
|
|
||||||
// uid: uid,
|
|
||||||
// }).then(results => {
|
|
||||||
// console.log('RES')
|
|
||||||
// console.log(results)
|
|
||||||
|
|
||||||
Promise.all(promises).then(results => {
|
|
||||||
removeLoadingMessage()
|
removeLoadingMessage()
|
||||||
ShowAnswers(results)
|
ShowAnswers(
|
||||||
|
results.map((res, i) => {
|
||||||
|
return {
|
||||||
|
answers: res.answers,
|
||||||
|
question: readQuestions[i],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue