Compare commits

..

4 Commits

Author SHA1 Message Date
Jannat Patel
471e7d9229 fix: fetch question details 2024-08-01 13:00:37 +05:30
Jannat Patel
b8c3bdc0b4 feat: open modal to edit question 2024-07-31 11:07:46 +05:30
Jannat Patel
a450c846a6 feat: questions table 2024-07-29 19:44:04 +05:30
Jannat Patel
fa774b0db2 feat: quiz creation 2024-07-19 20:05:28 +05:30
25 changed files with 824 additions and 527 deletions

View File

@@ -1,32 +0,0 @@
name: Generate Semantic Release
on:
workflow_dispatch:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Entire Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup dependencies
run: |
npm install @semantic-release/git @semantic-release/exec --no-save
- name: Create Release
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
GIT_AUTHOR_NAME: "Frappe PR Bot"
GIT_AUTHOR_EMAIL: "developers@frappe.io"
GIT_COMMITTER_NAME: "Frappe PR Bot"
GIT_COMMITTER_EMAIL: "developers@frappe.io"
run: npx semantic-release

View File

@@ -1,39 +0,0 @@
# This action:
#
# 1. Generates release notes using github API.
# 2. Strips unnecessary info like chore/style etc from notes.
# 3. Updates release info.
name: 'Release Notes'
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag of release like v2.0.0'
required: true
type: string
release:
types: [released]
permissions:
contents: read
jobs:
regen-notes:
name: 'Regenerate release notes'
runs-on: ubuntu-latest
steps:
- name: Update notes
run: |
NEW_NOTES=$(gh api --method POST -H "Accept: application/vnd.github+json" /repos/frappe/lms/releases/generate-notes -f tag_name=$RELEASE_TAG \
| jq -r '.body' \
| sed -E '/^\* (chore|ci|test|docs|style)/d' \
| sed -E 's/by @mergify //'
)
RELEASE_ID=$(gh api -H "Accept: application/vnd.github+json" /repos/frappe/lms/releases/tags/$RELEASE_TAG | jq -r '.id')
gh api --method PATCH -H "Accept: application/vnd.github+json" /repos/frappe/lms/releases/$RELEASE_ID -f body="$NEW_NOTES"
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
RELEASE_TAG: ${{ github.event.inputs.tag_name || github.event.release.tag_name }}

1
.gitignore vendored
View File

@@ -12,3 +12,4 @@ node_modules
package-lock.json package-lock.json
lms/public/frontend lms/public/frontend
lms/www/lms.html lms/www/lms.html
frappe-ui

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "frappe-ui"]
path = frappe-ui
url = https://github.com/pateljannat/frappe-ui

View File

@@ -1,21 +0,0 @@
{
"branches": ["develop"],
"plugins": [
"@semantic-release/commit-analyzer", {
"preset": "angular"
},
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec", {
"prepareCmd": 'sed -ir "s/[0-9]*\.[0-9]*\.[0-9]*/${nextRelease.version}/" lms/__init__.py'
}
],
[
"@semantic-release/git", {
"assets": ["lms/__init__.py"],
"message": "chore(release): Bumped to Version ${nextRelease.version}"
}
],
"@semantic-release/github"
]
}

1
frappe-ui Submodule

Submodule frappe-ui added at a349ab070a

View File

