mirror of
				https://gitlab.com/MrFry/moodle-test-userscript
				synced 2025-04-01 20:22:48 +02:00 
			
		
		
		
	grab box answer getting
This commit is contained in:
		| @@ -39,6 +39,10 @@ | |||||||
| // @namespace    https://qmining.frylabs.net | // @namespace    https://qmining.frylabs.net | ||||||
| // @updateURL    https://qmining.frylabs.net/moodle-test-userscript/stable.user.js?up | // @updateURL    https://qmining.frylabs.net/moodle-test-userscript/stable.user.js?up | ||||||
| // ==/UserScript== | // ==/UserScript== | ||||||
|  | // | ||||||
|  | // TODO: | ||||||
|  | // test select boxes on result page | ||||||
|  | // dragboxes test on quiz page | ||||||
|  |  | ||||||
| (function() { // eslint-disable-line | (function() { // eslint-disable-line | ||||||
|   // GM functions, only to disable ESLINT errors |   // GM functions, only to disable ESLINT errors | ||||||
| @@ -670,6 +674,24 @@ | |||||||
|       return r |       return r | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     TestIfQuestionIsGrabBox (i) { | ||||||
|  |       if (logElementGetting) { Log('testing if question is grab-box') } | ||||||
|  |       let results = this.GetFormResult() // getting results element | ||||||
|  |       let t = results[i].getElementsByClassName('dragitems')[0].childNodes | ||||||
|  |       if (t.length !== 1) { Log('grab box drag items group length is not 1!') } | ||||||
|  |       let placedItems = t[0].getElementsByClassName('placed') | ||||||
|  |       let res = [] | ||||||
|  |       for (let i = 0; i < placedItems.length; i++) { | ||||||
|  |         let item = placedItems[i] | ||||||
|  |         res.push({ | ||||||
|  |           text: item.innerText, | ||||||
|  |           left: item.style.left, | ||||||
|  |           top: item.style.top | ||||||
|  |         }) | ||||||
|  |       } | ||||||
|  |       return res | ||||||
|  |     } | ||||||
|  |  | ||||||
|     GetRightAnswerIfCorrectShown (i) { |     GetRightAnswerIfCorrectShown (i) { | ||||||
|       if (logElementGetting) { Log('getting right answer if correct shown') } |       if (logElementGetting) { Log('getting right answer if correct shown') } | ||||||
|       var results = this.GetFormResult() // getting results element |       var results = this.GetFormResult() // getting results element | ||||||
| @@ -748,7 +770,12 @@ | |||||||
|  |  | ||||||
|       // "húzza oda ..." skip |       // "húzza oda ..." skip | ||||||
|       fun.push((i) => { |       fun.push((i) => { | ||||||
|         return undefined |         let temp = RPM.TestIfQuestionIsGrabBox(i) | ||||||
|  |         console.log('GRABBOX TEST') | ||||||
|  |         console.log(temp) | ||||||
|  |         return temp.map((x) => { | ||||||
|  |           return x.text | ||||||
|  |         }).join(', ') | ||||||
|       }) |       }) | ||||||
|  |  | ||||||
|       // the basic type of getting answers |       // the basic type of getting answers | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user