diff --git a/frontend/src/components/Apps.vue b/frontend/src/components/Apps.vue new file mode 100644 index 00000000..4d63616a --- /dev/null +++ b/frontend/src/components/Apps.vue @@ -0,0 +1,67 @@ + + diff --git a/frontend/src/components/Quiz.vue b/frontend/src/components/Quiz.vue index 44149e6d..82e2710f 100644 --- a/frontend/src/components/Quiz.vue +++ b/frontend/src/components/Quiz.vue @@ -439,7 +439,7 @@ const checkAnswer = () => { const addToLocalStorage = () => { let quizData = JSON.parse(localStorage.getItem(quiz.data.title)) let questionData = { - question_index: activeQuestion.value, + question_name: currentQuestion.value, answer: getAnswers().join(), is_correct: showAnswers.filter((answer) => { return answer != undefined diff --git a/frontend/src/components/UserDropdown.vue b/frontend/src/components/UserDropdown.vue index 67c4bc96..348e7918 100644 --- a/frontend/src/components/UserDropdown.vue +++ b/frontend/src/components/UserDropdown.vue @@ -66,6 +66,7 @@ import LMSLogo from '@/components/Icons/LMSLogo.vue' import { sessionStore } from '@/stores/session' import { Dropdown } from 'frappe-ui' +import Apps from '@/components/Apps.vue' import { ChevronDown, LogIn, @@ -77,7 +78,7 @@ import { import { useRouter } from 'vue-router' import { convertToTitleCase } from '../utils' import { usersStore } from '@/stores/user' -import { ref } from 'vue' +import { ref, markRaw } from 'vue' import SettingsModal from '@/components/Modals/Settings.vue' const router = useRouter() @@ -105,11 +106,7 @@ const userDropdownOptions = [ }, }, { - icon: ArrowRightLeft, - label: 'Switch to Desk', - onClick: () => { - window.location.href = '/app' - }, + component: markRaw(Apps), condition: () => { let cookies = new URLSearchParams(document.cookie.split('; ').join('&')) let system_user = cookies.get('system_user') diff --git a/lms/__init__.py b/lms/__init__.py index 8a124bf6..55e47090 100644 --- a/lms/__init__.py +++ b/lms/__init__.py @@ -1 +1 @@ -__version__ = "2.2.0" +__version__ = "2.3.0" diff --git a/lms/hooks.py b/lms/hooks.py index f513c8d6..d077128f 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -4,9 +4,11 @@ app_name = "frappe_lms" app_title = "Frappe LMS" app_publisher = "Frappe" app_description = "Frappe LMS App" -app_icon = "octicon octicon-file-directory" +app_icon_url = "/assets/lms/images/lms-logo.png" +app_icon_title = "Learning" +app_icon_route = "/lms" app_color = "grey" -app_email = "school@frappe.io" +app_email = "jannat@frappe.io" app_license = "AGPL" # Includes in @@ -61,8 +63,6 @@ web_include_js = ["website.bundle.js"] after_install = "lms.install.after_install" after_sync = "lms.install.after_sync" before_uninstall = "lms.install.before_uninstall" - - setup_wizard_requires = "assets/lms/js/setup_wizard.js" # Desk Notifications @@ -231,3 +231,13 @@ profile_url_prefix = "/users/" signup_form_template = "lms.plugins.show_custom_signup" on_session_creation = "lms.overrides.user.on_session_creation" + +add_to_apps_screen = [ + { + "name": "lms", + "logo": "/assets/lms/images/lms-logo.png", + "title": "Learning", + "route": "/lms", + "has_permission": "lms.lms.api.check_app_permission", + } +] diff --git a/lms/lms/api.py b/lms/lms/api.py index df2272cd..872e7829 100644 --- a/lms/lms/api.py +++ b/lms/lms/api.py @@ -597,3 +597,16 @@ def get_members(start=0, search=""): member.role = "LMS Student" return members + + +def check_app_permission(): + """Check if the user has permission to access the app.""" + if frappe.session.user == "Administrator": + return True + + roles = frappe.get_roles() + lms_roles = ["Moderator", "Course Creator", "Batch Evaluator", "LMS Student"] + if any(role in roles for role in lms_roles): + return True + + return False diff --git a/lms/lms/doctype/lms_quiz/lms_quiz.py b/lms/lms/doctype/lms_quiz/lms_quiz.py index 33abac89..27ca24b8 100644 --- a/lms/lms/doctype/lms_quiz/lms_quiz.py +++ b/lms/lms/doctype/lms_quiz/lms_quiz.py @@ -90,21 +90,19 @@ def quiz_summary(quiz, results): question_details = frappe.db.get_value( "LMS Quiz Question", - {"parent": quiz, "idx": result["question_index"]}, - ["question", "marks"], + {"parent": quiz, "question": result["question_name"]}, + ["question", "marks", "question_detail"], as_dict=1, ) result["question_name"] = question_details.question - result["question"] = frappe.db.get_value( - "LMS Question", question_details.question, "question" - ) + result["question"] = question_details.question_detail marks = question_details.marks if correct else 0 result["marks"] = marks score += marks - del result["question_index"] + del result["question_name"] quiz_details = frappe.db.get_value( "LMS Quiz", quiz, ["total_marks", "passing_percentage", "lesson", "course"], as_dict=1 @@ -297,15 +295,6 @@ def check_choice_answers(question, answers): question_details = frappe.db.get_value("LMS Question", question, fields, as_dict=1) - """ if question_details.multiple: - correct_answers = [ question_details[f"option_{num}"] for num in range(1,5) if question_details[f"is_correct_{num}"]] - print(answers) - for ans in correct_answers: - if ans not in answers: - is_correct.append(0) - else: - is_correct.append(1) - else: """ for num in range(1, 5): if question_details[f"option_{num}"] in answers: is_correct.append(question_details[f"is_correct_{num}"]) diff --git a/lms/locale/main.pot b/lms/locale/main.pot index 960fed00..62485806 100644 --- a/lms/locale/main.pot +++ b/lms/locale/main.pot @@ -6,11 +6,11 @@ msgid "" msgstr "" "Project-Id-Version: Frappe LMS VERSION\n" -"Report-Msgid-Bugs-To: school@frappe.io\n" -"POT-Creation-Date: 2024-08-16 16:04+0000\n" -"PO-Revision-Date: 2024-08-16 16:04+0000\n" -"Last-Translator: school@frappe.io\n" -"Language-Team: school@frappe.io\n" +"Report-Msgid-Bugs-To: jannat@frappe.io\n" +"POT-Creation-Date: 2024-08-23 16:04+0000\n" +"PO-Revision-Date: 2024-08-23 16:04+0000\n" +"Last-Translator: jannat@frappe.io\n" +"Language-Team: jannat@frappe.io\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -20,6 +20,46 @@ msgstr "" msgid " Please evaluate and grade it." msgstr "" +#. Paragraph text in the LMS Workspace +#: lms/workspace/lms/lms.json +msgid "LMS Settings" +msgstr "" + +#. Paragraph text in the LMS Workspace +#: lms/workspace/lms/lms.json +msgid "Setup a Home Page" +msgstr "" + +#. Paragraph text in the LMS Workspace +#: lms/workspace/lms/lms.json +msgid "Visit LMS Portal" +msgstr "" + +#. Paragraph text in the LMS Workspace +#: lms/workspace/lms/lms.json +msgid "Create a Course" +msgstr "" + +#. Paragraph text in the LMS Workspace +#: lms/workspace/lms/lms.json +msgid "Documentation" +msgstr "" + +#. Header text in the LMS Workspace +#: lms/workspace/lms/lms.json +msgid "Get Started" +msgstr "" + +#. Header text in the LMS Workspace +#: lms/workspace/lms/lms.json +msgid "Master" +msgstr "" + +#. Header text in the LMS Workspace +#: lms/workspace/lms/lms.json +msgid "Statistics" +msgstr "" + #. Label of the verify_terms (Check) field in DocType 'User' #: fixtures/custom_field.json msgid "Acceptance for Terms and/or Policies" @@ -98,7 +138,7 @@ msgstr "" msgid "Allow accessing future dates" msgstr "" -#: overrides/user.py:195 +#: overrides/user.py:198 msgid "Already Registered" msgstr "" @@ -2449,7 +2489,7 @@ msgstr "" msgid "No." msgstr "" -#: overrides/user.py:190 +#: overrides/user.py:193 msgid "Not Allowed" msgstr "" @@ -2714,11 +2754,11 @@ msgstr "" msgid "Please add {1} for {3} to send calendar invites for evaluations." msgstr "" -#: overrides/user.py:236 +#: overrides/user.py:239 msgid "Please ask your administrator to verify your sign-up" msgstr "" -#: overrides/user.py:234 +#: overrides/user.py:237 msgid "Please check your email for verification" msgstr "" @@ -3019,7 +3059,7 @@ msgstr "" msgid "Registered" msgstr "" -#: overrides/user.py:197 +#: overrides/user.py:200 msgid "Registered but disabled" msgstr "" @@ -3255,7 +3295,7 @@ msgstr "" msgid "Sidebar Items" msgstr "" -#: overrides/user.py:190 +#: overrides/user.py:193 msgid "Sign Up is disabled" msgstr "" @@ -3299,7 +3339,7 @@ msgstr "" msgid "Skills" msgstr "" -#: overrides/user.py:38 +#: overrides/user.py:41 msgid "Skills must be unique" msgstr "" @@ -3591,7 +3631,7 @@ msgstr "" msgid "Template" msgstr "" -#: overrides/user.py:201 +#: overrides/user.py:204 msgid "Temporarily Disabled" msgstr "" @@ -3793,7 +3833,7 @@ msgstr "" msgid "To join this batch, please contact the Administrator." msgstr "" -#: overrides/user.py:202 +#: overrides/user.py:205 msgid "Too many users signed up recently, so the registration is disabled. Please try back in an hour" msgstr "" diff --git a/lms/overrides/user.py b/lms/overrides/user.py index da1d416b..6117c364 100644 --- a/lms/overrides/user.py +++ b/lms/overrides/user.py @@ -17,6 +17,7 @@ class CustomUser(User): self.validate_username_duplicates() def after_insert(self): + super().after_insert() self.add_roles("LMS Student") def validate_username_duplicates(self): diff --git a/lms/public/images/desk.png b/lms/public/images/desk.png new file mode 100644 index 00000000..f4a09599 Binary files /dev/null and b/lms/public/images/desk.png differ