@@ -3,7 +3,7 @@
class="flex flex-col shadow hover:bg-gray-100 rounded-md p-4 h-full" class="flex flex-col shadow hover:bg-gray-100 rounded-md p-4 h-full"
style="min-height: 150px" style="min-height: 150px"
> >
<div class="text-lg leading-5 font-semibold mb-2"> <div class="text-xl font-semibold mb-2">
{{ batch.title }} {{ batch.title }}
</div> </div>
<Badge <Badge
@@ -22,17 +22,18 @@
> >
{{ __('Sold Out') }} {{ __('Sold Out') }}
</Badge> </Badge>
<div class="short-introduction text-sm text-gray-700"> <div class="short-introduction">
{{ batch.description }} {{ batch.description }}
</div> </div>
<div v-if="batch.amount" class="font-semibold mb-4"> <div class="flex flex-col space-y-2 mt-auto">
<div v-if="batch.amount" class="font-semibold text-lg">
{{ batch.price }} {{ batch.price }}
</div> </div>
<div class="flex flex-col space-y-2 mt-auto">
<DateRange <DateRange
:startDate="batch.start_date" :startDate="batch.start_date"
:endDate="batch.end_date" :endDate="batch.end_date"
class="text-sm text-gray-700" class="text-sm text-gray-700 mb-3"
/> />
<div class="flex items-center text-sm text-gray-700"> <div class="flex items-center text-sm text-gray-700">
<Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" /> <Clock class="h-4 w-4 stroke-1.5 mr-2 text-gray-700" />
@@ -49,11 +50,7 @@
{{ batch.timezone }} {{ batch.timezone }}
</span> </span>
</div> </div>
</div> <div v-if="batch.instructors?.length" class="flex avatar-group overlap">
<div
v-if="batch.instructors?.length"
class="flex avatar-group overlap mt-4"
>
<div <div
class="h-6 mr-1" class="h-6 mr-1"
:class="{ 'avatar-group overlap': batch.instructors.length > 1 }" :class="{ 'avatar-group overlap': batch.instructors.length > 1 }"
@@ -66,6 +63,7 @@
<CourseInstructors :instructors="batch.instructors" /> <CourseInstructors :instructors="batch.instructors" />
</div> </div>
</div> </div>
</div>
</template> </template>
<script setup> <script setup>
import { Badge } from 'frappe-ui' import { Badge } from 'frappe-ui'
@@ -90,7 +88,7 @@ const props = defineProps({
text-overflow: ellipsis; text-overflow: ellipsis;
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
margin: 0.25rem 0 1rem; margin: 0.25rem 0 1.25rem;
line-height: 1.5; line-height: 1.5;
} }

View File

@@ -72,7 +72,7 @@
{{ course.title }} {{ course.title }}
</div> </div>
<div class="short-introduction text-gray-700 text-sm"> <div class="short-introduction">
{{ course.short_introduction }} {{ course.short_introduction }}
</div> </div>

View File

@@ -0,0 +1,147 @@
<template>
<Dialog v-model="show" :options="dialogOptions">
<template #body-content>
<div class="space-y-4">
<div>
<label class="block text-xs text-gray-600 mb-1">
{{ __('Question') }}
</label>
<TextEditor
:content="question.question"
@change="(val) => (question.question = 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]"
/>
</div>
<FormControl
:label="__('Type')"
v-model="question.type"
type="select"
:options="['Choices', 'User Input']"
class="pb-2"
/>
<div v-if="question.type == 'Choices'" class="divide-y">
<div v-for="n in 4" class="space-y-4 py-2">
<FormControl
:label="__('Option') + ' ' + n"
v-model="question[`option_${n}`]"
/>
<FormControl
:label="__('Explanation')"
v-model="question[`explanation_${n}`]"
/>
<FormControl
:label="__('Correct Answer')"
v-model="question[`correct_answer_${n}`]"
type="checkbox"
/>
</div>
</div>
<div v-else v-for="n in 4" class="space-y-2">
<FormControl
:label="__('Possibility') + ' ' + n"
v-model="question[`possibility_${n}`]"
/>
</div>
</div>
</template>
</Dialog>
</template>
<script setup>
import { Dialog, FormControl, TextEditor, createResource } from 'frappe-ui'
import { computed, onMounted, reactive, inject } from 'vue'
const show = defineModel()
const user = inject('$user')
const question = reactive({
question: '',
type: 'Choices',
})
onMounted(() => {
populateFields()
console.log(props.questionName)
if (
props.questionName == 'new' &&
!user.data?.is_moderator &&
!user.data?.is_instructor
) {
router.push({ name: 'Courses' })
}
if (props.courseName !== 'new') {
questionDoc.reload()
}
window.addEventListener('keydown', keyboardShortcut)
})
const props = defineProps({
title: {
type: String,
default: __('Add a Question'),
},
questionName: {
type: String,
},
})
const questionDoc = createResource({
url: 'frappe.client.get',
makeParams: (values) => {
return {
doctype: 'LMS Question',
name: props.questionName,
}
},
onSuccess(data) {
let counter = 1
Object.keys(data).forEach((key) => {
if (Object.hasOwn(question, key)) question[key] = data[key]
})
while (counter <= 4) {
question[`is_correct_${counter}`] = question[`is_correct_${counter}`]
? true
: false
}
},
})
const populateFields = () => {
let fields = ['option', 'correct_answer', 'explanation', 'possibility']
let counter = 1
fields.forEach((field) => {
while (counter <= 4) {
question[`${field}_${counter}`] = field === 'correct_answer' ? false : ''
counter++
}
})
}
const keyboardShortcut = (e) => {
if (
e.key === 's' &&
(e.ctrlKey || e.metaKey) &&
!e.target.classList.contains('ProseMirror')
) {
submitQuestion()
e.preventDefault()
}
}
const dialogOptions = computed(() => {
return {
title: __(props.title),
size: 'xl',
actions: [
{
label: __('Submit'),
variant: 'solid',
onClick: (close) => {
submitQuestion(close)
},
},
],
}
})
</script>

