1
This commit is contained in:
@@ -9,13 +9,13 @@ namespace TechHelper.Client.Services
|
||||
{
|
||||
public class ExamService : IExamService
|
||||
{
|
||||
private readonly IAIService _aIService;
|
||||
private readonly HttpClient _client;
|
||||
private readonly IAIService _aIService;
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public ExamService(IAIService aIService, HttpClient client)
|
||||
public ExamService(IAIService aIService, HttpClient client)
|
||||
{
|
||||
_aIService = aIService;
|
||||
_client = client;
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public ApiResponse ConvertToXML<T>(string xmlContent)
|
||||
@@ -86,9 +86,9 @@ namespace TechHelper.Client.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse> GetAllExam(string user)
|
||||
public async Task<ApiResponse> GetAllExam()
|
||||
{
|
||||
var response = await _client.GetAsync($"exam/getAllPreview?user={user}");
|
||||
var response = await _client.GetAsync($"exam/getAllPreview");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
@@ -104,6 +104,25 @@ namespace TechHelper.Client.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse> GetAllSubmission()
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await _client.GetAsync($"exam/getAllSubmission");
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var exam = JsonConvert.DeserializeObject<AssignmentDto>(content);
|
||||
return ApiResponse.Success();
|
||||
}
|
||||
return ApiResponse.Error(message: "获取失败");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error(message: $"内部错误{ex.Message}, InerEx{ex.InnerException}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse> GetExam(Guid guid)
|
||||
{
|
||||
|
||||
@@ -158,5 +177,18 @@ namespace TechHelper.Client.Services
|
||||
return ApiResponse.Error(message: $"保存试题失败: {response.StatusCode} - {errorContent}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse> SubmissionAssignment(SubmissionDto submission)
|
||||
{
|
||||
var response = await _client.PostAsJsonAsync("exam/submission", submission);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return ApiResponse.Success("提交成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
return ApiResponse.Error("提交失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user