Merge pull request #866 from pateljannat/issues-16

fix: misc issues
This commit is contained in:
Jannat Patel
2024-06-06 22:04:47 +05:30
committed by GitHub
7 changed files with 102 additions and 66 deletions

View File

@@ -8,7 +8,7 @@
:class="isSidebarCollapsed ? 'items-center' : ''" :class="isSidebarCollapsed ? 'items-center' : ''"
> >
<UserDropdown class="p-2" :isCollapsed="isSidebarCollapsed" /> <UserDropdown class="p-2" :isCollapsed="isSidebarCollapsed" />
<div class="flex flex-col overflow-y-auto" v-if="sidebarSettings.data"> <div class="flex flex-col" v-if="sidebarSettings.data">
<SidebarLink <SidebarLink
v-for="link in sidebarLinks" v-for="link in sidebarLinks"
:link="link" :link="link"
@@ -22,9 +22,13 @@
> >
<div <div
v-if="isModerator" v-if="isModerator"
class="flex items-center justify-between pl-4 pr-2" class="flex items-center justify-between pr-2"
:class="isSidebarCollapsed ? 'pl-3' : 'pl-5'"
> >
<span class="text-sm font-medium text-gray-600"> <span
v-if="!isSidebarCollapsed"
class="text-sm font-medium text-gray-600"
>
{{ __('Web Pages') }} {{ __('Web Pages') }}
</span> </span>
<Button variant="ghost" @click="openPageModal()"> <Button variant="ghost" @click="openPageModal()">
@@ -35,7 +39,7 @@
</div> </div>
<div <div
v-if="sidebarSettings.data?.web_pages?.length" v-if="sidebarSettings.data?.web_pages?.length"
class="flex flex-col overflow-y-auto" class="flex flex-col"
> >
<SidebarLink <SidebarLink
v-for="link in sidebarSettings.data.web_pages" v-for="link in sidebarSettings.data.web_pages"

View File

@@ -16,44 +16,42 @@
{{ __('Live Class') }} {{ __('Live Class') }}
</div> </div>
<div v-if="liveClasses.data?.length" class="grid grid-cols-2 gap-5"> <div v-if="liveClasses.data?.length" class="grid grid-cols-2 gap-5">
<div v-for="cls in liveClasses.data"> <div v-for="cls in liveClasses.data" class="border rounded-md h-full p-3">
<div class="border rounded-md p-3"> <div class="font-semibold text-lg mb-4">
<div class="font-semibold text-lg mb-4"> {{ cls.title }}
{{ cls.title }} </div>
</div> <div class="flex items-center mb-2">
<div class="flex items-center mb-2"> <Calendar class="w-4 h-4 stroke-1.5" />
<Calendar class="w-4 h-4 stroke-1.5" /> <span class="ml-2">
<span class="ml-2"> {{ dayjs(cls.date).format('DD MMMM YYYY') }}
{{ dayjs(cls.date).format('DD MMMM YYYY') }} </span>
</span> </div>
</div> <div class="flex items-center mb-5">
<div class="flex items-center mb-5"> <Clock class="w-4 h-4 stroke-1.5" />
<Clock class="w-4 h-4 stroke-1.5" /> <span class="ml-2">
<span class="ml-2"> {{ formatTime(cls.time) }}
{{ formatTime(cls.time) }} </span>
</span> </div>
</div> <div class="mb-5">
<div class="mb-5"> {{ cls.description }}
{{ cls.description }} </div>
</div> <div class="flex items-center gap-2">
<div class="flex items-center gap-2"> <a
<a :href="cls.start_url"
:href="cls.start_url" target="_blank"
target="_blank" class="w-1/2 cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded"
class="w-1/2 cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded" >
> <Monitor class="h-4 w-4 stroke-1.5" />
<Monitor class="h-4 w-4 stroke-1.5" /> {{ __('Start') }}
{{ __('Start') }} </a>
</a> <a
<a :href="cls.join_url"
:href="cls.join_url" target="_blank"
target="_blank" class="w-1/2 cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded"
class="w-1/2 cursor-pointer inline-flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base px-2 rounded" >
> <Video class="h-4 w-4 stroke-1.5" />
<Video class="h-4 w-4 stroke-1.5" /> {{ __('Join') }}
{{ __('Join') }} </a>
</a>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -138,7 +138,27 @@
{{ questionDetails.data[`explanation_${index}`] }} {{ questionDetails.data[`explanation_${index}`] }}
</div> </div>
</div> </div>
<div class="flex items-center justify-between mt-8"> <div v-else>
<FormControl
v-model="possibleAnswer"
type="textarea"
:disabled="showAnswers.length ? true : false"
class="my-2"
/>
<div v-if="showAnswers.length">
<Badge v-if="showAnswers[0]" :label="__('Correct')" theme="green">
<template #prefix>
<CheckCircle class="w-4 h-4 text-green-500 mr-1" />
</template>
</Badge>
<Badge v-else theme="red" :label="__('Incorrect')">
<template #prefix>
<XCircle class="w-4 h-4 text-red-500 mr-1" />
</template>
</Badge>
</div>
</div>
<div class="flex items-center justify-between mt-5">
<div> <div>
{{ {{
__('Question {0} of {1}').format( __('Question {0} of {1}').format(
@@ -215,22 +235,19 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { import { Badge, Button, createResource, ListView } from 'frappe-ui'
createDocumentResource,
Button,
createResource,
ListView,
} from 'frappe-ui'
import { ref, watch, reactive, inject } from 'vue' import { ref, watch, reactive, inject } from 'vue'
import { createToast } from '@/utils/' import { createToast } from '@/utils/'
import { CheckCircle, XCircle, MinusCircle } from 'lucide-vue-next' import { CheckCircle, XCircle, MinusCircle } from 'lucide-vue-next'
import { timeAgo } from '@/utils' import { timeAgo } from '@/utils'
import FormControl from 'frappe-ui/src/components/FormControl.vue'
const user = inject('$user') const user = inject('$user')
const activeQuestion = ref(0) const activeQuestion = ref(0)
const currentQuestion = ref('') const currentQuestion = ref('')
const selectedOptions = reactive([0, 0, 0, 0]) const selectedOptions = reactive([0, 0, 0, 0])
const showAnswers = reactive([]) const showAnswers = reactive([])
const possibleAnswer = ref(null)
const props = defineProps({ const props = defineProps({
quizName: { quizName: {
@@ -342,10 +359,17 @@ const markAnswer = (index) => {
const getAnswers = () => { const getAnswers = () => {
let answers = [] let answers = []
selectedOptions.forEach((value, index) => { const type = questionDetails.data.type
if (selectedOptions[index])
answers.push(questionDetails.data[`option_${index + 1}`]) if (type == 'Choices') {
}) selectedOptions.forEach((value, index) => {
if (selectedOptions[index])
answers.push(questionDetails.data[`option_${index + 1}`])
})
} else {
answers.push(possibleAnswer.value)
}
return answers return answers
} }
@@ -370,15 +394,20 @@ const checkAnswer = () => {
}, },
auto: true, auto: true,
onSuccess(data) { onSuccess(data) {
selectedOptions.forEach((option, index) => { let type = questionDetails.data.type
if (option) { if (type == 'Choices') {
showAnswers[index] = option && data[index] selectedOptions.forEach((option, index) => {
} else if (questionDetails.data[`is_correct_${index + 1}`]) { if (option) {
showAnswers[index] = 0 showAnswers[index] = option && data[index]
} else { } else if (questionDetails.data[`is_correct_${index + 1}`]) {
showAnswers[index] = undefined showAnswers[index] = 0
} } else {
}) showAnswers[index] = undefined
}
})
} else {
showAnswers.push(data)
}
addToLocalStorage() addToLocalStorage()
if (!quiz.data.show_answers) { if (!quiz.data.show_answers) {
resetQuestion() resetQuestion()
@@ -413,6 +442,7 @@ const resetQuestion = () => {
activeQuestion.value = activeQuestion.value + 1 activeQuestion.value = activeQuestion.value + 1
selectedOptions.splice(0, selectedOptions.length, ...[0, 0, 0, 0]) selectedOptions.splice(0, selectedOptions.length, ...[0, 0, 0, 0])
showAnswers.length = 0 showAnswers.length = 0
possibleAnswer.value = null
} }
const submitQuiz = () => { const submitQuiz = () => {

View File

@@ -33,7 +33,7 @@
{{ link.count }} {{ link.count }}
</span> </span>
<div <div
v-if="showControls" v-if="showControls && !isCollapsed"
class="flex items-center space-x-2 !ml-auto block text-xs text-gray-600 group-hover:visible invisible" class="flex items-center space-x-2 !ml-auto block text-xs text-gray-600 group-hover:visible invisible"
> >
<component <component
@@ -77,7 +77,7 @@ const props = defineProps({
function handleClick() { function handleClick() {
if (router.hasRoute(props.link.to)) { if (router.hasRoute(props.link.to)) {
router.push({ name: props.link.to }) router.push({ name: props.link.to })
} else { } else if (props.link.to) {
window.location.href = `/${props.link.to}` window.location.href = `/${props.link.to}`
} }
} }

View File

@@ -6,6 +6,7 @@ import frappe
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils import cstr, comma_and from frappe.utils import cstr, comma_and
from fuzzywuzzy import fuzz
from lms.lms.doctype.course_lesson.course_lesson import save_progress from lms.lms.doctype.course_lesson.course_lesson import save_progress
from lms.lms.utils import ( from lms.lms.utils import (
generate_slug, generate_slug,
@@ -304,7 +305,7 @@ def check_input_answers(question, answer):
question_details = frappe.db.get_value("LMS Question", question, fields, as_dict=1) question_details = frappe.db.get_value("LMS Question", question, fields, as_dict=1)
for num in range(1, 5): for num in range(1, 5):
current_possibility = question_details[f"possibility_{num}"] current_possibility = question_details[f"possibility_{num}"]
if current_possibility and current_possibility.lower() == answer.lower(): if current_possibility and fuzz.token_sort_ratio(current_possibility, answer) > 85:
return 1 return 1
return 0 return 0

View File

@@ -1213,6 +1213,7 @@ def create_membership(course, payment):
def add_student_to_batch(batchname, payment): def add_student_to_batch(batchname, payment):
student = frappe.new_doc("Batch Student") student = frappe.new_doc("Batch Student")
current_count = frappe.db.count("Batch Student", {"parent": batchname})
student.update( student.update(
{ {
"student": frappe.session.user, "student": frappe.session.user,
@@ -1221,6 +1222,7 @@ def add_student_to_batch(batchname, payment):
"parent": batchname, "parent": batchname,
"parenttype": "LMS Batch", "parenttype": "LMS Batch",
"parentfield": "students", "parentfield": "students",
"idx": current_count + 1,
} }
) )
student.save(ignore_permissions=True) student.save(ignore_permissions=True)

View File

@@ -14,7 +14,8 @@ dependencies = [
"beautifulsoup4~=4.12.2", "beautifulsoup4~=4.12.2",
"lxml~=4.9.3", "lxml~=4.9.3",
"cairocffi~=1.6.1", "cairocffi~=1.6.1",
"razorpay~=1.4.1" "razorpay~=1.4.1",
"fuzzywuzzy~=0.18.0",
] ]
[build-system] [build-system]