mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Merge branch 'JSON_Post'
This commit is contained in:
commit
cc8de2e15f
1 changed files with 11 additions and 4 deletions
|
@ -1019,7 +1019,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) {
|
||||||
|
@ -1623,9 +1623,14 @@
|
||||||
|
|
||||||
if (now > lastCheck + (infoExpireTime * 1000)) {
|
if (now > lastCheck + (infoExpireTime * 1000)) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
const url = apiAdress +
|
||||||
|
'infos?version=true&motd=true&subjinfo=true&cversion=' +
|
||||||
|
info().script.version +
|
||||||
|
'&cid=' + GetId()
|
||||||
|
|
||||||
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 {
|
||||||
setVal('lastInfoCheckTime', now)
|
setVal('lastInfoCheckTime', now)
|
||||||
|
@ -1668,7 +1673,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',
|
||||||
|
@ -1712,7 +1719,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