mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Changed content type sent to server #2
This commit is contained in:
parent
ac127afb99
commit
a524d9cdf5
1 changed files with 14 additions and 6 deletions
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Moodle/Elearning/KMOOC test help
|
// @name Moodle/Elearning/KMOOC test help
|
||||||
// @version 2.0.0.4
|
// @version 2.0.0.5
|
||||||
// @description Online Moodle/Elearning/KMOOC test help
|
// @description Online Moodle/Elearning/KMOOC test help
|
||||||
// @author MrFry
|
// @author MrFry
|
||||||
// @match https://elearning.uni-obuda.hu/main/*
|
// @match https://elearning.uni-obuda.hu/main/*
|
||||||
|
@ -58,8 +58,9 @@
|
||||||
|
|
||||||
var addEventListener // add event listener function
|
var addEventListener // add event listener function
|
||||||
const serverAdress = 'https://qmining.frylabs.net/'
|
const serverAdress = 'https://qmining.frylabs.net/'
|
||||||
const apiAdress = 'https://api.frylabs.net/'
|
|
||||||
// const serverAdress = 'http://localhost:8080/'
|
// const serverAdress = 'http://localhost:8080/'
|
||||||
|
const apiAdress = 'https://api.frylabs.net/'
|
||||||
|
// const apiAdress = 'http://localhost:8080/'
|
||||||
const ircAddress = 'https://kiwiirc.com/nextclient/irc.sub.fm/#qmining'
|
const ircAddress = 'https://kiwiirc.com/nextclient/irc.sub.fm/#qmining'
|
||||||
|
|
||||||
// forcing pages for testing. unless you test, do not set these to true!
|
// forcing pages for testing. unless you test, do not set these to true!
|
||||||
|
@ -978,7 +979,7 @@
|
||||||
sentData.id = GetId()
|
sentData.id = GetId()
|
||||||
sentData.quiz = quiz
|
sentData.quiz = quiz
|
||||||
console.log('SENT DATA', sentData)
|
console.log('SENT DATA', sentData)
|
||||||
SendXHRMessage('datatoadd=' + JSON.stringify(sentData)).then((res) => {
|
SendXHRMessage(JSON.stringify(sentData)).then((res) => {
|
||||||
next(res.success, sentData, res.newQuestions)
|
next(res.success, sentData, res.newQuestions)
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -1574,10 +1575,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function GetXHRInfos () {
|
function GetXHRInfos () {
|
||||||
|
const url = apiAdress +
|
||||||
|
'infos?version=true&motd=true&subjinfo=true&cversion=' +
|
||||||
|
info().script.version +
|
||||||
|
'&cid=' + GetId()
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
xmlhttpRequest({
|
xmlhttpRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: apiAdress + 'infos?version=true&motd=true&subjinfo=true&cversion=' + info().script.version,
|
url: url,
|
||||||
onload: function (response) {
|
onload: function (response) {
|
||||||
try {
|
try {
|
||||||
const res = JSON.parse(response.responseText)
|
const res = JSON.parse(response.responseText)
|
||||||
|
@ -1607,7 +1613,9 @@
|
||||||
}
|
}
|
||||||
params.push(key + '=' + encodeURIComponent(val))
|
params.push(key + '=' + encodeURIComponent(val))
|
||||||
})
|
})
|
||||||
url += params.join('&')
|
url += params.join('&') +
|
||||||
|
'&cversion=' + info().script.version +
|
||||||
|
'&cid=' + GetId()
|
||||||
|
|
||||||
xmlhttpRequest({
|
xmlhttpRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
@ -1651,7 +1659,7 @@
|
||||||
url: url,
|
url: url,
|
||||||
data: message,
|
data: message,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
onerror: function (e) {
|
onerror: function (e) {
|
||||||
Log('Data send error', e)
|
Log('Data send error', e)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue