|
|
@@ -210,6 +210,14 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
return String(item['kcid'] ?? item['kcId'] ?? item['NodeID'] ?? item['nodeId'] ?? '');
|
|
|
}
|
|
|
|
|
|
+ courseBindingId(item: Item): string {
|
|
|
+ return String(item['id'] ?? item['bindingId'] ?? item['bindingObjectId'] ?? '');
|
|
|
+ }
|
|
|
+
|
|
|
+ canOpenCourse(item: Item): boolean {
|
|
|
+ return Boolean(this.courseId(item) || this.courseBindingId(item) || this.assignedUnits(item).length);
|
|
|
+ }
|
|
|
+
|
|
|
courseTitle(item: Item): string {
|
|
|
const title = String(item['Title2'] ?? item['Title'] ?? '课程内容');
|
|
|
if (item['Title2'] || !title.includes('@')) return title;
|
|
|
@@ -218,9 +226,22 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
return `【${first}】${parts.at(-1) ?? ''}`;
|
|
|
}
|
|
|
|
|
|
+ courseHint(item: Item): string {
|
|
|
+ if (!this.canOpenCourse(item)) return '暂未分配可查看的学习内容';
|
|
|
+ if (!this.canStartPointReading) return '点击查看老师分配的单元与单词列表';
|
|
|
+ return '选择本次学习单元';
|
|
|
+ }
|
|
|
+
|
|
|
openCourse(item: Item): void {
|
|
|
- const id = this.courseId(item);
|
|
|
- if (id) void this.router.navigate(['/pages/stu/stu_list'], { queryParams: { nid: id } });
|
|
|
+ if (!this.canOpenCourse(item)) return;
|
|
|
+ const courseId = this.courseId(item);
|
|
|
+ const bindingId = this.courseBindingId(item);
|
|
|
+ void this.router.navigate(['/pages/stu/stu_list'], {
|
|
|
+ queryParams: {
|
|
|
+ nid: courseId || null,
|
|
|
+ bindingId: bindingId || null,
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
openSchedulePlan(item: Item): void {
|
|
|
@@ -247,6 +268,28 @@ export class StudyRecordsPageComponent implements OnInit {
|
|
|
return canStartTeacherLedLearning(this.session.groupId());
|
|
|
}
|
|
|
|
|
|
+ private assignedUnits(item: Item): Array<{ id: string; name: string }> {
|
|
|
+ const raw = item['syjd'] ?? item['assignedUnits'];
|
|
|
+ let source: unknown = raw;
|
|
|
+ if (typeof raw === 'string' && raw.trim()) {
|
|
|
+ try { source = JSON.parse(raw); } catch { return []; }
|
|
|
+ }
|
|
|
+ const entries = Array.isArray(source)
|
|
|
+ ? source.map((value, index) => [String(index), value] as const)
|
|
|
+ : source && typeof source === 'object'
|
|
|
+ ? Object.entries(source)
|
|
|
+ : [];
|
|
|
+ return entries
|
|
|
+ .map(([key, value]) => {
|
|
|
+ const text = typeof value === 'object' && value
|
|
|
+ ? String((value as Item)['name'] ?? (value as Item)['title'] ?? (value as Item)['NodeName'] ?? '')
|
|
|
+ : String(value ?? '');
|
|
|
+ const id = String((typeof value === 'object' && value ? (value as Item)['id'] ?? (value as Item)['nodeId'] : '') || (/^\d+$/.test(key) ? key : text.split('@')[0]) || '').trim();
|
|
|
+ return { id, name: text };
|
|
|
+ })
|
|
|
+ .filter((unit) => /^\d+$/.test(unit.id));
|
|
|
+ }
|
|
|
+
|
|
|
openReading(item: Item, event: Event): void {
|
|
|
event.stopPropagation();
|
|
|
this.navigateToReading(item);
|