Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface ExamUserExamDto {
}

export interface GetExamForEditorOutput extends ExamCreateOrUpdateDtoBase {
status?: number;
}

export interface GetExamsInput extends PagedAndSortedResultRequestDto {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { NzSelectModule } from 'ng-zorro-antd/select';
import { NzSpinModule } from 'ng-zorro-antd/spin';
import { forkJoin } from 'rxjs';
import { finalize, max, tap } from 'rxjs/operators';
import { ExaminationStatus } from '@shared';

@Component({
selector: 'app-exam-management-exam-edit',
Expand Down Expand Up @@ -60,6 +61,7 @@ export class ExamManagementExamEditComponent implements OnInit {

loading = false;
isConfirmLoading = false;
canSave = true;

form: FormGroup = null;
papers: PaperListDto[] = [];
Expand Down Expand Up @@ -93,6 +95,9 @@ export class ExamManagementExamEditComponent implements OnInit {
get disableChoosePaper() {
return this.paperId != undefined || this.paperId != null || this.examId != undefined || this.examId != null;
}
get isFormDisabled() {
return !this.canSave;
}
get examTimes() {
return this.form.get('examTimes');
}
Expand All @@ -110,7 +115,6 @@ export class ExamManagementExamEditComponent implements OnInit {
this.loading = true;

if (this.examId) {
// 有 examId 时,同时获取选项数据、考试数据和试卷列表
forkJoin({
answerModes: this.optionService.getAnswerModes(),
reviewModes: this.optionService.getReviewModes(),
Expand All @@ -129,6 +133,8 @@ export class ExamManagementExamEditComponent implements OnInit {
}));
this.exam = exam;
this.papers = papers.items;
// 只有草稿状态才能保存
this.canSave = this.exam.status === ExaminationStatus.Draft;
this.buildForm();
}),
finalize(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ export class ExamManagementExamComponent implements OnInit {
{
icon: 'edit',
type: 'modal',
iif: record => {
return this.permissionService.getGrantedPolicy('Exam.Exams.Update') && record.status === ExaminationStatus.Draft;
},
modal: {
component: ExamManagementExamEditComponent,
params: (record: any) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export class PaperManagementPaperRandomEditComponent implements OnInit {
this.currentSectionIndex = sectionIndex;
const section = this.sections.at(sectionIndex);
const rulesArray = section.get('paperQuestionRules') as FormArray;
const scoreEach = section.get('scoreEach')?.value || 0;

// Prepare selected rules from FormArray for the modal
const selectedRules = rulesArray.controls.map(control => ({
Expand Down Expand Up @@ -274,7 +275,7 @@ export class PaperManagementPaperRandomEditComponent implements OnInit {
questionBankId: result.questionBankId,
questionType: result.questionType,
count: result.count,
score: 0,
score: scoreEach,
questionBankName: '',
questionTypeName: '',
knowledgePointId: result.knowledgePointId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ export class SysKnowledgePointComponent implements OnInit {
}
delete(record) {
this.knowledgePointService.delete(record.id).subscribe(response => {
this.messageService.success(this.localizationService.instant('Exam::DeletedSuccessfully', record.name));
// tslint:disable-next-line: no-non-null-assertion
this.knowledgePoints = this.knowledgePoints.filter(item => item.id !== record.id);
this.getList();
});
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace SuperAbp.Exam.Admin.ExamManagement.Exams
namespace SuperAbp.Exam.Admin.ExamManagement.Exams;

/// <summary>
/// 修改输出
/// </summary>
public class GetExamForEditorOutput : ExamCreateOrUpdateDtoBase
{
/// <summary>
/// 修改输出
/// </summary>
public class GetExamForEditorOutput : ExamCreateOrUpdateDtoBase
{
}
public int Status { get; set; }
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using SuperAbp.Exam.Admin.ExamManagement.Exams;
using SuperAbp.Exam.ExamManagement.Exams;
using SuperAbp.Exam.ExamManagement.UserExamQuestions;
using SuperAbp.Exam.ExamManagement.UserExams;
using SuperAbp.Exam.KnowledgePoints;
using SuperAbp.Exam.QuestionManagement.Questions;
using SuperAbp.Exam.QuestionManagement.Questions.QuestionOptions;
using System;
using System.Collections.Generic;
using System.Linq;
using SuperAbp.Exam.ExamManagement.Exams;
using SuperAbp.Exam.ExamManagement.UserExamQuestions;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Data;
using Volo.Abp.Identity;
using Volo.Abp.Users;
using Volo.Abp;
using SuperAbp.Exam.QuestionManagement.Questions.QuestionOptions;
using SuperAbp.Exam.Admin.ExamManagement.Exams;

namespace SuperAbp.Exam.Admin.ExamManagement.UserExams;

Expand All @@ -21,13 +22,15 @@ public class UserExamAdminAppService(IUserExamRepository userExamRepository,
IIdentityUserRepository userRepository,
IExamRepository examRepository,
QuestionManager questionManager,
UserExamManager userExamManager) : ExamAppService, IUserExamAdminAppService
UserExamManager userExamManager,
IDataFilter<ISoftDelete> softDeleteFilter) : ExamAppService, IUserExamAdminAppService
{
protected IQuestionRepository QuestionRepository { get; } = questionRepository;
public IIdentityUserRepository UserRepository { get; } = userRepository;
public IExamRepository ExamRepository { get; } = examRepository;
protected QuestionManager QuestionManager { get; } = questionManager;
public UserExamManager UserExamManager { get; } = userExamManager;
public IDataFilter<ISoftDelete> SoftDeleteFilter { get; } = softDeleteFilter;
protected IUserExamRepository UserExamRepository { get; } = userExamRepository;

public async Task<ListResultDto<UserExamListDto>> GetListAsync(GetUserExamsInput input)
Expand All @@ -46,7 +49,20 @@ public async Task<UserExamDetailDto> GetAsync(Guid id)
Examination examination = await ExamRepository.GetAsync(userExam.ExamId);
IdentityUser user = await UserRepository.GetAsync(userExam.UserId);
List<Guid> questionIds = userExam.Sections.SelectMany(s => s.Questions).Select(q => q.QuestionId).ToList();
List<Question> questions = await QuestionRepository.GetByIdsAsync(questionIds);

List<Question> questions;
if (userExam.IsSubmitted())
{
using (SoftDeleteFilter.Disable())
{
questions = await QuestionRepository.GetByIdsAsync(questionIds);
}
}
else
{
questions = await QuestionRepository.GetByIdsAsync(questionIds);
}

UserExamDetailDto dto = ObjectMapper.Map<UserExam, UserExamDetailDto>(userExam);
dto.ReviewMode = examination.ReviewMode.Value;
dto.ExamStatus = examination.Status.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
namespace SuperAbp.Exam.Admin.KnowledgePoints;

[Authorize(ExamPermissions.KnowledgePoints.Default)]
public class KnowledgePointAdminAppService(IKnowledgePointRepository knowledgePointRepository) : ExamAppService, IKnowledgePointAdminAppService
public class KnowledgePointAdminAppService(IKnowledgePointRepository knowledgePointRepository,
KnowledgePointManager knowledgePointManager) : ExamAppService, IKnowledgePointAdminAppService
{
public IKnowledgePointRepository KnowledgePointRepository { get; } = knowledgePointRepository;
public KnowledgePointManager KnowledgePointManager { get; } = knowledgePointManager;

public async Task<ListResultDto<KnowledgePointNodeDto>> GetAllAsync(GetKnowledgePointsInput input)
{
List<KnowledgePoint> knowledgePoints = await knowledgePointRepository.GetListAsync(input.Name);
List<KnowledgePoint> knowledgePoints = await KnowledgePointRepository.GetListAsync(input.Name);
List<KnowledgePointNodeDto> dtos = BuildTree(knowledgePoints);
return new ListResultDto<KnowledgePointNodeDto>(dtos);
}
Expand Down Expand Up @@ -46,30 +50,31 @@ private List<KnowledgePointNodeDto> BuildTreeNodes(Guid parentId, Dictionary<Gui

public async Task<GetKnowledgePointForEditorOutput> GetEditorAsync(Guid id)
{
KnowledgePoint category = await knowledgePointRepository.GetAsync(id);
KnowledgePoint category = await KnowledgePointRepository.GetAsync(id);
return ObjectMapper.Map<KnowledgePoint, GetKnowledgePointForEditorOutput>(category);
}

[Authorize(ExamPermissions.KnowledgePoints.Create)]
public async Task<Guid> CreateAsync(KnowledgePointCreateDto input)
{
KnowledgePoint category = new(GuidGenerator.Create(), input.Name, input.ParentId);
await knowledgePointRepository.InsertAsync(category);
await KnowledgePointRepository.InsertAsync(category);
return category.Id;
}

[Authorize(ExamPermissions.KnowledgePoints.Update)]
public async Task UpdateAsync(Guid id, KnowledgePointUpdateDto input)
{
KnowledgePoint category = await knowledgePointRepository.GetAsync(id);
KnowledgePoint category = await KnowledgePointRepository.GetAsync(id);
category.Name = input.Name;
category.ParentId = input.ParentId;
await knowledgePointRepository.UpdateAsync(category);
await KnowledgePointRepository.UpdateAsync(category);
}

[Authorize(ExamPermissions.KnowledgePoints.Delete)]
public async Task DeleteAsync(Guid id)
{
await knowledgePointRepository.DeleteAsync(id);
KnowledgePoint knowledgePoint = await KnowledgePointRepository.GetAsync(id);
await KnowledgePointManager.DeleteAsync(knowledgePoint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using SuperAbp.Exam.Admin.PaperManagement.PaperQuestionRules;
using SuperAbp.Exam.Admin.PaperManagement.Papers;
using SuperAbp.Exam.PaperManagement.PaperQuestionRules;
using SuperAbp.Exam.PaperManagement.PaperQuestions;
using SuperAbp.Exam.PaperManagement.Papers;
using SuperAbp.Exam.PaperManagement.PaperSections;
using System.Linq;
using static SuperAbp.Exam.Admin.PaperManagement.Papers.PaperCreateOrUpdateDtoBase;
using static SuperAbp.Exam.Admin.PaperManagement.Papers.PaperCreateOrUpdateDtoBase.PaperSectionDto;
Expand Down Expand Up @@ -42,7 +40,6 @@ public ExamManagementAdminApplicationAutoMapperProfile()

CreateMap<PaperQuestionRule, GetPaperQuestionRuleForEditorOutput>();
CreateMap<PaperQuestionRule, PaperQuestionRuleListDto>();
CreateMap<PaperQuestionRuleWithDetails, PaperQuestionRuleListDto>();
CreateMap<PaperQuestionRule, PaperQuestionRuleDetailDto>();
CreateMap<PaperQuestionRuleCreateOrUpdateDtoBase, PaperQuestionRule>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using SuperAbp.Exam.PaperManagement.PaperQuestions;
using SuperAbp.Exam.PaperManagement.Papers;
using SuperAbp.Exam.PaperManagement.PaperSections;
using SuperAbp.Exam.Permissions;
using SuperAbp.Exam.QuestionManagement.Questions;
using System;
Expand Down Expand Up @@ -171,8 +169,8 @@ protected virtual void CreateOrUpdatePaperQuestion(Paper paper, PaperSectionDto[
[Authorize(ExamPermissions.Papers.Delete)]
public virtual async Task DeleteAsync(Guid id)
{
// TODO: 如何同时删除子实体?
await paperRepository.DeleteAsync(id);
Paper paper = await paperRepository.GetAsync(id);
await paperManager.DeleteAsync(paper);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,83 +12,76 @@ namespace SuperAbp.Exam.Admin.QuestionManagement.QuestionBanks
[Authorize(ExamPermissions.QuestionBanks.Default)]
public class QuestionBankAdminAppService(
QuestionBankManager questionRepoManager,
QuestionBankManager questionBankManager,
IQuestionBankRepository questionBankRepository,
IQuestionRepository questionRepository)
: ExamAppService, IQuestionBankAdminAppService
{
protected QuestionBankManager QuestionRepoManager { get; } = questionRepoManager;
protected QuestionBankManager QuestionBankManager { get; } = questionBankManager;
protected IQuestionBankRepository QuestionBankRepository { get; } = questionBankRepository;
protected IQuestionRepository QuestionRepository { get; } = questionRepository;

public virtual async Task<QuestionBankDetailDto> GetAsync(Guid id)
{
QuestionBank entity = await questionBankRepository.GetAsync(id);
QuestionBank entity = await QuestionBankRepository.GetAsync(id);

return ObjectMapper.Map<QuestionBank, QuestionBankDetailDto>(entity);
}

public virtual async Task<PagedResultDto<QuestionBankListDto>> GetListAsync(GetQuestionBanksInput input)
{
long totalCount = await questionBankRepository.GetCountAsync(input.Title);
long totalCount = await QuestionBankRepository.GetCountAsync(input.Title);

var entities = await questionBankRepository
var entities = await QuestionBankRepository
.GetListAsync(input.Sorting ?? QuestionBankConsts.DefaultSorting, input.SkipCount,
input.MaxResultCount, input.Title);

var dtos = new List<QuestionBankListDto>();
foreach (var item in entities)
{
var dto = ObjectMapper.Map<QuestionBank, QuestionBankListDto>(item);
dto.SingleCount = await questionRepository.GetCountAsync(questionBankIds: new List<Guid> { item.Id }, questionType: QuestionType.SingleSelect);
dto.JudgeCount = await questionRepository.GetCountAsync(questionBankIds: new List<Guid> { item.Id }, questionType: QuestionType.Judge);
dto.MultiCount = await questionRepository.GetCountAsync(questionBankIds: new List<Guid> { item.Id }, questionType: QuestionType.MultiSelect);
dto.BlankCount = await questionRepository.GetCountAsync(questionBankIds: new List<Guid> { item.Id }, questionType: QuestionType.FillInTheBlanks);
dto.SingleCount = await QuestionRepository.GetCountAsync(questionBankIds: new List<Guid> { item.Id }, questionType: QuestionType.SingleSelect);
dto.JudgeCount = await QuestionRepository.GetCountAsync(questionBankIds: new List<Guid> { item.Id }, questionType: QuestionType.Judge);
dto.MultiCount = await QuestionRepository.GetCountAsync(questionBankIds: new List<Guid> { item.Id }, questionType: QuestionType.MultiSelect);
dto.BlankCount = await QuestionRepository.GetCountAsync(questionBankIds: new List<Guid> { item.Id }, questionType: QuestionType.FillInTheBlanks);
dtos.Add(dto);
}
return new PagedResultDto<QuestionBankListDto>(totalCount, dtos);
}

public virtual async Task<GetQuestionBankForEditorOutput> GetEditorAsync(Guid id)
{
QuestionBank entity = await questionBankRepository.GetAsync(id);
QuestionBank entity = await QuestionBankRepository.GetAsync(id);

return ObjectMapper.Map<QuestionBank, GetQuestionBankForEditorOutput>(entity);
}

[Authorize(ExamPermissions.QuestionBanks.Create)]
public virtual async Task<QuestionBankListDto> CreateAsync(QuestionBankCreateDto input)
{
QuestionBank repository = await questionRepoManager.CreateAsync(input.Title);
QuestionBank repository = await QuestionRepoManager.CreateAsync(input.Title);
repository.Remark = input.Remark;

repository = await questionBankRepository.InsertAsync(repository);
repository = await QuestionBankRepository.InsertAsync(repository);
return ObjectMapper.Map<QuestionBank, QuestionBankListDto>(repository);
}

[Authorize(ExamPermissions.QuestionBanks.Update)]
public virtual async Task<QuestionBankListDto> UpdateAsync(Guid id, QuestionBankUpdateDto input)
{
QuestionBank repository = await questionBankRepository.GetAsync(id);
await questionRepoManager.SetTitleAsync(repository, input.Title);
QuestionBank repository = await QuestionBankRepository.GetAsync(id);
await QuestionRepoManager.SetTitleAsync(repository, input.Title);
repository.Remark = input.Remark;
repository = await questionBankRepository.UpdateAsync(repository);
repository = await QuestionBankRepository.UpdateAsync(repository);
return ObjectMapper.Map<QuestionBank, QuestionBankListDto>(repository);
}

[Authorize(ExamPermissions.QuestionBanks.Delete)]
public virtual async Task DeleteAsync(Guid id)
{
await questionBankRepository.DeleteAsync(id);
}

/// <summary>
/// 规范最大记录数
/// </summary>
/// <param name="input">参数</param>
/// <returns></returns>
private async Task NormalizeMaxResultCountAsync(PagedAndSortedResultRequestDto input)
{
var maxPageSize = (await SettingProvider.GetOrNullAsync(QuestionBankSettings.MaxPageSize))?.To<int>();
if (maxPageSize.HasValue && input.MaxResultCount > maxPageSize.Value)
{
input.MaxResultCount = maxPageSize.Value;
}
QuestionBank questionBank = await QuestionBankRepository.GetAsync(id);
await QuestionBankManager.DeleteAsync(questionBank);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ protected virtual void CreateOrUpdateAnswer(Question question, QuestionCreateOrU
[Authorize(ExamPermissions.Questions.Delete)]
public virtual async Task DeleteAsync(Guid id)
{
await questionRepository.DeleteAsync(id);
Question question = await questionRepository.GetAsync(id);
await questionManager.DeleteAsync(question);
}

[Authorize(ExamPermissions.Questions.Delete)]
Expand Down
Loading
Loading