Skip to content

Commit

Permalink
Dev (#25)
Browse files Browse the repository at this point in the history
* delete workflow

* add: component user card

* add: component label

* add: moleculs discussItem

* add: page discuss and update userCard

* add: filter discuss

* add: component add discuss

* refactor: integrate to backend add discuss

* refactor: integrate to backend discussItem

* refactor: add mutate add discuss

* refactor: integrate discuss item to backend and fix vote

* ref: filter discuss

* Feature/discustions (#4)

* feature:create discustions :sprakles:

* feature: vote and update status discustion :sprakles:

* feature: comments ✨

* feature: bookmark :sprakles:

* feat:filter and sort discustion ✨

* bug:fix bug filter use 🐛

* fix: file change upi

* fix: useSWR

* feat: add comment

* feat: Reply Comments

* fix: discuss item & add discuss

* feat: bookmark discussion

* refactor : change filterby

* fix: fix bookmark & ux in interact discuss

* feat: share discussion

* feat: create mutateSWRPartialKey

* feat: add duration and deadline of quiz :sprakles:

* feat: filter discussion & fix useSWR

* feat: add photo in comments

* add seeder

* feat: quiz duration, quiz deadline, quiz navigation, quiz per page

* feat: landing page welcome

* feat: Login Page

* feat: re-design header & sidebar

* feature:setting project ✨

* feat:add contact ✨

* Feat/review quiz user (#7)

* feat:review quiz ✨

* feat: add start at on quiz created ✨

* feat: change color by settings

* feat: header footer for settings

* feat: uploud drag & drop

* feat: page settings

* feat: Add Zustand dependency for state management

* feat: Update all components to set by settings

* fix: update settings

* fix: default components

* Ref/quiz schema (#8)

* ref:Quiz Schema ♻️

* remove console.log

* feat: Update site name to "EduClass.AI"

* bugfix:question format update 🐛 (#10)

* ref:remove class and add import for datamaster

* feat: add import with excel

* feat: Add file upload component for importing data

* chore: Refactor create course page

* fix: button NextLink

* fix: create quest performance

* fix: choice input form

* fix: fix input lag choice input

* fix: multiple and choice answer

* fix: bug discussion

* bugfix import data master

* cleanup

* feat: create quiz

* ref: add questions on quiz detail

* fix: remove quiz type on create

* handle error

* post data

* feat: slicing quiz review

* feat: setup user quiz fetcher

* refactor: Update course and user routes to handle new data structure

* fix: create quiz choice and type not expected

* feat: do a quiz

* fix: link

* feat: Calculate total points for quiz submission

* fix: uploud document import

* refactor: Add file upload functionality to route.ts

* fix: fix object title for quiz item essay

* setup quiz generator

* feat: setup generate quiz fetch

* feat: generate quiz

* chore: Remove commented out code and unused Azure-related fields

* chore: Remove commented out code and unused Azure-related fields (#15)

* chore: Remove unused Azure-related fields and code

* Dev (#16)

* chore: Remove commented out code and unused Azure-related fields

* chore: Remove unused Azure-related fields and code

* fix: chatbot features

* chore: dynamic course class

* feat: Update resource upload process

The resource upload process has been updated to use the file URL instead of the file itself. This change improves the efficiency of the upload process and reduces unnecessary file handling.

* chore: Update resource upload process to include callback URL

* fix: disable button non used

* chore: Update @azure/storage-blob dependency to version 12.17.0

* fix: fetch api with env

* fix: reply comments

* add: loading skeleton discuss

* feat: Add status and error message to course API response

This commit adds the `status` and `error_message` fields to the course API response. This will provide additional information about the status and any error messages associated with the course.

* chore: Update deployment directory to educlass_v2

* fix: logo-brand and try catch discuss

* chore: update tailwindcss version

* chore: update postcss version

* feat: add status uploud rag & alert start quiz

* chore: change header to general app

* Update educlass.yml

* fix: header and color

* refactor: Improve user quiz retrieval and scoring logic

---------

Co-authored-by: FajarWG <[email protected]>
Co-authored-by: FajarWG <[email protected]>
Co-authored-by: ichsnn <[email protected]>
Co-authored-by: “FajarWG” <“[email protected]“>
Co-authored-by: “Reymunda” <“[email protected]“>
Co-authored-by: Ichsan Nulmuhlis <[email protected]>
  • Loading branch information
7 people authored Jul 26, 2024
1 parent fc15ad5 commit 8eacd4f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
32 changes: 31 additions & 1 deletion app/api/quiz/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function POST(req: Request, { params }: any) {
quiz_id: +id
}
})
if (isAlreadyAnswered) return getResponse(null, "user already answered this quiz", 400)
// if (isAlreadyAnswered) return getResponse(null, "user already answered this quiz", 400)
const quiz = await prisma.quiz.findUnique({
where: {
id: +id
Expand Down Expand Up @@ -96,10 +96,40 @@ export async function GET(req: Request, { params }: any) {
user_quiz: {
where: {
user_id: session?.id
},
include: {
users: {
select: {
name: true,
username: true,
id: true
}
},
}
},
questions:true
},
})
if (!quiz) return getResponse(null, 'quiz not found', 404);
const userQuizMapped = quiz.user_quiz.map((uq) => {
const answer = uq.answer as any
const questions = quiz.questions
const correctAnswer = questions.map((q, index) => {
const answerOfQuestion: any = q.answer as [];
const isAnswerCorrect = answerOfQuestion.filter((ans:any, i: number) => ans === answer[index].answer[i]);
return {
...q,
isCorrect: isAnswerCorrect.length === answerOfQuestion.length
}
})
// console.log()
return {
user: uq.users,
correct_answer: correctAnswer.filter((c) => c.isCorrect).length,
total_question: questions.length,
};
})
console.log()
return getResponse({ ...quiz, user_quiz: userQuizMapped }, 'success get quiz', 200);
return getResponse(quiz, 'success get quiz', 200);
}
53 changes: 53 additions & 0 deletions app/api/quiz/[id]/user/[u_id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Answer, Quiz } from "@/types/quiz";
import getResponse from "@/utils/getResponse";
import getSessionUser from "@/utils/session";
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient()
export async function GET(req: Request, { params }: any) {
const { id,u_id } = params;
const session = await getSessionUser();
const userQuiz = await prisma.user_quiz.findFirst({
where: {
quiz_id: +id,
user_id: +u_id

},
include: {
users: {
select: {
name: true,
username: true,
id: true
}
},
quiz: {
select: {
questions:true
}
}
},
})
const quiz = userQuiz?.quiz.questions.map((q) => {
const quizAnswer = userQuiz?.answer as any
return {
...quizAnswer?.find((uq: any) => uq.id === q.id),
true_answer: q.answer,
title: q.title,
choices: q.choices,
};
})

return getResponse(
{
id: userQuiz?.id,
user: userQuiz?.users,
quiz: quiz,
score: userQuiz?.score,
duration: userQuiz?.duration,
created_at: userQuiz?.createdAt,
updated_at: userQuiz?.updatedAt
},
"success get quiz",
200
);
}

0 comments on commit 8eacd4f

Please sign in to comment.