Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: misc issues #1133

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion frontend/src/components/AppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ watch(userResource, () => {
})

const toggleSidebar = () => {
console.log(sidebarStore.isSidebarCollapsed)
sidebarStore.isSidebarCollapsed = !sidebarStore.isSidebarCollapsed
}
</script>
16 changes: 1 addition & 15 deletions frontend/src/components/Modals/ChapterModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
>
<template #body-content>
<div class="space-y-4 text-base">
<FormControl
ref="chapterInput"
label="Title"
v-model="chapter.title"
:required="true"
/>
<FormControl label="Title" v-model="chapter.title" :required="true" />
<FormControl
:label="__('Is SCORM Package')"
v-model="chapter.is_scorm_package"
Expand Down Expand Up @@ -83,7 +78,6 @@ import { FileText, X } from 'lucide-vue-next'

const show = defineModel()
const outline = defineModel('outline')
const chapterInput = ref(null)

const props = defineProps({
course: {
Expand Down Expand Up @@ -209,14 +203,6 @@ watch(
}
)

/* watch(show, () => {
if (show.value) {
setTimeout(() => {
chapterInput.value.$el.querySelector('input').focus()
}, 100)
}
}) */

const validateFile = (file) => {
let extension = file.name.split('.').pop().toLowerCase()
if (extension !== 'zip') {
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/components/Modals/Question.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
id="existing"
value="existing"
v-model="questionType"
class="w-3 h-3 accent-gray-900"
class="w-3 h-3 cursor-pointer"
/>
<label for="existing">
<label for="existing" class="cursor-pointer">
{{ __('Add an existing question') }}
</label>
</div>
Expand All @@ -25,9 +25,9 @@
id="new"
value="new"
v-model="questionType"
class="w-3 h-3"
class="w-3 h-3 cursor-pointer"
/>
<label for="new">
<label for="new" class="cursor-pointer">
{{ __('Create a new question') }}
</label>
</div>
Expand Down Expand Up @@ -127,7 +127,7 @@ const populateFields = () => {
let counter = 1
fields.forEach((field) => {
while (counter <= 4) {
question[`${field}_${counter}`] = field === 'is_correct' ? false : ''
question[`${field}_${counter}`] = field === 'is_correct' ? false : null
counter++
}
})
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/Courses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
</FormControl>
</div>
<router-link
v-if="user.data?.is_moderator || user.data?.is_instructor"
:to="{
name: 'CourseForm',
params: {
courseName: 'new',
},
}"
>
<Button v-if="user.data?.is_moderator" variant="solid">
<Button variant="solid">
<template #prefix>
<Plus class="h-4 w-4" />
</template>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/pages/QuizForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
v-slot="{ idx, column, item }"
v-for="row in quiz.questions"
@click="openQuestionModal(row)"
class="cursor-pointer"
>
<ListRowItem :item="item">
<div
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/pages/SCORMChapter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ onBeforeMount(() => {
Initialize: () => 'true',
Terminate: () => 'true',
GetValue: (key) => {
console.log(`GetValue called for key: ${key}`)
console.log(`GET: ${key}`)
return getDataFromLMS(key)
},
SetValue: (key, value) => {
console.log(`SetValue called for key: ${key} to value: ${value}`)
console.log(`SET: ${key} to value: ${value}`)

saveDataToLMS(key, value)
return 'true'
Expand All @@ -96,7 +96,6 @@ onBeforeMount(() => {
LMSGetErrorString: () => '',
LMSGetDiagnostic: () => '',
}
console.log(window.API_1484_11)
})

const getDataFromLMS = (key) => {
Expand Down
6 changes: 6 additions & 0 deletions lms/lms/doctype/lms_question/lms_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def validate(self):
def validate_correct_answers(question):
if question.type == "Choices":
validate_duplicate_options(question)
validate_minimum_options(question)
validate_correct_options(question)
elif question.type == "User Input":
validate_possible_answer(question)
Expand All @@ -42,6 +43,11 @@ def validate_correct_options(question):
frappe.throw(_("At least one option must be correct for this question."))


def validate_minimum_options(question):
if question.type == "Choices" and (not question.option_1 or not question.option_2):
frappe.throw(_("Minimum two options are required for multiple choice questions."))


def validate_possible_answer(question):
possible_answers = []
possible_answers_fields = [
Expand Down
Loading