-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
4,592 additions
and
2,143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { CourseGetCommand } from 'src/application/courses/courseGetCommand' | ||
import { ReportListImportCommand } from 'src/application/reportLists/reportListImportCommand' | ||
import { ReportGetResult } from 'src/application/reports/reportGetResult' | ||
|
||
// 型付きで API を公開するための定義 | ||
// https://www.electronjs.org/docs/latest/tutorial/context-isolation#usage-with-typescript | ||
export interface IElectronAPI { | ||
importReportListAsync: ( | ||
reportListImportCommand: ReportListImportCommand | ||
) => Promise<number> | ||
|
||
getReportAsync: ( | ||
reportGetCommand: ReportGetCommand | ||
) => Promise<ReportGetResult> | ||
|
||
getCourseAsync: ( | ||
courseGetCommand: CourseGetCommand | ||
) => Promise<CourseGetResult> | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
electronAPI: IElectronAPI | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { InMemoryCourseRepository } from 'src/infrastructure/inMemory/courses/inMemoryCourseRepository' | ||
import { describe, expect, test } from 'vitest' | ||
import { CourseApplicationService } from './courseApplicationService' | ||
import { CourseGetCommand } from './courseGetCommand' | ||
import { Course } from 'src/domain/models/courses/course' | ||
|
||
describe('get', () => { | ||
test('The service can get the course saved in the repository.', async () => { | ||
const repository = new InMemoryCourseRepository() | ||
const course = new Course(1, 'name') | ||
await repository.saveAsync(course) | ||
const service = new CourseApplicationService(repository) | ||
const command = new CourseGetCommand(course.id) | ||
|
||
const result = await service.getAsync(command) | ||
|
||
expect(result.courseData.id).toBe(course.id) | ||
expect(result.courseData.name).toBe(course.name) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { CourseRepository } from 'src/domain/models/courses/courseRepository' | ||
import { CourseGetResult } from './courseGetResult' | ||
import { CourseGetCommand } from './courseGetCommand' | ||
import { CourseData } from './courseData' | ||
|
||
/** | ||
* コースアプリケーションサービス | ||
*/ | ||
export class CourseApplicationService { | ||
/** | ||
* コンストラクタ | ||
* | ||
* @param courseRepository コースリポジトリ | ||
*/ | ||
public constructor(private readonly courseRepository: CourseRepository) {} | ||
|
||
/** | ||
* コースを取得する | ||
* | ||
* @param courseGetCommand コース取得コマンド | ||
* @returns コース取得結果 | ||
*/ | ||
public async getAsync( | ||
courseGetCommand: CourseGetCommand | ||
): Promise<CourseGetResult> { | ||
const course = await this.courseRepository.findAsync(courseGetCommand.id) | ||
return new CourseGetResult(new CourseData(course)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Course } from 'src/domain/models/courses/course' | ||
|
||
/** | ||
* コースデータ(DTO) | ||
*/ | ||
export class CourseData { | ||
/** | ||
* ID | ||
*/ | ||
public readonly id: number | ||
|
||
/** | ||
* 名前 | ||
*/ | ||
public readonly name: string | ||
|
||
/** | ||
* コンストラクタ | ||
* | ||
* @param course コース | ||
*/ | ||
public constructor(course: Course) { | ||
this.id = course.id | ||
this.name = course.name | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* コース取得コマンド | ||
*/ | ||
export class CourseGetCommand { | ||
/** | ||
* コンストラクタ | ||
* | ||
* @param id ID | ||
*/ | ||
public constructor(public readonly id: number) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CourseData } from './courseData' | ||
|
||
/** | ||
* コース取得結果 | ||
*/ | ||
export class CourseGetResult { | ||
/** | ||
* コンストラクタ | ||
* | ||
* @param courseData コースデータ | ||
*/ | ||
public constructor(public readonly courseData: CourseData) {} | ||
} |
167 changes: 167 additions & 0 deletions
167
src/application/reportLists/reportListApplicationService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
import { describe, expect, test } from 'vitest' | ||
import { ReportListApplicationService } from './reportListApplicationService' | ||
import { InMemoryCourseRepository } from 'src/infrastructure/inMemory/courses/inMemoryCourseRepository' | ||
import { ReportListImportCommand } from './reportListImportCommand' | ||
import path from 'path' | ||
import { InMemoryReportRepository } from 'src/infrastructure/inMemory/reports/inMemoryReportRepository' | ||
import { InMemoryStudentRepository } from 'src/infrastructure/inMemory/students/inMemoryStudentRepository' | ||
import { InMemorySubmissionRepository } from 'src/infrastructure/inMemory/submissions/inMemorySubmissionRepository' | ||
import { InMemoryAssessmentRepository } from 'src/infrastructure/inMemory/assessments/inMemoryAssessmentRepository' | ||
|
||
describe('import', () => { | ||
test('The course of the report is saved.', async () => { | ||
const courseRepository = new InMemoryCourseRepository() | ||
const reportRepository = new InMemoryReportRepository() | ||
const studentRepository = new InMemoryStudentRepository() | ||
const submissionRepository = new InMemorySubmissionRepository() | ||
const assessmentRepository = new InMemoryAssessmentRepository() | ||
const service = new ReportListApplicationService( | ||
courseRepository, | ||
reportRepository, | ||
studentRepository, | ||
submissionRepository, | ||
assessmentRepository | ||
) | ||
const command = new ReportListImportCommand( | ||
path.join(__dirname, 'reportListImportTestFiles', 'reportlist.xlsx') | ||
) | ||
|
||
await service.importAsync(command) | ||
|
||
const course = await courseRepository.findAsync(27048) | ||
expect(course.id).toBe(27048) | ||
expect(course.name).toBe('コミュニケーション技術特論2') | ||
}) | ||
|
||
test('The report is saved.', async () => { | ||
const courseRepository = new InMemoryCourseRepository() | ||
const reportRepository = new InMemoryReportRepository() | ||
const studentRepository = new InMemoryStudentRepository() | ||
const submissionRepository = new InMemorySubmissionRepository() | ||
const assessmentRepository = new InMemoryAssessmentRepository() | ||
const service = new ReportListApplicationService( | ||
courseRepository, | ||
reportRepository, | ||
studentRepository, | ||
submissionRepository, | ||
assessmentRepository | ||
) | ||
const command = new ReportListImportCommand( | ||
path.join(__dirname, 'reportListImportTestFiles', 'reportlist.xlsx') | ||
) | ||
|
||
await service.importAsync(command) | ||
|
||
const report = await reportRepository.findAsync(35677) | ||
expect(report.courseId).toBe(27048) | ||
expect(report.id).toBe(35677) | ||
expect(report.title).toBe('個人レポート課題') | ||
}) | ||
|
||
test('The first student is saved.', async () => { | ||
const courseRepository = new InMemoryCourseRepository() | ||
const reportRepository = new InMemoryReportRepository() | ||
const studentRepository = new InMemoryStudentRepository() | ||
const submissionRepository = new InMemorySubmissionRepository() | ||
const assessmentRepository = new InMemoryAssessmentRepository() | ||
const service = new ReportListApplicationService( | ||
courseRepository, | ||
reportRepository, | ||
studentRepository, | ||
submissionRepository, | ||
assessmentRepository | ||
) | ||
const command = new ReportListImportCommand( | ||
path.join(__dirname, 'reportListImportTestFiles', 'reportlist.xlsx') | ||
) | ||
|
||
await service.importAsync(command) | ||
|
||
const student = await studentRepository.findAsync(23745148) | ||
expect(student.userId).toBe('a2348mt') | ||
expect(student.numId).toBe(23745148) | ||
expect(student.name).toBe('田中 真') | ||
}) | ||
|
||
test('The last student is saved.', async () => { | ||
const courseRepository = new InMemoryCourseRepository() | ||
const reportRepository = new InMemoryReportRepository() | ||
const studentRepository = new InMemoryStudentRepository() | ||
const submissionRepository = new InMemorySubmissionRepository() | ||
const assessmentRepository = new InMemoryAssessmentRepository() | ||
const service = new ReportListApplicationService( | ||
courseRepository, | ||
reportRepository, | ||
studentRepository, | ||
submissionRepository, | ||
assessmentRepository | ||
) | ||
const command = new ReportListImportCommand( | ||
path.join(__dirname, 'reportListImportTestFiles', 'reportlist.xlsx') | ||
) | ||
|
||
await service.importAsync(command) | ||
|
||
const student = await studentRepository.findAsync(23745197) | ||
expect(student.userId).toBe('a2397ka') | ||
expect(student.numId).toBe(23745197) | ||
expect(student.name).toBe('安藤 健') | ||
}) | ||
|
||
test('The first submission is saved.', async () => { | ||
const courseRepository = new InMemoryCourseRepository() | ||
const reportRepository = new InMemoryReportRepository() | ||
const studentRepository = new InMemoryStudentRepository() | ||
const submissionRepository = new InMemorySubmissionRepository() | ||
const assessmentRepository = new InMemoryAssessmentRepository() | ||
const service = new ReportListApplicationService( | ||
courseRepository, | ||
reportRepository, | ||
studentRepository, | ||
submissionRepository, | ||
assessmentRepository | ||
) | ||
const command = new ReportListImportCommand( | ||
path.join(__dirname, 'reportListImportTestFiles', 'reportlist.xlsx') | ||
) | ||
|
||
await service.importAsync(command) | ||
|
||
const submissions = await submissionRepository.findAsync(35677) | ||
const submission = submissions.find((x) => x.studentNumId === 23745148) | ||
expect(submission.reportId).toBe(35677) | ||
expect(submission.studentNumId).toBe(23745148) | ||
expect(submission.folderRelativePath).toBe('23745148@a2348mt') | ||
}) | ||
|
||
test('The first assessment is saved.', async () => { | ||
const courseRepository = new InMemoryCourseRepository() | ||
const reportRepository = new InMemoryReportRepository() | ||
const studentRepository = new InMemoryStudentRepository() | ||
const submissionRepository = new InMemorySubmissionRepository() | ||
const assessmentRepository = new InMemoryAssessmentRepository() | ||
const service = new ReportListApplicationService( | ||
courseRepository, | ||
reportRepository, | ||
studentRepository, | ||
submissionRepository, | ||
assessmentRepository | ||
) | ||
const command = new ReportListImportCommand( | ||
path.join(__dirname, 'reportListImportTestFiles', 'reportlist.xlsx') | ||
) | ||
|
||
await service.importAsync(command) | ||
|
||
const assessments = await assessmentRepository.findAsync(35677) | ||
const assessment = assessments.find((x) => x.studentNumId === 23745148) | ||
|
||
expect(assessment.reportId).toBe(35677) | ||
expect(assessment.studentNumId).toBe(23745148) | ||
expect(assessment.feedback).toBeUndefined() | ||
expect(assessment.memo).toBeUndefined() | ||
expect(assessment.grade).toBeUndefined() | ||
expect(assessment.rank).toBeUndefined() | ||
expect(assessment.score).toBeUndefined() | ||
}) | ||
}) |
Oops, something went wrong.