View File

@@ -3,7 +3,9 @@
<div class="bg-blue-100 py-2 px-2 mb-4 rounded-md text-sm text-blue-800"> <div class="bg-blue-100 py-2 px-2 mb-4 rounded-md text-sm text-blue-800">
<div class="leading-relaxed"> <div class="leading-relaxed">
{{ {{
__('This quiz consists of {0} questions.').format(questions.length) __('This quiz consists of {0} questions.').format(
quiz.data.questions.length
)
}} }}
</div> </div>
<div v-if="quiz.data.passing_percentage" class="leading-relaxed"> <div v-if="quiz.data.passing_percentage" class="leading-relaxed">
@@ -57,7 +59,7 @@
</div> </div>
</div> </div>
<div v-else-if="!quizSubmission.data"> <div v-else-if="!quizSubmission.data">
<div v-for="(question, qtidx) in questions"> <div v-for="(question, qtidx) in quiz.data.questions">
<div <div
v-if="qtidx == activeQuestion - 1 && questionDetails.data" v-if="qtidx == activeQuestion - 1 && questionDetails.data"
class="border rounded-md p-5" class="border rounded-md p-5"
@@ -164,7 +166,7 @@
{{ {{
__('Question {0} of {1}').format( __('Question {0} of {1}').format(
activeQuestion, activeQuestion,
questions.length quiz.data.questions.length
) )
}} }}
</div> </div>
@@ -177,7 +179,7 @@
</span> </span>
</Button> </Button>
<Button <Button
v-else-if="activeQuestion != questions.length" v-else-if="activeQuestion != quiz.data.questions.length"
@click="nextQuetion()" @click="nextQuetion()"
> >
<span> <span>
@@ -248,7 +250,6 @@ 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([])
let questions = reactive([])
const possibleAnswer = ref(null) const possibleAnswer = ref(null)
const props = defineProps({ const props = defineProps({
@@ -269,30 +270,15 @@ const quiz = createResource({
cache: ['quiz', props.quizName], cache: ['quiz', props.quizName],
auto: true, auto: true,
onSuccess(data) { onSuccess(data) {
populateQuestions() if (data.shuffle_questions) {
data.questions = data.questions.sort(() => Math.random() - 0.5)
}
if (data.limit_questions_to) {
data.questions = data.questions.slice(0, data.limit_questions_to)
}
}, },
}) })
const populateQuestions = () => {
let data = quiz.data
if (data.shuffle_questions) {
questions = shuffleArray(data.questions)
if (data.limit_questions_to) {
questions = questions.slice(0, data.limit_questions_to)
}
} else {
questions = data.questions
}
}
const shuffleArray = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))
;[array[i], array[j]] = [array[j], array[i]]
}
return array
}
const attempts = createResource({ const attempts = createResource({
url: 'frappe.client.get_list', url: 'frappe.client.get_list',
makeParams(values) { makeParams(values) {
@@ -324,7 +310,7 @@ const attempts = createResource({
watch( watch(
() => quiz.data, () => quiz.data,
() => { () => {
if (quiz.data && quiz.data.max_attempts) { if (quiz.data) {
attempts.reload() attempts.reload()
resetQuiz() resetQuiz()
} }
@@ -478,7 +464,7 @@ const submitQuiz = () => {
const createSubmission = () => { const createSubmission = () => {
quizSubmission.reload().then(() => { quizSubmission.reload().then(() => {
if (quiz.data && quiz.data.max_attempts) attempts.reload() attempts.reload()
}) })
} }
@@ -487,7 +473,6 @@ const resetQuiz = () => {
selectedOptions.splice(0, selectedOptions.length, ...[0, 0, 0, 0]) selectedOptions.splice(0, selectedOptions.length, ...[0, 0, 0, 0])
showAnswers.length = 0 showAnswers.length = 0
quizSubmission.reset() quizSubmission.reset()
populateQuestions()
} }
const getSubmissionColumns = () => { const getSubmissionColumns = () => {

View File

@@ -50,9 +50,9 @@
</Button> </Button>
</div> </div>
</header> </header>
<div v-if="job.data" class="max-w-3xl mx-auto"> <div v-if="job.data" class="w-3/4 mx-auto">
<div class="p-4"> <div class="p-4">
<div class="flex mb-10"> <div class="flex mb-4">
<img <img
:src="job.data.company_logo" :src="job.data.company_logo"
class="w-16 h-16 rounded-lg object-contain mr-4" class="w-16 h-16 rounded-lg object-contain mr-4"
@@ -62,9 +62,8 @@
<div class="text-2xl font-semibold mb-4"> <div class="text-2xl font-semibold mb-4">
{{ job.data.job_title }} {{ job.data.job_title }}
</div> </div>
<div <div class="grid grid-cols-3 gap-8">
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-x-10 gap-y-2 md:gap-y-4" <div class="grid grid-cols-1 gap-2">
>
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<Building2 class="h-4 w-4 stroke-1.5" /> <Building2 class="h-4 w-4 stroke-1.5" />
<span>{{ job.data.company_name }}</span> <span>{{ job.data.company_name }}</span>
@@ -73,16 +72,20 @@
<MapPin class="h-4 w-4 stroke-1.5" /> <MapPin class="h-4 w-4 stroke-1.5" />
<span>{{ job.data.location }}</span> <span>{{ job.data.location }}</span>
</div> </div>
</div>
<div class="grid grid-cols-1 gap-2">
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<ClipboardType class="h-4 w-4 stroke-1.5" /> <ClipboardType class="h-4 w-4 stroke-1.5" />
<span>{{ job.data.type }}</span> <span>{{ job.data.type }}</span>
</div> </div>
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<CalendarDays class="h-4 w-4 stroke-1.5" /> <CalendarDays class="h-4 w-4 stroke-1.5" />
<span> <span>{{
{{ dayjs(job.data.creation).format('DD MMM YYYY') }} dayjs(job.data.creation).format('DD MMM YYYY')
</span> }}</span>
</div> </div>
</div>
<div class="grid grid-cols-1 h-fit">
<div <div
v-if="applicationCount.data" v-if="applicationCount.data"
class="flex items-center space-x-2" class="flex items-center space-x-2"
@@ -96,6 +99,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<p <p
v-html="job.data.description" v-html="job.data.description"
class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal mt-6" class="ProseMirror prose prose-table:table-fixed prose-td:p-2 prose-th:p-2 prose-td:border prose-th:border prose-td:border-gray-300 prose-th:border-gray-300 prose-td:relative prose-th:relative prose-th:bg-gray-100 prose-sm max-w-none !whitespace-normal mt-6"

View File

@@ -0,0 +1,209 @@
<template>
<header
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
>
<Breadcrumbs :items="breadcrumbs" />
</header>
<div class="w-3/4 mx-auto py-5">
<!-- Details -->
<div class="mb-8">
<div class="text-sm font-semibold mb-4">
{{ __('Details') }}
</div>
<div class="grid grid-cols-2 gap-5">
<div class="space-y-2">
<FormControl v-model="quiz.title" :label="__('Title')" />
<FormControl
v-model="quiz.max_attempts"
:label="__('Maximun Attempts')"
/>
<FormControl
v-model="quiz.limit_questions_to"
:label="__('Limit Questions To')"
/>
</div>
<div class="space-y-2">
<FormControl v-model="quiz.total_marks" :label="__('Total Marks')" />
<FormControl
v-model="quiz.passing_percentage"
:label="__('Passing Percentage')"
/>
</div>
</div>
</div>
<!-- Settings -->
<div class="mb-8">
<div class="text-sm font-semibold mb-4">
{{ __('Settings') }}
</div>
<div class="grid grid-cols-3 gap-5 my-4">
<FormControl
v-model="quiz.show_answers"
type="checkbox"
:label="__('Show Answers')"
/>
<FormControl
v-model="quiz.show_submission_history"
type="checkbox"
:label="__('Show Submission History')"
/>
<FormControl
v-model="quiz.shuffle_questions"
type="checkbox"
:label="__('Shuffle Questions')"
/>
</div>
</div>
<!-- Questions -->
<div>
<div class="flex items-center justify-between mb-4">
<div class="text-sm font-semibold">
{{ __('Questions') }}
</div>
<Button @click="openQuestionModal()">
<template #prefix>
<Plus class="w-4 h-4" />
</template>
{{ __('New Question') }}
</Button>
</div>
<ListView
:columns="questionColumns"
:rows="quiz.questions"
row-key="name"
:options="{
showTooltip: false,
}"
>
<ListHeader
class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2"
>
<ListHeaderItem :item="item" v-for="item in questionColumns" />
</ListHeader>
<ListRows>
<ListRow
:row="row"
v-slot="{ idx, column, item }"
v-for="row in quiz.questions"
@click="openQuestionModal(row.question)"
>
<ListRowItem :item="item">
<div
v-if="column.key == 'question_detail'"
class="text-xs truncate"
>
{{ item }}
</div>
<div v-else class="text-xs">
{{ item }}
</div>
</ListRowItem>
</ListRow>
</ListRows>
</ListView>
</div>
</div>
<Question v-model="showQuestionModal" :questionName="currentQuestion" />
</template>
<script setup>
import {
Breadcrumbs,
createDocumentResource,
FormControl,
ListView,
ListHeader,
ListHeaderItem,
ListRows,
ListRow,
ListRowItem,
Button,
} from 'frappe-ui'
import { computed, reactive, ref } from 'vue'
import { Plus } from 'lucide-vue-next'
import Question from '@/components/Modals/Question.vue'
const showQuestionModal = ref(false)
const currentQuestion = ref(null)
const props = defineProps({
quizID: {
type: String,
required: true,
},
})
const quiz = reactive({
title: '',
total_marks: '',
passing_percentage: '',
max_attempts: 0,
limit_questions_to: 0,
show_answers: true,
show_submission_history: false,
shuffle_questions: false,
questions: [],
})
const quizDetails = createDocumentResource({
doctype: 'LMS Quiz',
name: props.quizID,
auto: true,
cache: ['quiz', props.quizID],
onSuccess(data) {
Object.keys(data).forEach((key) => {
if (Object.hasOwn(quiz, key)) quiz[key] = data[key]
})
let checkboxes = [
'show_answers',
'show_submission_history',
'shuffle_questions',
]
for (let idx in checkboxes) {
let key = checkboxes[idx]
quiz[key] = quiz[key] ? true : false
}
},
})
const questionColumns = computed(() => {
return [
{
label: __('ID'),
key: 'question',
width: '25%',
},
{
label: __('Question'),
key: __('question_detail'),
width: '60%',
},
{
label: __('Marks'),
key: 'marks',
width: '10%',
},
]
})
const openQuestionModal = (question = null) => {
console.log('called')
console.log(question)
currentQuestion.value = question
showQuestionModal.value = true
}
const breadcrumbs = computed(() => {
let crumbs = [
{
label: __('Quizzes'),
route: {
name: 'Quizzes',
},
},
]
return crumbs
})
</script>

View File

@@ -0,0 +1,108 @@
<template>
<header
class="sticky top-0 z-10 flex items-center justify-between border-b bg-white px-3 py-2.5 sm:px-5"
>
<Breadcrumbs :items="breadcrumbs" />
<Button variant="solid">
<template #prefix>
<Plus class="w-4 h-4"/>
</template>
{{ __('New Quiz') }}
</Button>
</header>
<div v-if="quizzes.data?.length" class="w-3/4 mx-auto py-5">
<ListView
:columns="quizColumns"
:rows="quizzes.data"
row-key="name"
:options="{ showTooltip: false, selectable: false }"
>
<ListHeader
class="mb-2 grid items-center space-x-4 rounded bg-gray-100 p-2"
>
<ListHeaderItem :item="item" v-for="item in quizColumns">
</ListHeaderItem>
</ListHeader>
<ListRows>
<router-link
v-for="row in quizzes.data"
:to="{
name: 'QuizCreation',
params: {
quizID: row.name,
},
}"
>
<ListRow :row="row" />
</router-link>
</ListRows>
</ListView>
</div>
</template>
<script setup>
import {
Breadcrumbs,
createListResource,
ListView,
ListRows,
ListRow,
ListHeader,
ListHeaderItem,
Button,
} from 'frappe-ui'
import { computed, inject } from 'vue'
import { Plus } from 'lucide-vue-next'
const user = inject('$user')
const quizFilter = computed(() => {
if (user.data?.is_moderator) return {}
return {
owner: user.data?.name,
}
})
const quizzes = createListResource({
doctype: 'LMS Quiz',
filters: quizFilter,
fields: ['name', 'title', 'passing_percentage', 'total_marks'],
auto: true,
cache: ['quizzes', user.data?.name],
onSuccess(data) {
data.forEach((row) => {})
},
})
const quizColumns = computed(() => {
return [
{
label: __('Title'),
key: 'title',
width: 2,
},
{
label: __('Total Marks'),
key: 'total_marks',
width: 1,
align: 'center',
},
{
label: __('Passing Percentage'),
key: 'passing_percentage',
width: 1,
align: 'center',
},
]
})
const breadcrumbs = computed(() => {
return [
{
label: __('Quizzes'),
route: {
name: 'Quizzes',
},
},
]
})
</script>

View File

@@ -141,6 +141,17 @@ const routes = [
component: () => import('@/pages/Badge.vue'), component: () => import('@/pages/Badge.vue'),
props: true, props: true,
}, },
{
path: '/quizzes',
name: 'Quizzes',
component: () => import('@/pages/Quizzes.vue'),
},
{
path: '/quizzes/:quizID',
name: 'QuizCreation',
component: () => import('@/pages/QuizCreation.vue'),
props: true,
},
] ]
let router = createRouter({ let router = createRouter({

View File

@@ -2,6 +2,7 @@ import { createResource } from 'frappe-ui'
export default function translationPlugin(app) { export default function translationPlugin(app) {
app.config.globalProperties.__ = translate app.config.globalProperties.__ = translate
window.__ = translate
if (!window.translatedMessages) fetchTranslations() if (!window.translatedMessages) fetchTranslations()
} }

View File

@@ -68,13 +68,6 @@
dependencies: dependencies:
"@codexteam/icons" "^0.0.5" "@codexteam/icons" "^0.0.5"
"@editorjs/image@^2.9.2":
version "2.9.2"
resolved "https://registry.yarnpkg.com/@editorjs/image/-/image-2.9.2.tgz#c8bea65a578fab65a1a75df1223b4fd8f06b57d5"
integrity sha512-n09sMieGW8cksoeflpplzvbmFH2bdVzVTWbnidPWAHaeU467HRteoXU9yfGBB7+eeHZLnmCulQ2dr6ae+G2niw==
dependencies:
"@codexteam/icons" "^0.3.0"
"@editorjs/inline-code@^1.5.0": "@editorjs/inline-code@^1.5.0":
version "1.5.0" version "1.5.0"
resolved "https://registry.yarnpkg.com/@editorjs/inline-code/-/inline-code-1.5.0.tgz#ad5849bac3396b9dad22dceeda76198dd991e426" resolved "https://registry.yarnpkg.com/@editorjs/inline-code/-/inline-code-1.5.0.tgz#ad5849bac3396b9dad22dceeda76198dd991e426"
@@ -1882,8 +1875,16 @@ source-map-js@^1.2.0:
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af" resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af"
integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg== integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0: "string-width-cjs@npm:string-width@^4.2.0":
name string-width-cjs version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
string-width@^4.1.0:
version "4.2.3" version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -1901,8 +1902,14 @@ string-width@^5.0.1, string-width@^5.1.2:
emoji-regex "^9.2.2" emoji-regex "^9.2.2"
strip-ansi "^7.0.1" strip-ansi "^7.0.1"
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: "strip-ansi-cjs@npm:strip-ansi@^6.0.1":
name strip-ansi-cjs version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1" version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==

View File

@@ -176,10 +176,7 @@ update_website_context = [
] ]
jinja = { jinja = {
"methods": [ "methods": ["lms.lms.utils.get_signup_optin_checks"],
"lms.lms.utils.get_signup_optin_checks",
"lms.lms.utils.get_tags",
],
"filters": [], "filters": [],
} }
## Specify the additional tabs to be included in the user profile page. ## Specify the additional tabs to be included in the user profile page.

View File

@@ -26,6 +26,9 @@ class LMSCertificateRequest(Document):
self.validate_if_existing_requests() self.validate_if_existing_requests()
self.validate_evaluation_end_date() self.validate_evaluation_end_date()
def after_insert(self):
self.send_notification()
def set_evaluator(self): def set_evaluator(self):
if not self.evaluator: if not self.evaluator:
self.evaluator = get_evaluator(self.course, self.batch_name) self.evaluator = get_evaluator(self.course, self.batch_name)
@@ -56,7 +59,6 @@ class LMSCertificateRequest(Document):
"evaluator": self.evaluator, "evaluator": self.evaluator,
"date": self.date, "date": self.date,
"start_time": self.start_time, "start_time": self.start_time,
"member": ["!=", self.member],
}, },
): ):
frappe.throw(_("The slot is already booked by another participant.")) frappe.throw(_("The slot is already booked by another participant."))
@@ -108,6 +110,35 @@ class LMSCertificateRequest(Document):
) )
) )
def send_notification(self):
outgoing_email_account = frappe.get_cached_value(
"Email Account", {"default_outgoing": 1, "enable_outgoing": 1}, "name"
)
if outgoing_email_account or frappe.conf.get("mail_login"):
subject = _("Your evaluation slot has been booked")
template = "certificate_request_notification"
args = {
"course": frappe.db.get_value("LMS Course", self.course, "title"),
"timezone": frappe.db.get_value("LMS Batch", self.batch_name, "timezone")
if self.batch_name
else "",
"date": format_date(self.date, "medium"),
"member_name": self.member_name,
"start_time": format_time(self.start_time, "short"),
"evaluator": frappe.db.get_value("User", self.evaluator, "full_name"),
}
frappe.sendmail(
recipients=[self.member],
cc=[self.evaluator],
subject=subject,
template=template,
args=args,
header=[subject, "green"],
retry=3,
)
def schedule_evals(): def schedule_evals():
if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"): if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"):

View File

@@ -196,7 +196,7 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"make_attachments_public": 1, "make_attachments_public": 1,
"modified": "2024-08-01 13:01:55.000072", "modified": "2024-08-01 12:53:22.540990",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Question", "name": "LMS Question",

View File

@@ -74,6 +74,7 @@
"default": "1", "default": "1",
"fieldname": "show_answers", "fieldname": "show_answers",
"fieldtype": "Check", "fieldtype": "Check",
"in_standard_filter": 1,
"label": "Show Answers" "label": "Show Answers"
}, },
{ {
@@ -98,6 +99,8 @@
{ {
"fieldname": "passing_percentage", "fieldname": "passing_percentage",
"fieldtype": "Int", "fieldtype": "Int",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Passing Percentage", "label": "Passing Percentage",
"non_negative": 1, "non_negative": 1,
"reqd": 1 "reqd": 1
@@ -110,6 +113,7 @@
"default": "0", "default": "0",
"fieldname": "total_marks", "fieldname": "total_marks",
"fieldtype": "Int", "fieldtype": "Int",
"in_list_view": 1,
"label": "Total Marks", "label": "Total Marks",
"non_negative": 1, "non_negative": 1,
"read_only": 1, "read_only": 1,
@@ -133,7 +137,7 @@
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2024-06-27 22:03:48.576489", "modified": "2024-07-19 18:21:26.681501",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Quiz", "name": "LMS Quiz",

View File

@@ -6,7 +6,10 @@
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"question", "question",
"marks" "column_break_qcpo",
"marks",
"section_break_huup",
"question_detail"
], ],
"fields": [ "fields": [
{ {
@@ -25,12 +28,28 @@
"label": "Marks", "label": "Marks",
"non_negative": 1, "non_negative": 1,
"reqd": 1 "reqd": 1
},
{
"fetch_from": "question.question",
"fieldname": "question_detail",
"fieldtype": "Text",
"in_list_view": 1,
"label": "Question Detail",
"read_only": 1
},
{
"fieldname": "column_break_qcpo",
"fieldtype": "Column Break"
},
{
"fieldname": "section_break_huup",
"fieldtype": "Section Break"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2023-10-16 19:51:03.893144", "modified": "2024-07-29 15:10:09.662715",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Quiz Question", "name": "LMS Quiz Question",

View File

@@ -6,14 +6,14 @@
"docstatus": 0, "docstatus": 0,
"doctype": "Notification", "doctype": "Notification",
"document_type": "LMS Certificate Request", "document_type": "LMS Certificate Request",
"enabled": 1, "enabled": 0,
"event": "New", "event": "New",
"idx": 0, "idx": 0,
"is_standard": 1, "is_standard": 1,
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n{% set timezone = frappe.db.get_value(\"LMS Batch\", doc.batch, \"timezone\") %}\n{% set timezone = timezone if timezone else '' %}\n{% set evaluator_name = frappe.db.get_value(\"User\", doc.evaluator, \"full_name\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\"), timezone) }}</p>\n<p> {{ _(\"Your evaluator is {0}\").format(evaluator_name) }}\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n", "message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n{% set timezone = frappe.db.get_value(\"LMS Batch\", doc.batch, \"timezone\") %}\n{% set timezone = timezone if timezone else '' %}\n{% set evaluator_name = frappe.db.get_value(\"User\", doc.evaluator, \"full_name\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\"), timezone) }}</p>\n<p> {{ _(\"Your evaluator is {0}\").format(evaluator_name) }} </p>\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
"message_type": "HTML", "message_type": "HTML",
"modified": "2024-07-10 15:51:03.429317", "modified": "2024-08-01 12:17:40.647724",
"modified_by": "sayali@erpnext.com", "modified_by": "jannat@frappe.io",
"module": "LMS", "module": "LMS",
"name": "Certificate Request Creation", "name": "Certificate Request Creation",
"owner": "Administrator", "owner": "Administrator",

View File

@@ -0,0 +1,4 @@
<p> {{ _("Hey {0}").format(member_name) }} </p>
<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2} {3}.').format(title, date, start_time, timezone) }}</p>
<p> {{ _("Your evaluator is {0}").format(evaluator) }} </p>
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>

View File

@@ -2,7 +2,7 @@
"name": "frappe_lms", "name": "frappe_lms",
"version": "1.0.0", "version": "1.0.0",
"description": "Easy to use, open-source, Learning Management System", "description": "Easy to use, open-source, Learning Management System",
"workspaces1": [ "workspaces": [
"frappe-ui", "frappe-ui",
"frontend" "frontend"
], ],
@@ -26,8 +26,5 @@
"devDependencies": { "devDependencies": {
"cypress": "^13.9.0", "cypress": "^13.9.0",
"cypress-file-upload": "^5.0.8" "cypress-file-upload": "^5.0.8"
},
"dependencies": {
"pre-commit": "^1.2.2"
} }
} }

514
yarn.lock

File diff suppressed because it is too large Load Diff