diff --git a/README.md b/README.md index 7ab8bd6..e7393c3 100644 --- a/README.md +++ b/README.md @@ -287,13 +287,13 @@ Kubernetes 或密钥管理系统仍可覆盖文件中的值。 手动关联只保存链接,不检查课程是否存在,也不创建 Moodle 账号、同步名单或自动登录。教师须在 Moodle 中已有对应课程的访问权限;如需单点登录,需要分别配置两边的身份认证。部署升级时需应用数据库迁移。 -管理员还可为已发布且尚未关联的教学任务创建 Moodle 空课程。服务端配置 `Moodle__BaseUrl`(HTTPS Moodle 根地址,可含子路径)、`Moodle__CategoryId`(目标分类数字 ID)和 `Moodle__Token`(Moodle Web 服务令牌)后显示创建按钮。请通过环境变量或密钥管理器提供令牌,不要提交到仓库。Moodle 需要启用 REST Web 服务并为服务账户提供 `core_course_get_courses_by_field`、`core_course_create_courses` 及相应分类创建、隐藏课程查看权限。系统使用教学任务 ID 生成课程短名称和 ID 号码,以便请求超时后重试恢复;创建的课程默认隐藏,需要 Moodle 管理员配置教师、内容和可见性。此步骤尚不自动同步用户和名单;教师可以在 Moodle 中从旧课程导入资源。 +管理员可对已发布且尚未关联的教学任务批量匹配或创建 Moodle 课程:系统优先检查旧版本创建的课程,再按教学任务编号匹配 Moodle 课程 ID 号码(idnumber);未找到时创建隐藏空课程,idnumber 设置为教学任务编号。服务端配置 `Moodle__BaseUrl`(HTTPS Moodle 根地址,可含子路径)、`Moodle__CategoryId`(目标分类数字 ID)和 `Moodle__Token`(Moodle Web 服务令牌)后显示按钮。请通过环境变量或密钥管理器提供令牌,不要提交到仓库。Moodle 需要启用 REST Web 服务并为服务账户提供 `core_course_get_courses_by_field`、`core_course_create_courses` 及相应分类创建、隐藏课程查看权限。旧版自动创建课程继续使用原有标识和链接;手动关联仍支持多个教学班共用课程。师生名单需另行导入。 配置 `Moodle__TeacherRoleId` 并为服务账户提供 `core_user_get_users_by_field`、`enrol_manual_enrol_users` 和相应用户查询、手动选课及角色分配权限后,管理员可在已关联的教学任务中同步授课教师。教务工号须与 Moodle 用户名一致;系统先检查所有教师账号,再加入课程,不会自动创建账号或移除 Moodle 中已有的教师。课程需启用 Moodle 手动选课方式。 配置 `Moodle__StudentRoleId` 后,有管理权限的管理员或该教学班的任课教师可将当前教学班名单导入 Moodle,学号须与 Moodle 用户名一致。名单包括行政班关联和正式选课学生,排除学籍异动限制;导入是增量操作,不会自动移除退课学生或创建账号。导入前应确认选课名单,名单变化后可重复导入;需要撤销访问时须在 Moodle 中处理。 -管理员也可输入 Moodle 历史课程的数字 ID 来复制课程;需要启用 `core_course_duplicate_course` 并授予来源课程备份和目标分类恢复权限。复制不包含旧用户及其数据。复制超时或失败时,Moodle 可能留下未完成课程;须先在 Moodle 检查结果并处理,再手动关联,不应直接认定复制成功。 +管理员也可输入 Moodle 历史课程的数字 ID 来复制课程;需要启用 `core_course_duplicate_course`、`core_course_update_courses` 并授予来源课程备份和目标分类恢复、课程更新权限。复制成功后写入教学任务编号作为课程 ID 号码,不包含旧用户及其数据。复制或更新编号超时、失败时,Moodle 可能留下未完成课程;须先在 Moodle 检查结果并处理,再手动关联,不应直接认定复制成功。 ### Keycloak 单点登录(可选) diff --git a/src/Jiaowu.Api/Controllers/MoodleCoursesController.cs b/src/Jiaowu.Api/Controllers/MoodleCoursesController.cs index 5b5a834..c94c2b6 100644 --- a/src/Jiaowu.Api/Controllers/MoodleCoursesController.cs +++ b/src/Jiaowu.Api/Controllers/MoodleCoursesController.cs @@ -76,7 +76,7 @@ public sealed class MoodleCoursesController(AppDbContext db, ICurrentUserDataSco if (task.MoodleCourseUrl is not null) return Conflict(new ProblemDetails { Detail = "该教学任务已有 Moodle 课程关联。", Status = 409 }); try { - var url = await moodle.CreateOrRecoverAsync(task.Id, task.Name, ct); + var url = await moodle.CreateOrRecoverAsync(task.Id, task.TaskNumber, task.Name, ct); var updated = await db.TeachingTasks.Where(x => x.Id == id && x.MoodleCourseUrl == null && x.Status == TeachingTaskStatus.Published) .ExecuteUpdateAsync(setters => setters.SetProperty(x => x.MoodleCourseUrl, url), ct); if (updated == 0) return Conflict(new ProblemDetails { Detail = "教学任务状态或课程关联已更改;请检查 Moodle 课程后重新操作。", Status = 409 }); @@ -100,7 +100,7 @@ public sealed class MoodleCoursesController(AppDbContext db, ICurrentUserDataSco return Conflict(new ProblemDetails { Detail = "仅已发布且未关联的教学任务可以复制课程。", Status = 409 }); try { - var url = await moodle.CopyCourseAsync(task.Id, task.Name, request.TemplateId, ct); + var url = await moodle.CopyCourseAsync(task.Id, task.TaskNumber, task.Name, request.TemplateId, ct); var updated = await db.TeachingTasks.Where(x => x.Id == id && x.MoodleCourseUrl == null && x.Status == TeachingTaskStatus.Published) .ExecuteUpdateAsync(setters => setters.SetProperty(x => x.MoodleCourseUrl, url), ct); if (updated == 0) return Conflict(new ProblemDetails { Detail = "教学任务已更改,请在 Moodle 检查复制结果并手动关联。", Status = 409 }); diff --git a/src/Jiaowu.Api/Infrastructure/Teaching/MoodleCourseClient.cs b/src/Jiaowu.Api/Infrastructure/Teaching/MoodleCourseClient.cs index 1ae3d2b..a1fcbf6 100644 --- a/src/Jiaowu.Api/Infrastructure/Teaching/MoodleCourseClient.cs +++ b/src/Jiaowu.Api/Infrastructure/Teaching/MoodleCourseClient.cs @@ -21,9 +21,16 @@ public sealed class MoodleCourseClient(IHttpClientFactory clients, IConfiguratio throw new MoodleIntegrationException("请配置 Moodle 对应角色 ID 和服务连接。"); if (!Uri.TryCreate(courseUrl, UriKind.Absolute, out var courseUri) || !string.Equals(courseUri.GetLeftPart(UriPartial.Path), new Uri(baseUri, "course/view.php").GetLeftPart(UriPartial.Path), StringComparison.OrdinalIgnoreCase) || - !Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(courseUri.Query).TryGetValue("id", out var idText) || - !long.TryParse(idText.ToString(), out var courseId) || courseId <= 0) + !string.IsNullOrEmpty(courseUri.UserInfo)) throw new MoodleIntegrationException("课程链接与配置的 Moodle 站点不匹配,无法同步教师。"); + var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(courseUri.Query); + long courseId; + if (query.TryGetValue("name", out var shortname) && !string.IsNullOrWhiteSpace(shortname.ToString())) + courseId = await LookupCourseIdAsync(baseUri, token, "shortname", shortname.ToString(), ct) ?? throw new MoodleIntegrationException("未找到 Moodle 课程简称对应的课程。"); + else if (query.TryGetValue("idnumber", out var number) && !string.IsNullOrWhiteSpace(number.ToString())) + courseId = await LookupCourseIdAsync(baseUri, token, "idnumber", number.ToString(), ct) ?? throw new MoodleIntegrationException("未找到 Moodle 课程编号对应的课程。"); + else if (!query.TryGetValue("id", out var idText) || !long.TryParse(idText.ToString(), out courseId) || courseId <= 0) + throw new MoodleIntegrationException("Moodle 课程链接缺少有效的课程标识。"); if (teacherNumbers.Count == 0) throw new MoodleIntegrationException("教学任务名单为空。"); var usersQuery = new Dictionary { ["field"] = "username" }; for (var i = 0; i < teacherNumbers.Count; i++) usersQuery[$"values[{i}]"] = teacherNumbers[i]; @@ -62,20 +69,24 @@ public sealed class MoodleCourseClient(IHttpClientFactory clients, IConfiguratio return validUri && token.Length > 0 && validCategory; } - public async Task CreateOrRecoverAsync(Guid taskId, string name, CancellationToken ct) + public async Task CreateOrRecoverAsync(Guid taskId, string taskNumber, string name, CancellationToken ct) { if (!TryGetSettings(out var baseUri, out var token, out var categoryId)) throw new MoodleIntegrationException("Moodle 未配置或配置无效。"); var key = "jiaowu-" + taskId.ToString("N"); await EnsureNoCopyAsync(baseUri, token, taskId, ct); - var found = await FindAsync(baseUri, token, key, ct); + var legacy = await FindAsync(baseUri, token, key, ct, taskNumber); + var matching = await LookupCourseIdAsync(baseUri, token, "idnumber", taskNumber, ct); + if (legacy is not null && matching is not null && legacy != matching) + throw new MoodleIntegrationException("旧课程标识与教学班编号指向不同课程,请检查后手动关联。"); + var found = legacy ?? matching; if (found is null) { using var created = await CallAsync(baseUri, token, "core_course_create_courses", new() { ["courses[0][fullname]"] = name, ["courses[0][shortname]"] = key, - ["courses[0][idnumber]"] = key, + ["courses[0][idnumber]"] = taskNumber, ["courses[0][categoryid]"] = categoryId.ToString(System.Globalization.CultureInfo.InvariantCulture), ["courses[0][visible]"] = "0" }, ct); @@ -87,13 +98,13 @@ public sealed class MoodleCourseClient(IHttpClientFactory clients, IConfiguratio return new Uri(baseUri, "course/view.php?id=" + found.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)).ToString(); } - public async Task CopyCourseAsync(Guid taskId, string name, long templateId, CancellationToken ct) + public async Task CopyCourseAsync(Guid taskId, string taskNumber, string name, long templateId, CancellationToken ct) { if (!TryGetSettings(out var baseUri, out var token, out var categoryId)) throw new MoodleIntegrationException("Moodle 未配置或配置无效。"); if (templateId <= 0) throw new MoodleIntegrationException("请输入有效的模板课程 ID。"); var key = "jiaowu-" + taskId.ToString("N"); await EnsureNoCopyAsync(baseUri, token, taskId, ct); - if (await FindAsync(baseUri, token, key, ct) is not null) + if (await FindAsync(baseUri, token, key, ct, taskNumber) is not null || await LookupCourseIdAsync(baseUri, token, "idnumber", taskNumber, ct) is not null) throw new MoodleIntegrationException("Moodle 中已存在相同标识的课程,请检查后手动关联。"); key = "jiaowu-copy-" + taskId.ToString("N"); using var copied = await CallAsync(baseUri, token, "core_course_duplicate_course", new() @@ -105,6 +116,10 @@ public sealed class MoodleCourseClient(IHttpClientFactory clients, IConfiguratio }, ct); if (copied.RootElement.ValueKind != JsonValueKind.Object || !copied.RootElement.TryGetProperty("id", out var id) || !id.TryGetInt64(out var courseId) || courseId <= 0) throw new MoodleIntegrationException("复制结果不确定,请在 Moodle 核对课程后手动关联。"); + using var updated = await CallAsync(baseUri, token, "core_course_update_courses", new() + { + ["courses[0][id]"] = courseId.ToString(), ["courses[0][idnumber]"] = taskNumber + }, ct); return new Uri(baseUri, "course/view.php?id=" + courseId.ToString()).ToString(); } @@ -119,7 +134,7 @@ public sealed class MoodleCourseClient(IHttpClientFactory clients, IConfiguratio if (courses.GetArrayLength() > 0) throw new MoodleIntegrationException("Moodle 中已存在复制课程或未完成的复制,请检查后手动关联或处理。"); } - private async Task FindAsync(Uri baseUri, string token, string key, CancellationToken ct) + private async Task FindAsync(Uri baseUri, string token, string key, CancellationToken ct, string taskNumber) { using var result = await CallAsync(baseUri, token, "core_course_get_courses_by_field", new() { @@ -131,11 +146,24 @@ public sealed class MoodleCourseClient(IHttpClientFactory clients, IConfiguratio if (courses.GetArrayLength() == 0) return null; if (courses.GetArrayLength() != 1 || courses[0].ValueKind != JsonValueKind.Object || !courses[0].TryGetProperty("idnumber", out var idnumber) || idnumber.ValueKind != JsonValueKind.String || - idnumber.GetString() != key || !courses[0].TryGetProperty("id", out var id) || !id.TryGetInt64(out var value) || value <= 0) + (idnumber.GetString() != key && idnumber.GetString() != taskNumber) || !courses[0].TryGetProperty("id", out var id) || !id.TryGetInt64(out var value) || value <= 0) throw new MoodleIntegrationException("Moodle 中存在标识冲突,请管理员检查后再试。"); return value; } + private async Task LookupCourseIdAsync(Uri baseUri, string token, string field, string value, CancellationToken ct) + { + using var result = await CallAsync(baseUri, token, "core_course_get_courses_by_field", new() { ["field"] = field, ["value"] = value }, ct); + if (result.RootElement.ValueKind != JsonValueKind.Object || !result.RootElement.TryGetProperty("courses", out var courses) || courses.ValueKind != JsonValueKind.Array) + throw new MoodleIntegrationException("Moodle 返回的查询结果无效。"); + if (courses.GetArrayLength() == 0) return null; + if (courses.GetArrayLength() != 1 || courses[0].ValueKind != JsonValueKind.Object || + !courses[0].TryGetProperty(field, out var actual) || actual.ValueKind != JsonValueKind.String || actual.GetString() != value || + !courses[0].TryGetProperty("id", out var id) || !id.TryGetInt64(out var courseId) || courseId <= 0) + throw new MoodleIntegrationException("Moodle 课程编号不唯一或返回的标识不匹配,请管理员检查。"); + return courseId; + } + private async Task CallAsync(Uri baseUri, string token, string function, Dictionary parameters, CancellationToken ct) { parameters["wstoken"] = token; diff --git a/tests/Jiaowu.Api.Tests/MoodleCourseClientTests.cs b/tests/Jiaowu.Api.Tests/MoodleCourseClientTests.cs index 01d81ab..3a0dce7 100644 --- a/tests/Jiaowu.Api.Tests/MoodleCourseClientTests.cs +++ b/tests/Jiaowu.Api.Tests/MoodleCourseClientTests.cs @@ -6,6 +6,34 @@ namespace Jiaowu.Api.Tests; public sealed class MoodleCourseClientTests { + [Fact] + public async Task MatchesExistingIdNumberAndResolvesNumberLinksForEnrolment() + { + var handler = new NumberHandler(); + var config = new ConfigurationBuilder().AddInMemoryCollection(new Dictionary + { + ["Moodle:BaseUrl"] = "https://moodle.example.edu/sub", ["Moodle:Token"] = "token", ["Moodle:CategoryId"] = "4", ["Moodle:StudentRoleId"] = "5" + }).Build(); + var client = new MoodleCourseClient(new Factory(new HttpClient(handler)), config); + Assert.Equal("https://moodle.example.edu/sub/course/view.php?id=42", await client.CreateOrRecoverAsync(Guid.NewGuid(), "TASK-1", "课程", CancellationToken.None)); + Assert.DoesNotContain(handler.Requests, x => x.Contains("core_course_create_courses")); + await client.SyncStudentsAsync("https://moodle.example.edu/sub/course/view.php?idnumber=TASK-1", ["S01"], CancellationToken.None); + Assert.Contains("enrolments%5B0%5D%5Bcourseid%5D=42", handler.Requests.Last()); + await client.SyncStudentsAsync("https://moodle.example.edu/sub/course/view.php?name=CS101&id=99", ["S01"], CancellationToken.None); + Assert.Contains("enrolments%5B0%5D%5Bcourseid%5D=42", handler.Requests.Last()); + } + + private sealed class NumberHandler : HttpMessageHandler + { + public List Requests { get; } = []; + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var body = await request.Content!.ReadAsStringAsync(cancellationToken); + Requests.Add(body); + var data = body.Contains("field=idnumber") ? "{\"courses\":[{\"id\":42,\"idnumber\":\"TASK-1\"}]}" : body.Contains("value=CS101") ? "{\"courses\":[{\"id\":42,\"shortname\":\"CS101\"}]}" : body.Contains("core_user_get_users_by_field") ? "[{\"id\":7,\"username\":\"S01\"}]" : body.Contains("enrol_manual_enrol_users") ? "null" : "{\"courses\":[]}"; + return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(data) }; + } + } [Fact] public async Task StudentImport_ValidatesAllAccountsBeforeEnrollingWithStudentRole() { @@ -30,11 +58,11 @@ public sealed class MoodleCourseClientTests ["Moodle:BaseUrl"] = "https://moodle.example.edu/sub", ["Moodle:Token"] = "token", ["Moodle:CategoryId"] = "4" }).Build(); var client = new MoodleCourseClient(new Factory(new HttpClient(handler)), config); - Assert.Equal("https://moodle.example.edu/sub/course/view.php?id=42", await client.CopyCourseAsync(Guid.NewGuid(), "课程", 5, CancellationToken.None)); - Assert.Contains("options%5B0%5D%5Bvalue%5D=0", handler.Requests[2]); + Assert.Equal("https://moodle.example.edu/sub/course/view.php?id=42", await client.CopyCourseAsync(Guid.NewGuid(), "TASK-1", "课程", 5, CancellationToken.None)); + Assert.Contains("options%5B0%5D%5Bvalue%5D=0", handler.Requests[3]); handler.HasPartial = true; - await Assert.ThrowsAsync(() => client.CopyCourseAsync(Guid.NewGuid(), "课程", 5, CancellationToken.None)); - Assert.Equal(4, handler.Requests.Count); + await Assert.ThrowsAsync(() => client.CopyCourseAsync(Guid.NewGuid(), "TASK-1", "课程", 5, CancellationToken.None)); + Assert.Equal(6, handler.Requests.Count); } private sealed class CopyHandler : HttpMessageHandler @@ -45,7 +73,7 @@ public sealed class MoodleCourseClientTests { var body = await request.Content!.ReadAsStringAsync(cancellationToken); Requests.Add(body); - var data = body.Contains("duplicate_course") ? "{\"id\":42}" : HasPartial ? "{\"courses\":[{\"id\":42,\"idnumber\":\"\"}]}" : "{\"courses\":[]}"; + var data = body.Contains("update_courses") ? "null" : body.Contains("duplicate_course") ? "{\"id\":42}" : HasPartial ? "{\"courses\":[{\"id\":42,\"idnumber\":\"\"}]}" : "{\"courses\":[]}"; return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(data) }; } } @@ -85,14 +113,14 @@ public sealed class MoodleCourseClientTests var key = "jiaowu-" + taskId.ToString("N"); var handler = new StubHandler(); var client = Client(handler); - var first = await client.CreateOrRecoverAsync(taskId, "测试课程", CancellationToken.None); + var first = await client.CreateOrRecoverAsync(taskId, "TASK-1", "测试课程", CancellationToken.None); Assert.Equal("https://moodle.example.edu/sub/course/view.php?id=42", first); - Assert.Contains("courses%5B0%5D%5Bvisible%5D=0", handler.Requests[2]); - Assert.Contains(key, handler.Requests[2]); + Assert.Contains("courses%5B0%5D%5Bvisible%5D=0", handler.Requests[3]); + Assert.Contains("courses%5B0%5D%5Bidnumber%5D=TASK-1", handler.Requests[3]); handler.ExistingKey = key; - var second = await client.CreateOrRecoverAsync(taskId, "测试课程", CancellationToken.None); + var second = await client.CreateOrRecoverAsync(taskId, "TASK-1", "测试课程", CancellationToken.None); Assert.Equal(first, second); - Assert.Equal(5, handler.Requests.Count); + Assert.Equal(7, handler.Requests.Count); } [Fact] @@ -101,16 +129,16 @@ public sealed class MoodleCourseClientTests var taskId = Guid.NewGuid(); var handler = new StubHandler { FailCreateOnce = true, RecoveryKey = "jiaowu-" + taskId.ToString("N") }; var client = Client(handler); - await Assert.ThrowsAsync(() => client.CreateOrRecoverAsync(taskId, "课程", CancellationToken.None)); - Assert.Equal("https://moodle.example.edu/sub/course/view.php?id=42", await client.CreateOrRecoverAsync(taskId, "课程", CancellationToken.None)); - Assert.Equal(5, handler.Requests.Count); + await Assert.ThrowsAsync(() => client.CreateOrRecoverAsync(taskId, "TASK-1", "课程", CancellationToken.None)); + Assert.Equal("https://moodle.example.edu/sub/course/view.php?id=42", await client.CreateOrRecoverAsync(taskId, "TASK-1", "课程", CancellationToken.None)); + Assert.Equal(7, handler.Requests.Count); } [Fact] public async Task RejectsExistingCourseWithUnexpectedIdNumber() { var handler = new StubHandler { ExistingKey = "different" }; - await Assert.ThrowsAsync(() => Client(handler).CreateOrRecoverAsync(Guid.NewGuid(), "课程", CancellationToken.None)); + await Assert.ThrowsAsync(() => Client(handler).CreateOrRecoverAsync(Guid.NewGuid(), "TASK-1", "课程", CancellationToken.None)); Assert.Equal(2, handler.Requests.Count); } @@ -144,7 +172,7 @@ public sealed class MoodleCourseClientTests ExistingKey = RecoveryKey; throw new HttpRequestException("response lost"); } - var response = body.Contains("jiaowu-copy-") ? "{\"courses\":[]}" : body.Contains("core_course_create_courses") ? "[{\"id\":42,\"shortname\":\"x\"}]" : + var response = body.Contains("jiaowu-copy-") || body.Contains("field=idnumber") ? "{\"courses\":[]}" : body.Contains("core_course_create_courses") ? "[{\"id\":42,\"shortname\":\"x\"}]" : ExistingKey is null ? "{\"courses\":[]}" : $"{{\"courses\":[{{\"id\":42,\"idnumber\":\"{ExistingKey}\"}}]}}"; return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(response) }; } diff --git a/web/src/i18n/messages/en-US/core.ts b/web/src/i18n/messages/en-US/core.ts index 4b79e5d..a0870ea 100644 --- a/web/src/i18n/messages/en-US/core.ts +++ b/web/src/i18n/messages/en-US/core.ts @@ -3,8 +3,8 @@ export default { myCourses: "My Moodle courses", 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", - 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.", + create: "Match or create course", createConfirm: "Match by teaching task number, or create a hidden empty course if none exists. Teachers and students will not be enrolled automatically. Continue?", created: "Moodle course linked", + batchCreate: "Match or create Moodle courses", batchConfirm: "Match the {count} selected tasks by number, or create hidden empty courses. Teachers and students will not be enrolled automatically. Continue?", batchResult: "Course processing results", batchSuccess: "Linked {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.", diff --git a/web/src/i18n/messages/zh-CN/core.ts b/web/src/i18n/messages/zh-CN/core.ts index cfc0e63..81416ab 100644 --- a/web/src/i18n/messages/zh-CN/core.ts +++ b/web/src/i18n/messages/zh-CN/core.ts @@ -3,8 +3,8 @@ export default { myCourses: "我的 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 课程已创建并关联", - batchCreate: "批量创建 Moodle 课程", batchConfirm: "将为选中的 {count} 个未关联教学任务创建隐藏的空课程,不会自动加入教师或学生。确认继续?", batchResult: "批量创建结果", batchSuccess: "已创建或恢复关联 {count} 门课程。", unavailable: "请先配置 Moodle 服务。", + 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} 个教学班。",