1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading.Tasks;
- using TEAMModelOS.Models;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.DI;
- using System.Text.Json;
- using TEAMModelOS.SDK.Models;
- using TEAMModelOS.SDK.Extension;
- using Azure.Cosmos;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Options;
- using System.IO;
- using System.Dynamic;
- using System.Net.Http;
- using System.Net;
- using Newtonsoft.Json;
- using System.Linq;
- using StackExchange.Redis;
- using static TEAMModelOS.SDK.Models.Teacher;
- using Microsoft.Extensions.Configuration;
- using TEAMModelOS.Filter;
- using Microsoft.AspNetCore.Authorization;
- using HTEXLib.COMM.Helpers;
- namespace TEAMModelAPI.Controllers
- {
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [ApiController]
- [Route("school")]
- public class ExamController : ControllerBase
- {
- public AzureCosmosFactory _azureCosmos;
- private readonly AzureStorageFactory _azureStorage;
- private readonly AzureRedisFactory _azureRedis;
- private readonly DingDing _dingDing;
- private readonly Option _option;
- private readonly IConfiguration _configuration;
- public ExamController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration)
- {
- _azureCosmos = azureCosmos;
- _azureStorage = azureStorage;
- _azureRedis = azureRedis;
- _dingDing = dingDing;
- _option = option?.Value;
- _configuration = configuration;
- }
- /// <summary>
- /// 获取试卷和评测的条件信息
- /// </summary>
- /// <param name="request"></param>
- /// <returns></returns>
- [ProducesDefaultResponseType]
- [HttpPost("get-paper-exam-condition")]
- [ApiToken(Auth = "11", Name = "试卷和评测的条件信息", RW = "R", Limit = false)]
- public async Task<IActionResult> GetPaperExamCondition(JsonElement json)
- {
- json.TryGetProperty("periodId", out JsonElement _periodId);
- var (id, school) = HttpContext.GetApiTokenInfo();
- School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
- var exmaType = new { type = new List<string> { "regular", "simulation", "normal" } };//regula ,正规考, simulation 模拟靠考,normal 普通考
- var exmaMode = new { type = new List<string> { "0", "1", "2" } };//0 线上评测, 1 课中评测 ,2 阅卷评测
- var period= data.period.Find(x => x.id.Equals($"{_periodId}"));
- if (period != null)
- {
- return Ok(new { period.subjects, period.analysis, period.grades , exmaType, exmaMode });
- }
- else {
- return Ok(new { error = 1, msg = "学段不存在!" });
- }
- }
- }
- }
|