fixed moodle logic

This commit is contained in:
PxlLoewe
2025-06-26 13:40:33 -07:00
parent 8968bff1c5
commit 22a406c2d1
13 changed files with 127 additions and 95 deletions

View File

@@ -4,8 +4,12 @@ export const getMoodleUserById = async (id: string) => {
const { data: user } = await axios.get(
`${process.env.NEXT_PUBLIC_MOODLE_URL}/webservice/rest/server.php`,
{
auth: {
username: "moodleuser",
password: "Xo1SXaLYBa7Yb6WW",
},
params: {
wstoken: process.env.MOODLE_TOKEN,
wstoken: process.env.MOODLE_API_TOKEN,
wsfunction: "core_user_get_users_by_field",
moodlewsrestformat: "json",
field: "idnumber",
@@ -33,8 +37,12 @@ export const getMoodleQuizResult = async (userId: string, quizId: string) => {
const { data: quizzes } = await axios.get(
`${process.env.NEXT_PUBLIC_MOODLE_URL}/webservice/rest/server.php`,
{
auth: {
username: "moodleuser",
password: "Xo1SXaLYBa7Yb6WW",
},
params: {
wstoken: process.env.MOODLE_TOKEN,
wstoken: process.env.MOODLE_API_TOKEN,
wsfunction: "mod_quiz_get_user_attempts",
moodlewsrestformat: "json",
quizid: quizId,
@@ -49,8 +57,12 @@ export const getMoodleCourseCompletionStatus = async (userId: string, courseId:
const { data: completionStatus } = await axios.get(
`${process.env.NEXT_PUBLIC_MOODLE_URL}/webservice/rest/server.php`,
{
auth: {
username: "moodleuser",
password: "Xo1SXaLYBa7Yb6WW",
},
params: {
wstoken: process.env.MOODLE_TOKEN,
wstoken: process.env.MOODLE_API_TOKEN,
wsfunction: "core_completion_get_course_completion_status",
moodlewsrestformat: "json",
userid: userId,