|
@@ -803,6 +803,7 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
//取得學校安排老師課程
|
|
|
HashSet<string> courseIds = new HashSet<string>();
|
|
|
List<KeyValuePair<string, CourseTask>> schoolTeacherTask = new List<KeyValuePair<string, CourseTask>>(); //key:courseId value:CourseTask
|
|
|
+ List<KeyValuePair<string, CourseTask>> schoolAssistantTask = new List<KeyValuePair<string, CourseTask>>();
|
|
|
List<string> periodIdList = new List<string>();
|
|
|
if (string.IsNullOrWhiteSpace(inputPeriodId)) periodIdList = periodIds;
|
|
|
else periodIdList.Add(inputPeriodId);
|
|
@@ -815,7 +816,7 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
int studyYear = (request.TryGetProperty("year", out JsonElement _year)) ? _year.GetInt32() : info.studyYear;
|
|
|
string semesterId = (request.TryGetProperty("semesterId", out JsonElement _semesterId)) ? _semesterId.GetString() : info.currSemester.id;
|
|
|
//string date = SchoolService.GetOpensByStudyYearAndSemester(period.semesters, int.Parse($"{_year}"), $"{_semesterId}");
|
|
|
- string sql = $"SELECT distinct value c FROM c join b in c.schedules where c.pk='CourseTask' and b.teacherId ='{id}'";
|
|
|
+ string sql = $"SELECT distinct value c FROM c join b in c.schedules where c.pk='CourseTask' and ( b.teacherId ='{id}' OR ARRAY_CONTAINS(b.assistants,'{id}'))";
|
|
|
sql = $"{sql} and c.year={studyYear} and c.semesterId='{semesterId}'";
|
|
|
var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<CourseTask>(sql, $"CourseTask-{school_code}");
|
|
|
if (resultSchool.list.IsNotEmpty())
|
|
@@ -831,6 +832,15 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
schoolTeacherTask.Add(new KeyValuePair<string, CourseTask>(x.courseId, courseTask));
|
|
|
groupIds.AddRange(schedulesTeacher.Where(z => !string.IsNullOrWhiteSpace(z.groupId)).Select(x => x.groupId));
|
|
|
}
|
|
|
+ var schedulesAssistant = x.schedules.Where(z => z.assistants.Contains(id));
|
|
|
+ if (schedulesAssistant.Any())
|
|
|
+ {
|
|
|
+ courseIds.Add(x.courseId);
|
|
|
+ CourseTask courseTask = x.ToJsonString().ToObject<CourseTask>();
|
|
|
+ courseTask.schedules = schedulesAssistant.ToList();
|
|
|
+ schoolAssistantTask.Add(new KeyValuePair<string, CourseTask>(x.courseId, courseTask));
|
|
|
+ groupIds.AddRange(schedulesAssistant.Where(z => !string.IsNullOrWhiteSpace(z.groupId)).Select(x => x.groupId));
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -896,7 +906,8 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
courseExtobj.subject.name = item.subject.name;
|
|
|
var period = school_base.period.Find(p => p.subjects.Exists(s => s.id.Equals(item.subject.id)));
|
|
|
classes = new List<GetTeacherInfoApiCourseClass>();
|
|
|
- List<CourseTaskDto> courseTaskDtos = new List<CourseTaskDto>();
|
|
|
+ //任教教師
|
|
|
+ //List<CourseTaskDto> courseTaskDtos = new List<CourseTaskDto>();
|
|
|
var teacher = schoolTeacherTask.Where(x => x.Key.Equals(item.id)).Select(z => new CourseTaskDto { courseTask = z.Value, type = "teacher" });
|
|
|
if (teacher.Any() && period != null)
|
|
|
{
|
|
@@ -935,6 +946,45 @@ namespace TEAMModelOS.Controllers.Client
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //協同教師
|
|
|
+ var assistant = schoolAssistantTask.Where(x => x.Key.Equals(item.id)).Select(z => new CourseTaskDto { courseTask = z.Value, type = "assistant" });
|
|
|
+ if (assistant.Any() && period != null)
|
|
|
+ {
|
|
|
+ List<CourseTaskDto> assistantList = assistant.ToList();
|
|
|
+ foreach (CourseTaskDto assistantTaskDto in assistantList)
|
|
|
+ {
|
|
|
+ List<ScheduleTask> schedules = assistantTaskDto.courseTask.schedules;
|
|
|
+ foreach (ScheduleTask schedule in schedules)
|
|
|
+ {
|
|
|
+ Class classInfo = school_classes.Where((Class x) => x.id == schedule.groupId).FirstOrDefault();
|
|
|
+ GetTeacherInfoApiCourseClass classExtobj = new GetTeacherInfoApiCourseClass();
|
|
|
+ classExtobj.code = (groupCntDic.ContainsKey(schedule.groupId)) ? groupCntDic[schedule.groupId].code : string.Empty;
|
|
|
+ classExtobj.id = schedule.groupId;
|
|
|
+ classExtobj.scope = (groupCntDic.ContainsKey(schedule.groupId)) ? groupCntDic[schedule.groupId].scope : string.Empty;
|
|
|
+ classExtobj.name = (groupCntDic.ContainsKey(schedule.groupId)) ? groupCntDic[schedule.groupId].name : string.Empty;
|
|
|
+ string classType = (groupCntDic.ContainsKey(schedule.groupId)) ? groupCntDic[schedule.groupId].type : schedule.type; /// class:編制班 teach:選課班
|
|
|
+ classExtobj.stuListId = (classType.Equals("teach")) ? schedule.groupId : string.Empty; ///選課班 stuListId才填值
|
|
|
+ classExtobj.teacher = new GetTeacherInfoApiSimlpeBase();
|
|
|
+ if (classInfo != null && !string.IsNullOrWhiteSpace(classInfo.teacher.id)) classExtobj.teacher.id = classInfo.teacher.id;
|
|
|
+ if (classInfo != null && !string.IsNullOrWhiteSpace(classInfo.teacher.name)) classExtobj.teacher.name = classInfo.teacher.name;
|
|
|
+ classExtobj.stuCnt = (groupCntDic.ContainsKey(schedule.groupId)) ? groupCntDic[schedule.groupId].memberCount : 0;
|
|
|
+ classExtobj.gradeId = null;
|
|
|
+ classExtobj.gradeName = null;
|
|
|
+ classExtobj.year = (groupCntDic.ContainsKey(schedule.groupId)) ? groupCntDic[schedule.groupId].year : assistantTaskDto.courseTask.year;
|
|
|
+ var grpCnt = schedules.GroupBy(c => c.groupId).Select(x => new { Count = x.Count() });
|
|
|
+ classExtobj.grpCnt = grpCnt.FirstOrDefault().Count;
|
|
|
+ var gradeInfo = getGradeInfoByYear(classExtobj.year, period);
|
|
|
+ if (!string.IsNullOrWhiteSpace(gradeInfo.id))
|
|
|
+ {
|
|
|
+ classExtobj.gradeId = gradeInfo.id;
|
|
|
+ if (gradeInfo.name.Equals("graduated")) classExtobj.gradeName = (lang.Equals("zh-cn")) ? "已毕业" : (lang.Equals("zh-tw")) ? "已畢業" : "Graduated";
|
|
|
+ else if (gradeInfo.name.Equals("not-enrollment")) classExtobj.gradeName = (lang.Equals("zh-cn")) ? "未到入学时间" : (lang.Equals("zh-tw")) ? "未到入學時間" : "It is not time for enrollment yet";
|
|
|
+ else classExtobj.gradeName = gradeInfo.name;
|
|
|
+ }
|
|
|
+ classes.Add(classExtobj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
courseExtobj.classes = classes;
|
|
|
courses.Add(courseExtobj);
|
|
|
}
|