Add Moodle course links for teaching tasks

This commit is contained in:
biss committed 2026-11-21 13:32:19 +08:00
1 parent aa4bb8f378
commit eacc21fbc7
13 files changed
+13058 -2

No files matched your search

+4 -1
View File
@@ -111,7 +111,10 @@ onMounted(async () => {
<h3>{{ t('teacherRoster.rosterTitle', { course: roster.courseName }) }}</h3>
<p>{{ t('teacherRoster.rosterCount', { count: roster.studentCount, capacity: roster.capacity }) }}</p>
</div>
<el-button :icon="Download" @click="exportRoster">{{ t('teacherRoster.export') }}</el-button>
<div>
<el-button v-if="selectedTask.moodleCourseUrl" tag="a" :href="selectedTask.moodleCourseUrl" target="_blank" rel="noopener noreferrer" type="primary">{{ t('moodle.open') }}</el-button>
<el-button :icon="Download" @click="exportRoster">{{ t('teacherRoster.export') }}</el-button>
</div>
</header>
<el-table :data="roster.students" class="data-table">
<el-table-column :label="t('teacherRoster.studentNumber')" width="135">
+33
View File
@@ -31,6 +31,10 @@ const cursors = ref<string[]>([]);
const nextCursor = ref<string>();
const hasMore = ref(false);
const dialogVisible = ref(false);
const moodleDialog = ref(false);
const moodleSaving = ref(false);
const moodleTask = ref<any>(null);
const moodleUrl = ref("");
const generationDialog = ref(false);
const generating = ref(false);
const editingId = ref("");
@@ -263,6 +267,26 @@ function canManageRow(row: any) {
);
}
function editMoodle(row: any) {
moodleTask.value = row;
moodleUrl.value = row.moodleCourseUrl ?? "";
moodleDialog.value = true;
}
async function saveMoodle() {
moodleSaving.value = true;
try {
await http.put(`/teaching-tasks/${moodleTask.value.id}/moodle-course`, { url: moodleUrl.value.trim() || null });
moodleDialog.value = false;
ElMessage.success(t("moodle.saved"));
await load();
} catch (error) {
ElMessage.error(apiErrorMessage(error));
} finally {
moodleSaving.value = false;
}
}
function courseMatches(item: any, filters: Record<string, any>) {
const keyword = filters.keyword.trim().toLocaleLowerCase();
return (
@@ -782,6 +806,14 @@ onMounted(async () => {
<template>
<div class="page-stack">
<el-dialog v-model="moodleDialog" :title="t('moodle.manage')" width="min(560px, 95vw)">
<p>{{ t('moodle.hint') }}</p>
<el-input v-model="moodleUrl" maxlength="2048" :placeholder="t('moodle.placeholder')" clearable />
<template #footer>
<el-button @click="moodleDialog = false">{{ t('moodle.cancel') }}</el-button>
<el-button type="primary" :loading="moodleSaving" @click="saveMoodle">{{ t('moodle.save') }}</el-button>
</template>
</el-dialog>
<section class="page-intro">
<div>
<span class="section-kicker">TEACHING COMMISSION</span>
@@ -1081,6 +1113,7 @@ onMounted(async () => {
fixed="right"
>
<template #default="{ row }">
<el-button v-if="canManageRow(row)" link type="primary" @click="editMoodle(row)">{{ t('moodle.manage') }}</el-button>
<el-button
v-if="canManageRow(row) && row.status === 'Draft'"
link