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:
		| @@ -315,8 +315,8 @@ | ||||
|     }) | ||||
|  | ||||
|     getQuizData() | ||||
|       .then(res => { | ||||
|         if (res.length === 0) { | ||||
|       .then(readQuestions => { | ||||
|         if (readQuestions.length === 0) { | ||||
|           ShowMessage( | ||||
|             { | ||||
|               m: texts.unableToParseTestQuestion, | ||||
| @@ -332,47 +332,30 @@ | ||||
|           return | ||||
|         } | ||||
|  | ||||
|         const promises = [] | ||||
|         res.forEach(question => { | ||||
|           const questionObj = { | ||||
|             q: question.question, | ||||
|         const questions = readQuestions.map(question => { | ||||
|           return { | ||||
|             Q: question.question, | ||||
|             data: question.data, | ||||
|             subj: getCurrentSubjectName(), | ||||
|           } | ||||
|           promises.push( | ||||
|             new Promise(resolve => { | ||||
|               GetXHRQuestionAnswer(questionObj).then(res => { | ||||
|                 resolve({ | ||||
|                   answers: res, | ||||
|                   question: question, | ||||
|                 }) | ||||
|               }) | ||||
|             }) | ||||
|           ) | ||||
|         }) | ||||
|  | ||||
|         // const questions = res.map(question => { | ||||
|         //   return { | ||||
|         //     q: question.question, | ||||
|         //     data: question.data, | ||||
|         //     subj: getCurrentSubjectName(), | ||||
|         //   } | ||||
|         // }) | ||||
|  | ||||
|         // 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 => { | ||||
|         post('ask', { | ||||
|           questions: questions, | ||||
|           subj: getCurrentSubjectName(), | ||||
|           location: location.href, | ||||
|           version: info().script.version, | ||||
|           cid: cid, | ||||
|           uid: uid, | ||||
|         }).then(results => { | ||||
|           removeLoadingMessage() | ||||
|           ShowAnswers(results) | ||||
|           ShowAnswers( | ||||
|             results.map((res, i) => { | ||||
|               return { | ||||
|                 answers: res.answers, | ||||
|                 question: readQuestions[i], | ||||
|               } | ||||
|             }) | ||||
|           ) | ||||
|         }) | ||||
|       }) | ||||
|       .catch(err => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user