Add Moodle student roster import
This commit is contained in:
1 parent
6faf00a68f
commit
1077d67346
8 files changed
+110
-7
No files matched your search
@@ -5,6 +5,8 @@ export default {
|
||||
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",
|
||||
batchCreate: "Create Moodle courses", batchConfirm: "Create hidden, empty courses for {count} selected tasks? Teachers and students will not be enrolled automatically.", batchResult: "Course creation results", batchSuccess: "Created or recovered {count} courses.", unavailable: "Configure the Moodle service first.",
|
||||
syncTeachers: "Sync teachers", syncConfirm: "Match teacher numbers to Moodle usernames and enrol teachers. Existing teachers will not be removed. Continue?", syncSuccess: "Teachers synced to Moodle",
|
||||
students: "Import Moodle students", studentsConfirm: "Enrol the current class roster by matching student numbers to Moodle usernames. Existing students will not be removed. Continue?", studentsDone: "Processed {count} students",
|
||||
studentsBatch: "Import Moodle students in bulk", studentsBatchConfirm: "Import current student rosters for {count} linked classes? Existing students will not be removed.", studentsBatchDone: "Processed {count} classes.",
|
||||
copy: "Copy existing course", copyHint: "Enter the numeric ID of the Moodle course to copy. Users and their records are excluded. If the copy times out, check Moodle before retrying.", invalidTemplate: "Enter a positive numeric course ID", copied: "Moodle course copied and linked",
|
||||
},
|
||||
selectionTemplate: {
|
||||
|
||||
@@ -5,6 +5,8 @@ export default {
|
||||
create: "创建空课程", createConfirm: "将在 Moodle 创建隐藏的空课程并关联当前教学任务。教师和学生尚不会自动加入,确认继续?", created: "Moodle 课程已创建并关联",
|
||||
batchCreate: "批量创建 Moodle 课程", batchConfirm: "将为选中的 {count} 个未关联教学任务创建隐藏的空课程,不会自动加入教师或学生。确认继续?", batchResult: "批量创建结果", batchSuccess: "已创建或恢复关联 {count} 门课程。", unavailable: "请先配置 Moodle 服务。",
|
||||
syncTeachers: "同步授课教师", syncConfirm: "按工号匹配 Moodle 用户名并加入授课教师;不会移除 Moodle 中已有的教师。确认继续?", syncSuccess: "授课教师已同步至 Moodle",
|
||||
students: "导入 Moodle 学生", studentsConfirm: "按当前教学班名单和学号匹配 Moodle 用户名并加入课程;已有学生不会被移除。确认继续?", studentsDone: "已处理 {count} 名学生",
|
||||
studentsBatch: "批量导入 Moodle 学生", studentsBatchConfirm: "为选中的 {count} 个已关联教学班导入当前学生名单;不会移除已有学生。确认继续?", studentsBatchDone: "已处理 {count} 个教学班。",
|
||||
copy: "复制历史课程", copyHint: "请输入 Moodle 历史课程的数字 ID。复制不包含旧用户及其记录;如复制超时,请先在 Moodle 检查结果。", invalidTemplate: "请输入正整数课程 ID", copied: "Moodle 历史课程已复制并关联",
|
||||
},
|
||||
selectionTemplate: {
|
||||
|
||||
@@ -14,6 +14,20 @@ const selectedTask = ref<any>(null)
|
||||
const roster = ref<any>(null)
|
||||
const termId = ref<string>()
|
||||
const { locale, t } = useI18n()
|
||||
const moodleStudentSync = ref(false)
|
||||
const syncingMoodle = ref(false)
|
||||
|
||||
async function syncMoodleStudents() {
|
||||
if (!selectedTask.value) return
|
||||
try {
|
||||
await ElMessageBox.confirm(t('moodle.studentsConfirm'), t('moodle.students'), { type: 'warning' })
|
||||
syncingMoodle.value = true
|
||||
const result = await http.post(`/moodle-courses/teaching-tasks/${selectedTask.value.id}/students`)
|
||||
ElMessage.success(t('moodle.studentsDone', { count: result.data.count }))
|
||||
} catch (error) {
|
||||
if (error !== 'cancel' && error !== 'close') ElMessage.error(apiErrorMessage(error))
|
||||
} finally { syncingMoodle.value = false }
|
||||
}
|
||||
let rosterRequest = 0
|
||||
|
||||
async function loadTasks() {
|
||||
@@ -66,6 +80,7 @@ async function exportRoster() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try { moodleStudentSync.value = (await http.get('/moodle-courses/availability')).data.studentSync } catch { moodleStudentSync.value = false }
|
||||
terms.value = (await http.get('/base-data/terms')).data
|
||||
termId.value = defaultAcademicTermId(terms.value)
|
||||
await loadTasks()
|
||||
@@ -111,6 +126,7 @@ onMounted(async () => {
|
||||
<el-empty v-if="!selectedTask" :description="t('teacherRoster.selectTask')" />
|
||||
<div v-if="selectedTask?.moodleCourseUrl" class="moodle-course-link">
|
||||
<a :href="selectedTask.moodleCourseUrl" target="_blank" rel="noopener noreferrer">{{ t('moodle.open') }} ↗</a>
|
||||
<el-button v-if="moodleStudentSync" link type="primary" :loading="syncingMoodle" @click="syncMoodleStudents">{{ t('moodle.students') }}</el-button>
|
||||
</div>
|
||||
<template v-if="selectedTask && roster">
|
||||
<header class="roster-head">
|
||||
|
||||
Loaded 3 of 8 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user