|
@@ -42,14 +42,14 @@ namespace TEAMModelOS.SDK
|
|
|
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 List<ExamSubject> subjects { get; set; } = new List<ExamSubject>();
|
|
|
+
|
|
|
+ public List<string> classes { get; set; } = new List<string>();
|
|
|
+ public List<string> stuLists { get; set; } = new List<string>();
|
|
|
+ public List<string> tchLists { get; set; }= new List<string>();
|
|
|
public long createTime { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
- public Dictionary<string, JsonElement> ext { get; set; } = new Dictionary<string, JsonElement>();
|
|
|
+ //public Dictionary<string, JsonElement> ext { get; set; } = new Dictionary<string, JsonElement>();
|
|
|
/// 评分状态,0,未评分, 1已评分
|
|
|
public int sStatus { get; set; } = 0;
|
|
|
//评测 纸本1或者书面问答0
|
|
@@ -76,9 +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,List<string> subjects, string school,List<string> types, AzureCosmosFactory _azureCosmos, AzureRedisFactory azureRedis)
|
|
|
+ public static async Task<List<StudentActivity>> FindActivity(JsonElement request,string userId ,string userScope, List<string>groupListIds,List<string> subjects, string school,List<string> types, AzureCosmosFactory _azureCosmos)
|
|
|
{
|
|
|
- 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";
|
|
|
+ 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.isSub,c.mustSubmit,c.sStatus,c.scope,c.source,c.subjects";
|
|
|
if (string.IsNullOrWhiteSpace(school))
|
|
|
{
|
|
|
if (request.TryGetProperty("school", out JsonElement schooljson))
|
|
@@ -104,17 +104,17 @@ 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}') ");
|
|
|
+ if (userScope.Equals(Constant.ScopeTeacher))
|
|
|
+ {
|
|
|
+ arrayStr.Add($"array_contains(c.tchLists,'{z}') ");
|
|
|
+ }
|
|
|
});
|
|
|
groupListSQL= $"and ({string.Join(" or ", arrayStr)})";
|
|
|
}
|
|
@@ -131,9 +131,9 @@ namespace TEAMModelOS.SDK
|
|
|
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()}");
|
|
|
+ StringBuilder SQL = new StringBuilder( $"select { filed} from c {subjectJoin} where c.pk='Exam' {subjectSQL} {groupListSQL} and c.startTime>={stime} and c.startTime <= {etime} ");
|
|
|
//获取学校发布的活动
|
|
|
- if (userType.Equals(Constant.ScopeStudent) && ! string.IsNullOrWhiteSpace(school)) {
|
|
|
+ if (userScope.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);
|
|
|
}
|
|
@@ -147,9 +147,9 @@ namespace TEAMModelOS.SDK
|
|
|
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()}");
|
|
|
+ StringBuilder SQL = new StringBuilder($"select {filed} from c where c.pk='Vote' {groupListSQL} and c.startTime>={stime} and c.startTime <= {etime} ");
|
|
|
//获取学校发布的活动
|
|
|
- if (userType.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ if (userScope.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);
|
|
@@ -163,9 +163,9 @@ namespace TEAMModelOS.SDK
|
|
|
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()}");
|
|
|
+ StringBuilder SQL = new StringBuilder($"select {filed} from c where c.pk='Survey' {groupListSQL} and c.startTime>={stime} and c.startTime <= {etime} ");
|
|
|
//获取学校发布的活动
|
|
|
- if (userType.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ if (userScope.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);
|
|
@@ -179,9 +179,9 @@ namespace TEAMModelOS.SDK
|
|
|
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()}");
|
|
|
+ StringBuilder SQL = new StringBuilder($"select {filed} from c where c.pk='Homework' {groupListSQL} and c.startTime>={stime} and c.startTime <= {etime} ");
|
|
|
//获取学校发布的活动
|
|
|
- if (userType.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ if (userScope.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);
|
|
@@ -194,16 +194,24 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
if (types.IsEmpty()|| types.Contains("Art"))
|
|
|
{
|
|
|
+ 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 where c.pk='Art' {groupListSQL} and c.createTime>={stime} and c.createTime <= {etime} and c.startTime <= {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
|
|
|
+ StringBuilder SQL = new StringBuilder($"select {filed} from c {subjectJoin} where c.pk='Art' {subjectSQL} {groupListSQL} and c.startTime>={stime} and c.startTime <= {etime} ");
|
|
|
//获取学校发布的活动
|
|
|
- if (userType.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ if (userScope.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
|
|
|
+ return activities;
|
|
|
}
|
|
|
|
|
|
|