- {{ __('Enter a URL') }}
+
+
+ {{ __('Enter a URL') }}
+
+
+
+
+
+ {{ __('Write your answer here') }}
+
+
(answer = val)"
+ :editable="true"
+ :fixedMenu="true"
+ editorClass="prose-sm max-w-none border-b border-x bg-gray-100 rounded-b-md py-1 px-2 min-h-[7rem]"
+ />
-
-
- {{ __('Write your answer here') }}
+
+
+
+ {{ __('Grading') }}
-
(answer = val)"
- :editable="true"
- :fixedMenu="true"
- editorClass="prose-sm max-w-none border-b border-x bg-gray-100 rounded-b-md py-1 px-2 min-h-[7rem]"
+
+
@@ -119,8 +137,10 @@ import {
createResource,
FileUploader,
Button,
+ Badge,
FormControl,
TextEditor,
+ createDocumentResource,
} from 'frappe-ui'
import { FileText, X } from 'lucide-vue-next'
import { computed, inject, onMounted, ref } from 'vue'
@@ -143,6 +163,12 @@ const props = defineProps({
},
})
+onMounted(() => {
+ if (!user.data) {
+ window.location.href = '/login'
+ }
+})
+
const assignment = createResource({
url: 'frappe.client.get',
params: {
@@ -150,29 +176,17 @@ const assignment = createResource({
name: props.assignmentID,
},
auto: true,
+ onSuccess(data) {
+ if (props.submissionName != 'new') {
+ submissionResource.reload()
+ }
+ },
})
const showUploader = () => {
return ['PDF', 'Image', 'Document'].includes(assignment.data?.type)
}
-const updateSubmission = createResource({
- url: 'frappe.client.set_value',
- makeParams(values) {
- let fieldname = {}
- if (showUploader()) {
- fieldname.assignment_attachment = submissionFile.value.file_url
- } else {
- fieldname.answer = answer.value
- }
- return {
- doctype: 'LMS Assignment Submission',
- name: props.submissionName,
- fieldname: fieldname,
- }
- },
-})
-
const imageResource = createResource({
url: 'lms.lms.api.get_file_info',
makeParams(values) {
@@ -205,43 +219,25 @@ const newSubmission = createResource({
},
})
-const submissionResource = createResource({
- url: 'frappe.client.get_value',
- params: {
- doctype: 'LMS Assignment Submission',
- fieldname: showUploader() ? 'assignment_attachment' : 'answer',
- filters: {
- name: props.submissionName,
- },
- },
+const submissionResource = createDocumentResource({
+ doctype: 'LMS Assignment Submission',
+ name: props.submissionName,
+ auto: false,
onSuccess(data) {
- if (data.assignment_attachment)
+ if (data.assignment_attachment) {
imageResource.reload({ image: data.assignment_attachment })
- if (data.answer) answer.value = data.answer
+ }
},
})
-onMounted(() => {
- if (!user.data) {
- window.location.href = '/login'
- }
- if (props.submissionName != 'new') {
- submissionResource.reload()
- }
-})
const submitAssignment = () => {
if (props.submissionName != 'new') {
- updateSubmission.submit(
- {},
- {
- onSuccess(data) {
- showToast('Success', 'Submission updated successfully.', 'check')
- },
- onError(err) {
- showToast('Error', err.messages?.[0] || err, 'x')
- },
- }
- )
+ let evaluator =
+ submissionResource.doc.owner != user.data?.name ? user.data?.name : null
+ submissionResource.setValue.submit({
+ ...submissionResource.doc,
+ evaluator: evaluator,
+ })
} else {
addNewSubmission()
}
@@ -271,7 +267,8 @@ const addNewSubmission = () => {
const breadcrumbs = computed(() => {
let crumbs = [
{
- label: 'Assignment',
+ label: 'Submissions',
+ route: { name: 'AssignmentSubmissionList' },
},
{
label: assignment.data?.title,
@@ -325,4 +322,31 @@ const validateFile = (file) => {
const removeSubmission = () => {
submissionFile.value = null
}
+
+const canGradeSubmission = computed(() => {
+ return (
+ (user.data?.is_moderator ||
+ user.data?.is_evaluator ||
+ user.data?.is_instructor) &&
+ props.submissionName != 'new'
+ )
+})
+
+const submissionStatusOptions = computed(() => {
+ return [
+ { label: 'Not Graded', value: 'Not Graded' },
+ { label: 'Pass', value: 'Pass' },
+ { label: 'Fail', value: 'Fail' },
+ ]
+})
+
+const statusTheme = computed(() => {
+ if (submissionResource.doc.status == 'Pass') {
+ return 'green'
+ } else if (submissionResource.doc.status == 'Not Graded') {
+ return 'orange'
+ } else {
+ return 'red'
+ }
+})
diff --git a/frontend/src/pages/AssignmentSubmissionList.vue b/frontend/src/pages/AssignmentSubmissionList.vue
index 4aa11bfa6..1575070be 100644
--- a/frontend/src/pages/AssignmentSubmissionList.vue
+++ b/frontend/src/pages/AssignmentSubmissionList.vue
@@ -4,19 +4,23 @@
>
-
-
+
-
-
-
- {{ __('No submissions') }}
+
+
+
+ {{ __('No submissions') }}
+
+
+ {{ __('There are no submissions for this assignment.') }}
+
-