Merge pull request #484 from pateljannat/mini-fix
This commit is contained in:
@@ -21,7 +21,7 @@ def submit_solution(exercise, code):
|
|||||||
@exerecise: name of the exercise to submit
|
@exerecise: name of the exercise to submit
|
||||||
@code: solution to the exercise
|
@code: solution to the exercise
|
||||||
"""
|
"""
|
||||||
ex = frappe.get_doc("Exercise", exercise)
|
ex = frappe.get_doc("LMS Exercise", exercise)
|
||||||
if not ex:
|
if not ex:
|
||||||
return
|
return
|
||||||
doc = ex.submit(code)
|
doc = ex.submit(code)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ frappe.ui.form.on("Course Lesson", {
|
|||||||
},
|
},
|
||||||
setup_help(frm) {
|
setup_help(frm) {
|
||||||
let quiz_link = `<a href="/app/lms-quiz"> ${__("Quiz List")} </a>`;
|
let quiz_link = `<a href="/app/lms-quiz"> ${__("Quiz List")} </a>`;
|
||||||
let exercise_link = `<a href="/app/exercise"> ${__(
|
let exercise_link = `<a href="/app/lms-exercise"> ${__(
|
||||||
"Exercise List"
|
"Exercise List"
|
||||||
)} </a>`;
|
)} </a>`;
|
||||||
let file_link = `<a href="/app/file"> ${__("File DocType")} </a>`;
|
let file_link = `<a href="/app/file"> ${__("File DocType")} </a>`;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class CourseLesson(Document):
|
|||||||
self.update_lesson_name_in_document(section)
|
self.update_lesson_name_in_document(section)
|
||||||
|
|
||||||
def update_lesson_name_in_document(self, section):
|
def update_lesson_name_in_document(self, section):
|
||||||
doctype_map = {"Exercise": "Exercise", "Quiz": "LMS Quiz"}
|
doctype_map = {"Exercise": "LMS Exercise", "Quiz": "LMS Quiz"}
|
||||||
macros = find_macros(self.body)
|
macros = find_macros(self.body)
|
||||||
documents = [value for name, value in macros if name == section]
|
documents = [value for name, value in macros if name == section]
|
||||||
index = 1
|
index = 1
|
||||||
@@ -71,7 +71,7 @@ class CourseLesson(Document):
|
|||||||
|
|
||||||
macros = find_macros(self.body)
|
macros = find_macros(self.body)
|
||||||
exercises = [value for name, value in macros if name == "Exercise"]
|
exercises = [value for name, value in macros if name == "Exercise"]
|
||||||
return [frappe.get_doc("Exercise", name) for name in exercises]
|
return [frappe.get_doc("LMS Exercise", name) for name in exercises]
|
||||||
|
|
||||||
def get_progress(self):
|
def get_progress(self):
|
||||||
return frappe.db.get_value(
|
return frappe.db.get_value(
|
||||||
@@ -92,14 +92,9 @@ def save_progress(lesson, course, status):
|
|||||||
if not membership:
|
if not membership:
|
||||||
return
|
return
|
||||||
|
|
||||||
if frappe.db.exists(
|
filters = {"lesson": lesson, "owner": frappe.session.user, "course": course}
|
||||||
"LMS Course Progress",
|
if frappe.db.exists("LMS Course Progress", filters):
|
||||||
{"lesson": lesson, "owner": frappe.session.user, "course": course},
|
doc = frappe.get_doc("LMS Course Progress", filters)
|
||||||
):
|
|
||||||
doc = frappe.get_doc(
|
|
||||||
"LMS Course Progress",
|
|
||||||
{"lesson": lesson, "owner": frappe.session.user, "course": course},
|
|
||||||
)
|
|
||||||
doc.status = status
|
doc.status = status
|
||||||
doc.save(ignore_permissions=True)
|
doc.save(ignore_permissions=True)
|
||||||
else:
|
else:
|
||||||
@@ -108,6 +103,7 @@ def save_progress(lesson, course, status):
|
|||||||
"doctype": "LMS Course Progress",
|
"doctype": "LMS Course Progress",
|
||||||
"lesson": lesson,
|
"lesson": lesson,
|
||||||
"status": status,
|
"status": status,
|
||||||
|
"member": frappe.session.user,
|
||||||
}
|
}
|
||||||
).save(ignore_permissions=True)
|
).save(ignore_permissions=True)
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Exercise",
|
"label": "Exercise",
|
||||||
"options": "Exercise",
|
"options": "LMS Exercise",
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Exercise",
|
"label": "Exercise",
|
||||||
"options": "Exercise"
|
"options": "LMS Exercise"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fetch_from": "exercise.title",
|
"fetch_from": "exercise.title",
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class TestLMSCourse(unittest.TestCase):
|
|||||||
if frappe.db.exists("LMS Course", "test-course"):
|
if frappe.db.exists("LMS Course", "test-course"):
|
||||||
frappe.db.delete("Exercise Submission", {"course": "test-course"})
|
frappe.db.delete("Exercise Submission", {"course": "test-course"})
|
||||||
frappe.db.delete("Exercise Latest Submission", {"course": "test-course"})
|
frappe.db.delete("Exercise Latest Submission", {"course": "test-course"})
|
||||||
frappe.db.delete("Exercise", {"course": "test-course"})
|
frappe.db.delete("LMS Exercise", {"course": "test-course"})
|
||||||
frappe.db.delete("LMS Batch Membership", {"course": "test-course"})
|
frappe.db.delete("LMS Batch Membership", {"course": "test-course"})
|
||||||
frappe.db.delete("LMS Batch", {"course": "test-course"})
|
frappe.db.delete("LMS Batch", {"course": "test-course"})
|
||||||
frappe.db.delete("LMS Course Mentor Mapping", {"course": "test-course"})
|
frappe.db.delete("LMS Course Mentor Mapping", {"course": "test-course"})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2021, FOSS United and contributors
|
// Copyright (c) 2021, FOSS United and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on("Exercise", {
|
frappe.ui.form.on("LMS Exercise", {
|
||||||
// refresh: function(frm) {
|
// refresh: function(frm) {
|
||||||
// }
|
// }
|
||||||
});
|
});
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
"modified": "2021-09-29 15:27:55.585874",
|
"modified": "2021-09-29 15:27:55.585874",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Exercise",
|
"name": "LMS Exercise",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
@@ -7,7 +7,7 @@ from frappe.model.document import Document
|
|||||||
from lms.lms.utils import get_membership
|
from lms.lms.utils import get_membership
|
||||||
|
|
||||||
|
|
||||||
class Exercise(Document):
|
class LMSExercise(Document):
|
||||||
def get_user_submission(self):
|
def get_user_submission(self):
|
||||||
"""Returns the latest submission for this user."""
|
"""Returns the latest submission for this user."""
|
||||||
user = frappe.session.user
|
user = frappe.session.user
|
||||||
@@ -8,7 +8,7 @@ import frappe
|
|||||||
from lms.lms.doctype.lms_course.test_lms_course import new_course
|
from lms.lms.doctype.lms_course.test_lms_course import new_course
|
||||||
|
|
||||||
|
|
||||||
class TestExercise(unittest.TestCase):
|
class TestLMSExercise(unittest.TestCase):
|
||||||
def new_exercise(self):
|
def new_exercise(self):
|
||||||
course = new_course("Test Course")
|
course = new_course("Test Course")
|
||||||
member = frappe.get_doc(
|
member = frappe.get_doc(
|
||||||
@@ -21,7 +21,7 @@ class TestExercise(unittest.TestCase):
|
|||||||
member.insert()
|
member.insert()
|
||||||
e = frappe.get_doc(
|
e = frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Exercise",
|
"doctype": "LMS Exercise",
|
||||||
"name": "test-problem",
|
"name": "test-problem",
|
||||||
"course": course.name,
|
"course": course.name,
|
||||||
"title": "Test Problem",
|
"title": "Test Problem",
|
||||||
@@ -51,4 +51,4 @@ class TestExercise(unittest.TestCase):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
frappe.db.sql("delete from `tabLMS Batch Membership`")
|
frappe.db.sql("delete from `tabLMS Batch Membership`")
|
||||||
frappe.db.sql("delete from `tabExercise Submission`")
|
frappe.db.sql("delete from `tabExercise Submission`")
|
||||||
frappe.db.sql("delete from `tabExercise`")
|
frappe.db.sql("delete from `tabLMS Exercise`")
|
||||||
@@ -11,7 +11,7 @@ class LMSSection(Document):
|
|||||||
|
|
||||||
def get_exercise(self):
|
def get_exercise(self):
|
||||||
if self.type == "exercise":
|
if self.type == "exercise":
|
||||||
return frappe.get_doc("Exercise", self.id)
|
return frappe.get_doc("LMS Exercise", self.id)
|
||||||
|
|
||||||
def get_quiz(self):
|
def get_quiz(self):
|
||||||
if self.type == "quiz":
|
if self.type == "quiz":
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ lms.patches.v0_0.create_course_instructor_role #29-08-2022
|
|||||||
lms.patches.v0_0.create_course_moderator_role
|
lms.patches.v0_0.create_course_moderator_role
|
||||||
lms.patches.v0_0.set_dashboard #11-10-2022
|
lms.patches.v0_0.set_dashboard #11-10-2022
|
||||||
lms.patches.v0_0.set_courses_page_as_home
|
lms.patches.v0_0.set_courses_page_as_home
|
||||||
lms.patches.v0_0.set_member_in_progress #09-11-2022
|
lms.patches.v0_0.set_member_in_progress #03-03-2023
|
||||||
lms.patches.v0_0.convert_progress_to_float
|
lms.patches.v0_0.convert_progress_to_float
|
||||||
lms.patches.v0_0.add_pages_to_nav #25-11-2022
|
lms.patches.v0_0.add_pages_to_nav #25-11-2022
|
||||||
lms.patches.v0_0.change_role_names
|
lms.patches.v0_0.change_role_names
|
||||||
@@ -47,3 +47,4 @@ lms.patches.v0_0.assignment_file_type
|
|||||||
lms.patches.v0_0.user_singles_issue #23-11-2022
|
lms.patches.v0_0.user_singles_issue #23-11-2022
|
||||||
lms.patches.v0_0.rename_community_to_users #06-01-2023
|
lms.patches.v0_0.rename_community_to_users #06-01-2023
|
||||||
lms.patches.v0_0.video_embed_link
|
lms.patches.v0_0.video_embed_link
|
||||||
|
lms.patches.v0_0.rename_exercise_doctype
|
||||||
|
|||||||
13
lms/patches/v0_0/rename_exercise_doctype.py
Normal file
13
lms/patches/v0_0/rename_exercise_doctype.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe.model.rename_doc import rename_doc
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
if frappe.db.exists("DocType", "LMS Exercise"):
|
||||||
|
return
|
||||||
|
|
||||||
|
frappe.flags.ignore_route_conflict_validation = True
|
||||||
|
rename_doc("DocType", "Exercise", "LMS Exercise")
|
||||||
|
frappe.flags.ignore_route_conflict_validation = False
|
||||||
|
|
||||||
|
frappe.reload_doctype("LMS Exercise", force=True)
|
||||||
@@ -3,9 +3,12 @@ import frappe
|
|||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doc("lms", "doctype", "lms_course_progress")
|
frappe.reload_doc("lms", "doctype", "lms_course_progress")
|
||||||
progress_records = frappe.get_all("LMS Course Progress", fields=["name", "owner"])
|
progress_records = frappe.get_all(
|
||||||
|
"LMS Course Progress", fields=["name", "owner", "member"]
|
||||||
|
)
|
||||||
|
|
||||||
for progress in progress_records:
|
for progress in progress_records:
|
||||||
full_name = frappe.db.get_value("User", progress.owner, "full_name")
|
if not progress.member:
|
||||||
frappe.db.set_value("LMS Course Progress", progress.name, "member", progress.owner)
|
full_name = frappe.db.get_value("User", progress.owner, "full_name")
|
||||||
frappe.db.set_value("LMS Course Progress", progress.name, "member_name", full_name)
|
frappe.db.set_value("LMS Course Progress", progress.name, "member", progress.owner)
|
||||||
|
frappe.db.set_value("LMS Course Progress", progress.name, "member_name", full_name)
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ def quiz_renderer(quiz_name):
|
|||||||
|
|
||||||
|
|
||||||
def exercise_renderer(argument):
|
def exercise_renderer(argument):
|
||||||
exercise = frappe.get_doc("Exercise", argument)
|
exercise = frappe.get_doc("LMS Exercise", argument)
|
||||||
context = dict(exercise=exercise)
|
context = dict(exercise=exercise)
|
||||||
return frappe.render_template("templates/exercise.html", context)
|
return frappe.render_template("templates/exercise.html", context)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user