Skip to content

Commit

Permalink
Weekly merge main into release
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jul 8, 2024
2 parents ef16318 + 16a4181 commit 848d343
Show file tree
Hide file tree
Showing 63 changed files with 4,592 additions and 2,143 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

</head>

<body>
<body class="bg-gray-50">
<script type="module" src="/src/renderer.ts"></script>
</body>

Expand Down
1,457 changes: 1,399 additions & 58 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vitest/coverage-v8": "^1.6.0",
"autoprefixer": "^10.4.19",
"electron": "31.0.1",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"jsdom": "^24.1.0",
"postcss": "^8.4.39",
"tailwindcss": "^3.4.4",
"ts-node": "^10.9.2",
"typescript": "~4.5.4",
"vite": "^5.3.1",
Expand All @@ -50,6 +53,8 @@
"exceljs": "^4.4.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-drag-drop-files": "^2.3.10",
"react-icons": "^5.2.1",
"react-router-dom": "^6.23.1"
}
}
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
25 changes: 25 additions & 0 deletions src/@types/interface.d.ts
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
}
}
11 changes: 4 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { HashRouter, Route, Routes } from "react-router-dom";
import CommonLayout from "./common/CommonLayout";

// ページコンポーネントのインポート
import Home from "./pages/Home";
import Evaluation from "./pages/Evaluation";
import Home from "./presentation/pages/Home";
import Evaluation from "./presentation/pages/Evaluation";

export default function App() {
return (
// Electron では BrowserRouter ではなく HashRouter を使う
<HashRouter>
<Routes>
<Route path="/" element={<CommonLayout />}>
<Route index element={<Home />} />
<Route path="/evaluation" element={<Evaluation />} />
</Route>
<Route path="/" element={<Home />} />
<Route path="/evaluation/:reportId" element={<Evaluation />} />
</Routes>
</HashRouter>
);
Expand Down
20 changes: 20 additions & 0 deletions src/application/courses/courseApplicationService.test.ts
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)
})
})
29 changes: 29 additions & 0 deletions src/application/courses/courseApplicationService.ts
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))
}
}
26 changes: 26 additions & 0 deletions src/application/courses/courseData.ts
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
}
}
11 changes: 11 additions & 0 deletions src/application/courses/courseGetCommand.ts
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) {}
}
13 changes: 13 additions & 0 deletions src/application/courses/courseGetResult.ts
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 src/application/reportLists/reportListApplicationService.test.ts
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()
})
})
Loading

0 comments on commit 848d343

Please sign in to comment.