|
@@ -22,7 +22,48 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
public class StudentService
|
|
|
{
|
|
|
+ public class StudentActivity
|
|
|
+ {
|
|
|
+
|
|
|
+ public string id { get; set; }
|
|
|
+ public string code { get; set; }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 源数据的发布层级 类型 school teacher
|
|
|
+ /// </summary>
|
|
|
+ public string owner { get; set; }
|
|
|
+
|
|
|
+ public string pk { get; set; }
|
|
|
+ //评测模式
|
|
|
+ public string source { get; set; }
|
|
|
+ public string name { get; set; }
|
|
|
+ public long startTime { get; set; }
|
|
|
+ public long endTime { get; set; }
|
|
|
+ public string scope { get; set; }
|
|
|
+ public string school { get; set; }
|
|
|
+ public string creatorId { get; set; }
|
|
|
+
|
|
|
+ public List<string> subjects { get; set; }
|
|
|
+
|
|
|
+ public List<string> classes { get; set; }
|
|
|
+ public List<string> stuLists { get; set; }
|
|
|
+ public List<string> tchLists { get; set; }
|
|
|
+ public long createTime { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ public Dictionary<string, JsonElement> ext { get; set; } = new Dictionary<string, JsonElement>();
|
|
|
+ /// 评分状态,0,未评分, 1已评分
|
|
|
+ public int sStatus { get; set; } = 0;
|
|
|
+ //评测 纸本1或者书面问答0
|
|
|
+ public int qamode { get; set; } = 0;
|
|
|
+ //标记作业活动是否比交
|
|
|
+ public bool mustSubmit { get; set; } = false;
|
|
|
+ //标记问卷是否重复提交 0 否 1 是
|
|
|
+ public int isSub { get; set; } = 0;
|
|
|
+ /// <summary>
|
|
|
+ /// 任务完成状态,-1 未参与,0,未完成, 1已完成
|
|
|
+ /// </summary>
|
|
|
+ public int taskStatus { get; set; } = -1;
|
|
|
+ public string recordUrl { get; set; }
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
///
|
|
@@ -35,8 +76,9 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="types">Exam ,Vote,Homework,Survey</param>
|
|
|
/// <param name="_azureCosmos"></param>
|
|
|
/// <param name="azureRedis"></param>
|
|
|
- public static async void FindActivity(JsonElement request,string userId ,string userType, List<string>groupListIds, string school,List<string> types, AzureCosmosFactory _azureCosmos, AzureRedisFactory azureRedis)
|
|
|
+ public static async void FindActivity(JsonElement request,string userId ,string userType, List<string>groupListIds,List<string> subjects, string school,List<string> types, AzureCosmosFactory _azureCosmos, AzureRedisFactory azureRedis)
|
|
|
{
|
|
|
+ string filed = "c.id ,c.code,c.owner,c.pk,c.qamode,c.name,c.school,c.startTime,c.endTime,c.classes,c.stuLists,c.tchLists,c.createTime,c.creatorId,c.ext,c.isSub,c.mustSubmit,c.sStatus,c.scope,c.source,c.subjects";
|
|
|
if (string.IsNullOrWhiteSpace(school))
|
|
|
{
|
|
|
if (request.TryGetProperty("school", out JsonElement schooljson))
|
|
@@ -47,7 +89,7 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- long stime = 0, etime = 0;
|
|
|
+ long stime = DateTimeOffset.UtcNow.AddDays(-30).ToUnixTimeMilliseconds(), etime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
if (request.TryGetProperty("stime", out JsonElement _stime))
|
|
|
{
|
|
|
if (!_stime.ValueKind.Equals(JsonValueKind.Undefined) && !_stime.ValueKind.Equals(JsonValueKind.Null) && _stime.TryGetInt64(out long data))
|
|
@@ -62,10 +104,109 @@ namespace TEAMModelOS.SDK
|
|
|
etime= data;
|
|
|
}
|
|
|
}
|
|
|
+ string code = null;
|
|
|
+ string groupListSQL =string .Empty ;
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ if (groupListIds.IsNotEmpty())
|
|
|
+ {
|
|
|
+ List<string > arrayStr= new List<string>();
|
|
|
+ groupListIds.ForEach(z => {
|
|
|
+ arrayStr.Add($"array_contains(c.classes,'{z}') ");
|
|
|
+ arrayStr.Add($"array_contains(c.stuLists,'{z}') ");
|
|
|
+ arrayStr.Add($"array_contains(c.tchLists,'{z}') ");
|
|
|
+ });
|
|
|
+ groupListSQL= $"and ({string.Join(" or ", arrayStr)})";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new Exception("名单为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StudentActivity> activities = new List<StudentActivity>();
|
|
|
+ if (types.IsEmpty()|| types.Contains("Exam")) {
|
|
|
+ string subjectSQL = "";
|
|
|
+ string subjectJoin = "";
|
|
|
+ if (subjects.IsNotEmpty()) {
|
|
|
+ subjectJoin = "join s in c.subjects";
|
|
|
+ subjectSQL = $" and c.id in ({string.Join(",",subjects.Select(z=>$"'{z}'"))}) ";
|
|
|
+ }
|
|
|
+ StringBuilder SQL = new StringBuilder( $"select { filed} from c {subjectJoin} where c.pk='Exam' {subjectSQL} {groupListSQL} and c.createTime>={stime} and c.createTime <= {etime} and c.startTime <= {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
|
|
|
+ //获取学校发布的活动
|
|
|
+ if (userType.Equals(Constant.ScopeStudent) && ! string.IsNullOrWhiteSpace(school)) {
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.owner='school' ", $"Exam-{school}");
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
+ }
|
|
|
+ //获取教师发布的活动(个人名单,学校名单)
|
|
|
+ {
|
|
|
+ var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.owner='teacher' ");
|
|
|
+ activities.AddRange(resultTeacher.list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (types.IsEmpty()|| types.Contains("Vote"))
|
|
|
+ {
|
|
|
+
|
|
|
+ StringBuilder SQL = new StringBuilder($"select {filed} from c where c.pk='Vote' {groupListSQL} and c.createTime>={stime} and c.createTime <= {etime} and c.startTime <= {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
|
|
|
+ //获取学校发布的活动
|
|
|
+ if (userType.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ {
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.owner='school' ", $"Vote-{school}");
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
+ }
|
|
|
+ //获取教师发布的活动(个人名单,学校名单)
|
|
|
+ {
|
|
|
+ var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.owner='teacher' ");
|
|
|
+ activities.AddRange(resultTeacher.list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (types.IsEmpty()|| types.Contains("Survey"))
|
|
|
+ {
|
|
|
+
|
|
|
+ StringBuilder SQL = new StringBuilder($"select {filed} from c where c.pk='Survey' {groupListSQL} and c.createTime>={stime} and c.createTime <= {etime} and c.startTime <= {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
|
|
|
+ //获取学校发布的活动
|
|
|
+ if (userType.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ {
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.owner='school' ", $"Survey-{school}");
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
+ }
|
|
|
+ //获取教师发布的活动(个人名单,学校名单)
|
|
|
+ {
|
|
|
+ var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.owner='teacher' ");
|
|
|
+ activities.AddRange(resultTeacher.list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (types.IsEmpty()|| types.Contains("Homework"))
|
|
|
+ {
|
|
|
+
|
|
|
+ StringBuilder SQL = new StringBuilder($"select {filed} from c where c.pk='Homework' {groupListSQL} and c.createTime>={stime} and c.createTime <= {etime} and c.startTime <= {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
|
|
|
+ //获取学校发布的活动
|
|
|
+ if (userType.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ {
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.owner='school' ", $"Homework-{school}");
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
+ }
|
|
|
+ //获取教师发布的活动(个人名单,学校名单)
|
|
|
+ {
|
|
|
+ var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.owner='teacher' ");
|
|
|
+ activities.AddRange(resultTeacher.list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (types.IsEmpty()|| types.Contains("Art"))
|
|
|
+ {
|
|
|
+
|
|
|
+ StringBuilder SQL = new StringBuilder($"select {filed} from c where c.pk='Art' {groupListSQL} and c.createTime>={stime} and c.createTime <= {etime} and c.startTime <= {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
|
|
|
+ //获取学校发布的活动
|
|
|
+ if (userType.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ {
|
|
|
+ var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()} and c.school='school' ", $"Art-{school}");
|
|
|
+ activities.AddRange(resultSchool.list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //作答 记录recordUrl taskStatus
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|