Create Moodle courses from teaching tasks
This commit is contained in:
1 parent
c7786f7c16
commit
d010af26b5
8 files changed
+242
-2
No files matched your search
@@ -2,6 +2,7 @@ export default {
|
||||
moodle: {
|
||||
manage: "Link Moodle", hint: "Paste the HTTPS address of an existing Moodle course. Clear it to unlink. Teachers need access to the course in Moodle.",
|
||||
placeholder: "https://moodle.example.edu/course/view.php?id=123", save: "Save", cancel: "Cancel", saved: "Moodle course link saved", open: "Open Moodle course", linked: "Moodle linked",
|
||||
create: "Create empty course", createConfirm: "Create a hidden, empty Moodle course for this teaching task? Teachers and students will not be enrolled automatically.", created: "Moodle course created and linked",
|
||||
},
|
||||
selectionTemplate: {
|
||||
courseSelection: "Course selection",
|
||||
|
||||
@@ -2,6 +2,7 @@ export default {
|
||||
moodle: {
|
||||
manage: "关联 Moodle", hint: "粘贴已有 Moodle 课程的 HTTPS 地址;留空可解除关联。教师需要具备 Moodle 课程访问权限。",
|
||||
placeholder: "https://moodle.example.edu/course/view.php?id=123", save: "保存", cancel: "取消", saved: "Moodle 课程关联已保存", open: "进入 Moodle 课程", linked: "已关联 Moodle",
|
||||
create: "创建空课程", createConfirm: "将在 Moodle 创建隐藏的空课程并关联当前教学任务。教师和学生尚不会自动加入,确认继续?", created: "Moodle 课程已创建并关联",
|
||||
},
|
||||
selectionTemplate: {
|
||||
courseSelection: "学生选课",
|
||||
|
||||
@@ -33,6 +33,7 @@ const hasMore = ref(false);
|
||||
const dialogVisible = ref(false);
|
||||
const moodleDialog = ref(false);
|
||||
const moodleSaving = ref(false);
|
||||
const moodleAvailable = ref(false);
|
||||
const moodleTask = ref<any>(null);
|
||||
const moodleUrl = ref("");
|
||||
const generationDialog = ref(false);
|
||||
@@ -267,10 +268,29 @@ function canManageRow(row: any) {
|
||||
);
|
||||
}
|
||||
|
||||
function editMoodle(row: any) {
|
||||
async function editMoodle(row: any) {
|
||||
moodleTask.value = row;
|
||||
moodleUrl.value = row.moodleCourseUrl ?? "";
|
||||
moodleDialog.value = true;
|
||||
moodleAvailable.value = false;
|
||||
try {
|
||||
moodleAvailable.value = (await http.get('/moodle-courses/availability')).data.available;
|
||||
} catch { /* Manual linking remains available. */ }
|
||||
}
|
||||
|
||||
async function createMoodle() {
|
||||
try {
|
||||
await ElMessageBox.confirm(t('moodle.createConfirm'), t('moodle.create'), { type: 'warning' });
|
||||
moodleSaving.value = true;
|
||||
await http.post(`/moodle-courses/teaching-tasks/${moodleTask.value.id}`);
|
||||
moodleDialog.value = false;
|
||||
ElMessage.success(t('moodle.created'));
|
||||
await load();
|
||||
} catch (error) {
|
||||
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error));
|
||||
} finally {
|
||||
moodleSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveMoodle() {
|
||||
@@ -810,6 +830,7 @@ onMounted(async () => {
|
||||
<p>{{ t('moodle.hint') }}</p>
|
||||
<el-input v-model="moodleUrl" maxlength="2048" :placeholder="t('moodle.placeholder')" clearable />
|
||||
<template #footer>
|
||||
<el-button v-if="moodleAvailable && moodleTask?.status === 'Published' && !moodleTask?.moodleCourseUrl" :loading="moodleSaving" @click="createMoodle">{{ t('moodle.create') }}</el-button>
|
||||
<el-button @click="moodleDialog = false">{{ t('moodle.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="moodleSaving" @click="saveMoodle">{{ t('moodle.save') }}</el-button>
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user