feat: delete submission

This commit is contained in:
Rotimi Best
2024-08-03 20:58:07 +01:00
parent e8de6b9457
commit 30a6193e3c
20 changed files with 305 additions and 161 deletions
@@ -1,4 +1,3 @@
import type { PostgrestSingleResponse } from '@supabase/supabase-js';
import { supabase } from '$lib/utils/functions/supabase';
import type { ExerciseSubmissions } from '$lib/utils/types';
@@ -87,8 +86,8 @@ export async function updateSubmission(
status_id,
total,
feedback
}: { id?: number; status_id?: number; total?: number; feedback?: string },
otherArgs?: any
}: { id: string; status_id?: number; total?: number; feedback?: string },
otherArgs?: Record<string, string>
) {
const toUpdate: {
status_id?: number;
@@ -106,6 +105,13 @@ export async function updateSubmission(
return supabase.from('submission').update(toUpdate, otherArgs).match({ id });
}
export async function updateQuestionAnswer(update: any, match: any) {
export async function deleteSubmission(id: string) {
return supabase.from('submission').delete().match({ id });
}
export async function updateQuestionAnswer(
update: Record<string, string>,
match: Record<string, string>
) {
return supabase.from('question_answer').update(update).match(match);
}
@@ -497,7 +497,10 @@
"accept_grade": "Akzeptieren",
"reject_grade": "Ablehnen",
"add_comment_placeholder": "Hinterlasse einen Kommentar",
"questions_tried": "Diese Punktzahl wurde aufgrund der Gesamtzahl der Versuche vergeben:"
"questions_tried": "Diese Punktzahl wurde aufgrund der Gesamtzahl der Versuche vergeben:",
"delete_prompt": "Löschen",
"delete_error": "Die Übermittlung konnte nicht gelöscht werden",
"delete_success": "Einreichung erfolgreich gelöscht"
}
},
"attendance": {
@@ -735,12 +738,6 @@
"materials": "Materialien",
"exercises": "Übungen"
},
"delete_lesson": {
"modal_heading": "Löschen",
"content": "Sind Sie sicher, dass Sie löschen möchten:",
"no": "NEIN",
"yes": "Ja"
},
"add_lesson": {
"button_title": "Hinzufügen",
"modal_heading": "Neue Lektion hinzufügen",
@@ -1390,5 +1387,11 @@
"empty_heading": "Kein Kurs verfügbar",
"empty_description": "Derzeit sind keine veröffentlichten Kurse verfügbar",
"heading": "Entdecken Sie unsere Kurse"
},
"delete_modal": {
"label": "Löschen",
"content": "Bist du sicher?",
"no": "NEIN",
"yes": "Ja"
}
}
@@ -10,6 +10,13 @@
"snackbar_error": "error while sending code"
},
"delete_modal": {
"label": "Delete",
"content": "Are you sure?",
"no": "No",
"yes": "Yes"
},
"onboarding": {
"sell": "Sell courses online",
"teach": "Teach my current students online",
@@ -514,12 +521,6 @@
"edit": "Edit",
"delete": "Delete"
},
"delete_lesson": {
"modal_heading": "Delete",
"content": "Are you sure you want to delete:",
"no": "No",
"yes": "Yes"
},
"join_lesson": "Join lesson",
"no_link": "No link",
"no_tutor": "No tutor added",
@@ -789,7 +790,10 @@
"submit_grades": "Submit Grades",
"accept_grade": "Accept",
"reject_grade": "Reject",
"questions_tried": "Allocated this score because of total tries:"
"questions_tried": "Allocated this score because of total tries:",
"delete_prompt": "Delete",
"delete_error": "Failed to delete submission",
"delete_success": "Successfully deleted submission"
}
},
@@ -497,7 +497,10 @@
"accept_grade": "Aceptar",
"reject_grade": "Rechazar",
"add_comment_placeholder": "Deja un comentario",
"questions_tried": "Se asignó esta puntuación debido al total de intentos:"
"questions_tried": "Se asignó esta puntuación debido al total de intentos:",
"delete_prompt": "Borrar",
"delete_error": "No se pudo eliminar el envío",
"delete_success": "Envío eliminado correctamente"
}
},
"attendance": {
@@ -735,12 +738,6 @@
"materials": "Materiales",
"exercises": "Ejercicios"
},
"delete_lesson": {
"modal_heading": "Borrar",
"content": "Estas seguro que quieres borrarlo:",
"no": "No",
"yes": "Sí"
},
"add_lesson": {
"button_title": "Agregar",
"modal_heading": "Agregar nueva lección",
@@ -1390,5 +1387,11 @@
"empty_heading": "No hay curso disponible",
"empty_description": "Actualmente no hay ningún curso publicado disponible",
"heading": "Explora nuestros cursos"
},
"delete_modal": {
"label": "Borrar",
"content": "¿Está seguro?",
"no": "No",
"yes": "Sí"
}
}
@@ -497,7 +497,10 @@
"accept_grade": "Accepter",
"reject_grade": "Rejeter",
"add_comment_placeholder": "laissez un commentaire",
"questions_tried": "Attribué ce score en raison du nombre total d'essais :"
"questions_tried": "Attribué ce score en raison du nombre total d'essais :",
"delete_prompt": "Supprimer",
"delete_error": "Échec de la suppression de la soumission",
"delete_success": "Soumission supprimée avec succès"
}
},
"attendance": {
@@ -735,12 +738,6 @@
"materials": "Matériaux",
"exercises": "Des exercices"
},
"delete_lesson": {
"modal_heading": "Supprimer",
"content": "Etes-vous sûr que vous voulez supprimer:",
"no": "Non",
"yes": "Oui"
},
"add_lesson": {
"button_title": "Ajouter",
"modal_heading": "Ajouter une nouvelle leçon",
@@ -1390,5 +1387,11 @@
"empty_heading": "Aucun cours disponible",
"empty_description": "Il n'y a actuellement aucun cours publié disponible",
"heading": "Découvrez nos cours"
},
"delete_modal": {
"label": "Supprimer",
"content": "Es-tu sûr?",
"no": "Non",
"yes": "Oui"
}
}
@@ -497,7 +497,10 @@
"accept_grade": "स्वीकार करना",
"reject_grade": "अस्वीकार करना",
"add_comment_placeholder": "एक टिप्पणी छोड़ें",
"questions_tried": "कुल प्रयासों के कारण यह स्कोर आवंटित किया गया:"
"questions_tried": "कुल प्रयासों के कारण यह स्कोर आवंटित किया गया:",
"delete_prompt": "मिटाना",
"delete_error": "सबमिशन हटाने में विफल",
"delete_success": "सबमिशन सफलतापूर्वक हटा दिया गया"
}
},
"attendance": {
@@ -735,12 +738,6 @@
"materials": "सामग्री",
"exercises": "अभ्यास"
},
"delete_lesson": {
"modal_heading": "मिटाना",
"content": "क्या आप आश्वस्त है कि आपको डिलीट करना है:",
"no": "नहीं",
"yes": "हाँ"
},
"add_lesson": {
"button_title": "जोड़ना",
"modal_heading": "नया पाठ जोड़ें",
@@ -1390,5 +1387,11 @@
"empty_heading": "कोई पाठ्यक्रम उपलब्ध नहीं है",
"empty_description": "वर्तमान में कोई प्रकाशित पाठ्यक्रम उपलब्ध नहीं है",
"heading": "हमारे पाठ्यक्रमों का अन्वेषण करें"
},
"delete_modal": {
"label": "मिटाना",
"content": "क्या आपको यकीन है?",
"no": "नहीं",
"yes": "हाँ"
}
}
@@ -497,7 +497,10 @@
"accept_grade": "Aceitar",
"reject_grade": "Rejeitar",
"add_comment_placeholder": "Deixe um comentário",
"questions_tried": "Alocada esta pontuação por causa do total de tentativas:"
"questions_tried": "Alocada esta pontuação por causa do total de tentativas:",
"delete_prompt": "Excluir",
"delete_error": "Falha ao excluir o envio",
"delete_success": "Envio excluído com sucesso"
}
},
"attendance": {
@@ -735,12 +738,6 @@
"materials": "Materiais",
"exercises": "Exercícios"
},
"delete_lesson": {
"modal_heading": "Excluir",
"content": "Tem certeza de que deseja excluir:",
"no": "Não",
"yes": "Sim"
},
"add_lesson": {
"button_title": "Adicionar",
"modal_heading": "Adicionar nova lição",
@@ -1390,5 +1387,11 @@
"empty_heading": "Nenhum curso disponível",
"empty_description": "Atualmente não há nenhum curso publicado disponível",
"heading": "Explore nossos cursos"
},
"delete_modal": {
"label": "Excluir",
"content": "Tem certeza?",
"no": "Não",
"yes": "Sim"
}
}
@@ -497,7 +497,10 @@
"accept_grade": "Принимать",
"reject_grade": "Отклонять",
"add_comment_placeholder": "Оставить комментарий",
"questions_tried": "Присвоен этот балл из-за общего количества попыток:"
"questions_tried": "Присвоен этот балл из-за общего количества попыток:",
"delete_prompt": "Удалить",
"delete_error": "Не удалось удалить отправку",
"delete_success": "Отправка успешно удалена"
}
},
"attendance": {
@@ -735,12 +738,6 @@
"materials": "Материалы",
"exercises": "Упражнения"
},
"delete_lesson": {
"modal_heading": "Удалить",
"content": "Вы уверены, что хотите удалить:",
"no": "Нет",
"yes": "Да"
},
"add_lesson": {
"button_title": "Добавлять",
"modal_heading": "Добавить новый урок",
@@ -1390,5 +1387,11 @@
"empty_heading": "Нет доступных курсов",
"empty_description": "На данный момент нет доступных опубликованных курсов",
"heading": "Ознакомьтесь с нашими курсами"
},
"delete_modal": {
"label": "Удалить",
"content": "Вы уверены?",
"no": "Нет",
"yes": "Да"
}
}
@@ -497,7 +497,10 @@
"accept_grade": "Chấp nhận",
"reject_grade": "Từ chối",
"add_comment_placeholder": "Để lại một bình luận",
"questions_tried": "Phân bổ số điểm này dựa trên tổng số lần thử:"
"questions_tried": "Phân bổ số điểm này dựa trên tổng số lần thử:",
"delete_prompt": "Xóa bỏ",
"delete_error": "Không thể xóa bài nộp",
"delete_success": "Đã xóa bài nộp thành công"
}
},
"attendance": {
@@ -735,12 +738,6 @@
"materials": "Nguyên vật liệu",
"exercises": "Bài tập"
},
"delete_lesson": {
"modal_heading": "Xóa bỏ",
"content": "Bạn có chắc chắn muốn xóa:",
"no": "KHÔNG",
"yes": "Đúng"
},
"add_lesson": {
"button_title": "Thêm vào",
"modal_heading": "Thêm bài học mới",
@@ -1390,5 +1387,11 @@
"empty_heading": "Không có khóa học nào",
"empty_description": "Hiện tại chưa có khóa học nào được xuất bản",
"heading": "Khám phá các khóa học của chúng tôi"
},
"delete_modal": {
"label": "Xóa bỏ",
"content": "Bạn có chắc không?",
"no": "KHÔNG",
"yes": "Đúng"
}
}
@@ -0,0 +1,48 @@
import { Profile } from '.';
export interface SubmissionItem {
id: string;
statusId: number;
isEarly: boolean;
submittedAt: string;
exercise: {
id: string;
title: string;
};
answers: string;
student: Partial<Profile>;
lesson: {
id: string;
title: string;
};
}
export interface SubmissionSection {
id: number;
title: string;
value: number;
items: SubmissionItem[] | [];
}
export interface SubmissionIdData {
id: string;
statusId: number;
title: string;
isEarly: boolean;
questionAnswerByPoint: Record<string, string>;
answers: Record<string, string>;
questions: {
id: number;
title: string;
order: number;
points: number;
question_type_id: number;
}[];
questionAnswers: {
open_answer: string;
question_id: number;
answers: [];
}[];
student?: Partial<Profile>;
feedback: string;
}