Skip to content

feat(be): add duplicate course with input parameters#3457

Open
Choi-Jung-Hyeon wants to merge 9 commits intomainfrom
t2601-add-id-sem-duplicatecourse
Open

feat(be): add duplicate course with input parameters#3457
Choi-Jung-Hyeon wants to merge 9 commits intomainfrom
t2601-add-id-sem-duplicatecourse

Conversation

@Choi-Jung-Hyeon
Copy link
Contributor

Description

Course 복제(duplicateCourse) 시 원본 Course의 courseNum(학수번호)과 semester(학기)를 그대로 복사하던 기존 동작을 변경하여, 사용자가 직접 새로운 학수번호와 학기를 입력할 수 있도록 개선합니다.

변경 사항:

  • [NEW] duplicate-course.input.tsDuplicateCourseInput GraphQL InputType 생성 (courseNumsemester 필드)
  • [MODIFY] group.resolver.tsduplicateCourse mutation에 DuplicateCourseInput 파라미터 추가
  • [MODIFY] group.service.tsduplicateCourse 메서드에서 복제된 CourseInfo의 courseNumsemester를 input 값으로 덮어쓰도록 수정, JSDoc 업데이트
  • [MODIFY] group.service.spec.ts: 기존 duplicateCourse 테스트 4개를 새로운 input 파라미터에 맞게 수정

Before:

duplicateCourse(groupId) → 원본 courseNum/semester 그대로 복사

After:

duplicateCourse(groupId, input: { courseNum, semester }) → 사용자 입력값으로 courseNum/semester 설정

Additional context

  • 이 PR은 Backend만 포함합니다. Frontend(입력 필드 UI 추가, GraphQL mutation 변수 수정)는 별도 PR에서 작업 예정입니다.

Before submitting the PR, please make sure you do the following

Copilot AI review requested due to automatic review settings February 26, 2026 18:17
@Choi-Jung-Hyeon Choi-Jung-Hyeon changed the title feat(be): add duplicate course functionality with input parameters feat(be): add duplicate course with input parameters Feb 26, 2026
@Choi-Jung-Hyeon Choi-Jung-Hyeon requested review from RyuRaseul and Copilot and removed request for Copilot February 26, 2026 18:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the course duplication functionality by allowing users to specify custom courseNum and semester values instead of copying them from the original course. The changes are backend-only, with frontend modifications planned for a separate PR.

Changes:

  • Added DuplicateCourseInput type to accept courseNum and semester parameters
  • Updated duplicateCourse mutation to accept input parameter and apply custom values
  • Modified all existing tests to use the new input parameter structure

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
apps/backend/apps/admin/src/group/model/duplicate-course.input.ts New GraphQL InputType defining courseNum and semester fields for course duplication
apps/backend/apps/admin/src/group/group.resolver.ts Added DuplicateCourseInput parameter to duplicateCourse mutation
apps/backend/apps/admin/src/group/group.service.ts Updated duplicateCourse method signature and implementation to override courseNum/semester with input values; updated JSDoc
apps/backend/apps/admin/src/group/group.service.spec.ts Updated all four test cases to include the new duplicateInput parameter
Comments suppressed due to low confidence (1)

apps/backend/apps/admin/src/group/group.service.spec.ts:427

  • The test should verify that the duplicated course uses the courseNum and semester from the duplicateInput parameter. Currently, the test mocks db.group.create to return groupWithAssignment which contains the original course info. Consider adding an assertion or spy to verify that the create method is called with the correct courseNum ('SWE3099') and semester ('2026 Spring') values from duplicateInput.
    it('should duplicate course successfully', async () => {
      db.user.findUnique.resolves({ canCreateCourse: true })
      const groupWithAssignment = {
        ...group,
        assignment: [{ id: 999 }, { id: 1000 }]
      }

      db.assignmentProblem.findMany.resolves([
        { order: 1, problemId: 1, score: 100 }
      ])
      db.group.findUniqueOrThrow.resolves(groupWithAssignment)
      db.group.create.resolves(groupWithAssignment)

      db.assignment.findFirst.onFirstCall().resolves({
        id: 999,
        groupId,
        startTime: new Date(Date.now() - 1000),
        endTime: new Date(Date.now() + 1000),
        createTime: new Date(),
        updateTime: new Date(),
        title: 'Original Assignment'
      })

      db.assignment.findFirst.onSecondCall().resolves({
        id: 1000,
        groupId,
        startTime: new Date(Date.now() - 1000),
        endTime: new Date(Date.now() + 1000),
        createTime: new Date(),
        updateTime: new Date(),
        title: 'Original Assignment'
      })

      db.assignment.create.onFirstCall().resolves({
        id: 999
      })
      db.assignment.create.onSecondCall().resolves({
        id: 1000
      })

      const result = await service.duplicateCourse(
        groupId,
        userId,
        duplicateInput
      )

      expect(result).to.deep.equal({
        duplicatedCourse: groupWithAssignment,
        originAssignments: [999, 1000],
        copiedAssignments: [999, 1000]
      })
    })

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RyuRaseul
Copy link
Contributor

해당 PR과 관련없는 이야기지만 추가적으로 제가 생각하기에는 나중에 교수님과 미팅을 통해 좀 더 관련 기능을 구체화할 필요성이 있다고 느껴졌습니다 (프론트, 백 모두)

@RyuRaseul RyuRaseul enabled auto-merge March 1, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants