fix: progress

This commit is contained in:
Jannat Patel
2024-04-03 12:11:34 +05:30
parent c7bdf68bc6
commit 5de7f5e283
9 changed files with 68 additions and 35 deletions

Submodule frappe-ui updated: 3b700c7a8a...c5faaae38e

View File

@@ -21,32 +21,29 @@
<div class="flex flex-col flex-auto p-4"> <div class="flex flex-col flex-auto p-4">
<div class="flex items-center justify-between mb-2"> <div class="flex items-center justify-between mb-2">
<div v-if="course.lesson_count"> <div v-if="course.lesson_count">
<Tooltip <Tooltip :text="__('Lessons')">
:text="__('Lessons')" <span class="flex items-center">
class="flex items-center space-x-1 py-1" <BookOpen class="h-4 w-4 stroke-1.5 text-gray-700 mr-1" />
> {{ course.lesson_count }}
<BookOpen class="h-4 w-4 stroke-1.5 text-gray-700" /> </span>
<span> {{ course.lesson_count }} </span>
</Tooltip> </Tooltip>
</div> </div>
<div v-if="course.enrollment_count"> <div v-if="course.enrollment_count">
<Tooltip <Tooltip :text="__('Enrolled Students')">
:text="__('Enrolled Students')" <span class="flex items-center">
class="flex items-center space-x-1 py-1" <Users class="h-4 w-4 stroke-1.5 text-gray-700 mr-1" />
> {{ course.enrollment_count }}
<Users class="h-4 w-4 stroke-1.5 text-gray-700" /> </span>
<span> {{ course.enrollment_count }} </span>
</Tooltip> </Tooltip>
</div> </div>
<div v-if="course.avg_rating"> <div v-if="course.avg_rating">
<Tooltip <Tooltip :text="__('Average Rating')">
:text="__('Average Rating')" <span class="flex items-center">
class="flex items-center space-x-1 py-1" <Star class="h-4 w-4 stroke-1.5 text-gray-700 mr-1" />
> {{ course.avg_rating }}
<Star class="h-4 w-4 stroke-1.5 text-gray-700" /> </span>
<span> {{ course.avg_rating }} </span>
</Tooltip> </Tooltip>
</div> </div>

View File

@@ -65,6 +65,10 @@
class="h-4 w-4 text-gray-900 stroke-1 mr-2" class="h-4 w-4 text-gray-900 stroke-1 mr-2"
/> />
{{ lesson.title }} {{ lesson.title }}
<Check
v-if="lesson.is_complete"
class="h-4 w-4 text-green-500 stroke-1.5 ml-2"
/>
</div> </div>
</router-link> </router-link>
</div> </div>
@@ -108,6 +112,7 @@ import {
MonitorPlay, MonitorPlay,
HelpCircle, HelpCircle,
FileText, FileText,
Check,
} from 'lucide-vue-next' } from 'lucide-vue-next'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import ChapterModal from '@/components/Modals/ChapterModal.vue' import ChapterModal from '@/components/Modals/ChapterModal.vue'

View File

@@ -230,6 +230,8 @@ const lesson = createResource({
name: data.membership.name, name: data.membership.name,
lesson_name: data.name, lesson_name: data.name,
}) })
markProgress(data)
if (data.content) editor = renderEditor('editor', data.content) if (data.content) editor = renderEditor('editor', data.content)
if (data.instructor_content) if (data.instructor_content)
@@ -237,8 +239,6 @@ const lesson = createResource({
'instructor-content', 'instructor-content',
data.instructor_content data.instructor_content
) )
markProgress(data)
}, },
}) })
@@ -253,9 +253,7 @@ const renderEditor = (holder, content) => {
} }
const markProgress = (data) => { const markProgress = (data) => {
setTimeout(() => {
if (!data.progress) progress.submit() if (!data.progress) progress.submit()
}, 60000)
} }
const current_lesson = createResource({ const current_lesson = createResource({

View File

@@ -66,7 +66,8 @@
}, },
{ {
"fieldname": "section_break_6", "fieldname": "section_break_6",
"fieldtype": "Section Break" "fieldtype": "Section Break",
"hidden": 1
}, },
{ {
"fieldname": "body", "fieldname": "body",
@@ -78,6 +79,7 @@
{ {
"fieldname": "help_section", "fieldname": "help_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 1,
"label": "Help" "label": "Help"
}, },
{ {
@@ -117,6 +119,7 @@
{ {
"fieldname": "section_break_16", "fieldname": "section_break_16",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 1,
"label": "Assignment" "label": "Assignment"
}, },
{ {
@@ -158,7 +161,7 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2024-03-14 14:25:22.464111", "modified": "2024-04-03 10:48:17.525859",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "Course Lesson", "name": "Course Lesson",

View File

@@ -98,6 +98,11 @@ def save_progress(lesson, course):
if not quiz_completed: if not quiz_completed:
return 0 return 0
if frappe.db.exists(
"LMS Course Progress", {"lesson": lesson, "member": frappe.session.user}
):
return 0
frappe.get_doc( frappe.get_doc(
{ {
"doctype": "LMS Course Progress", "doctype": "LMS Course Progress",
@@ -116,7 +121,6 @@ def get_quiz_progress(lesson):
body = frappe.db.get_value("Course Lesson", lesson, "body") body = frappe.db.get_value("Course Lesson", lesson, "body")
macros = find_macros(body) macros = find_macros(body)
quizzes = [value for name, value in macros if name == "Quiz"] quizzes = [value for name, value in macros if name == "Quiz"]
for quiz in quizzes: for quiz in quizzes:
passing_percentage = frappe.db.get_value("LMS Quiz", quiz, "passing_percentage") passing_percentage = frappe.db.get_value("LMS Quiz", quiz, "passing_percentage")
if not frappe.db.exists( if not frappe.db.exists(
@@ -128,7 +132,6 @@ def get_quiz_progress(lesson):
}, },
): ):
return False return False
return True return True

View File

@@ -6,7 +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 lms.lms.doctype.lms_question.lms_question import validate_correct_answers 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,
has_course_moderator_role, has_course_moderator_role,
@@ -86,7 +86,7 @@ def quiz_summary(quiz, results):
del result["question_index"] del result["question_index"]
quiz_details = frappe.db.get_value( quiz_details = frappe.db.get_value(
"LMS Quiz", quiz, ["total_marks", "passing_percentage"], as_dict=1 "LMS Quiz", quiz, ["total_marks", "passing_percentage", "lesson", "course"], as_dict=1
) )
score_out_of = quiz_details.total_marks score_out_of = quiz_details.total_marks
percentage = (score / score_out_of) * 100 percentage = (score / score_out_of) * 100
@@ -103,6 +103,16 @@ def quiz_summary(quiz, results):
"passing_percentage": quiz_details.passing_percentage, "passing_percentage": quiz_details.passing_percentage,
} }
) )
print(
percentage, quiz_details.passing_percentage, quiz_details.lesson, quiz_details.course
)
if (
percentage >= quiz_details.passing_percentage
and quiz_details.lesson
and quiz_details.course
):
save_progress(quiz_details.lesson, quiz_details.course)
submission.save(ignore_permissions=True) submission.save(ignore_permissions=True)
return { return {

View File

@@ -155,11 +155,13 @@ def get_lesson_details(chapter):
"question", "question",
"file_type", "file_type",
"instructor_notes", "instructor_notes",
"course",
], ],
as_dict=True, as_dict=True,
) )
lesson_details.number = f"{chapter.idx}.{row.idx}" lesson_details.number = f"{chapter.idx}.{row.idx}"
lesson_details.icon = get_lesson_icon(lesson_details.body) lesson_details.icon = get_lesson_icon(lesson_details.body)
lesson_details.is_complete = get_progress(lesson_details.course, lesson_details.name)
lessons.append(lesson_details) lessons.append(lesson_details)
return lessons return lessons
@@ -307,7 +309,7 @@ def get_progress(course, lesson, member=None):
return frappe.db.get_value( return frappe.db.get_value(
"LMS Course Progress", "LMS Course Progress",
{"course": course, "owner": member, "lesson": lesson}, {"course": course, "member": member, "lesson": lesson},
["status"], ["status"],
) )

View File

@@ -15,14 +15,29 @@
<meta name="twitter:title" content="{{ meta.title }}" /> <meta name="twitter:title" content="{{ meta.title }}" />
<meta name="twitter:image" content="{{ meta.image }}" /> <meta name="twitter:image" content="{{ meta.image }}" />
<meta name="twitter:description" content="{{ meta.description }}" /> <meta name="twitter:description" content="{{ meta.description }}" />
<script type="module" crossorigin src="/assets/lms/frontend/assets/index-B9z4Wi_B.js"></script> <script type="module" crossorigin src="/assets/lms/frontend/assets/index-CY-7ZjXP.js"></script>
<link rel="modulepreload" crossorigin href="/assets/lms/frontend/assets/frappe-ui-K4nTYoB-.js"> <link rel="modulepreload" crossorigin href="/assets/lms/frontend/assets/frappe-ui-h_6W7zSS.js">
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/frappe-ui-DzKBfka9.css"> <link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/frappe-ui-DzKBfka9.css">
<link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/index-vSljmvbG.css"> <link rel="stylesheet" crossorigin href="/assets/lms/frontend/assets/index-B5SBTRQU.css">
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<h2>{{ meta.title }}</h2> <h1>{{ meta.title }}</h1>
<p>
{{ meta.description }}
</p>
<p>
The content here is just for seo purposes. The actual content will be loaded in a few seconds.
</p>
<p>
Seo checks if a page has more than 300 words. So, here are some more words to make it more than 300 words.
Page descriptions are the HTML meta tags that provide a brief summary of a web page.
Search engines use meta descriptions to help identify the page's topic - they don't use them to rank the page, but they do use them to determine whether or not to display the page in search results.
Meta descriptions are important because they're often the first thing people see when they're deciding which search result to click on.
They're also important because they can help improve your click-through rate (CTR) from search results.
A good meta description can entice people to click on your page instead of someone else's.
</p>
<a href="{{ meta.link }}">Know More</a>
</div> </div>
<div id="modals"></div> <div id="modals"></div>
<div id="popovers"></div> <div id="popovers"></div>