| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- import http from "../common/http";
- import {Gitlab} from "@gitbeaker/browser";
- import {store} from "@/redux/store";
- import {loadError, loadSuccess} from "@/redux/action/action";
- import {IFolderTreeNodeProps} from "@dtinsight/molecule/esm/model";
- import molecule from "@dtinsight/molecule";
- const basePath = './mock';
- const apiPath = '/api'
- const host = 'https://seecoder-gitlab-gitlab.seec.seecoder.cn';
- const token = 'Qhdx3cZF-WRPTTc1yWSf';
- const client = new Gitlab({
- host: host,
- token: token
- });
- const api = {
- getFolderTree() {
- const extToLang: { [prop: string]: string } = {
- 'html': 'html',
- 'js': 'javascript',
- 'ts': 'typescript',
- 'java': 'java',
- 'py': 'python',
- 'cpp': 'cpp',
- 'json': 'json',
- 'xml': 'xml',
- }
- const nameScope = store.getState().loadProject.nameScope
- const path = store.getState().loadProject.path
- const projectId = encodeURI(nameScope + '/' + path)
- async function getFolderInfo(parent: IFolderTreeNodeProps, parentPath: string): Promise<IFolderTreeNodeProps> {
- try {
- const tree = await client.Repositories.tree(projectId, {path: parentPath})
- for (const index in tree) {
- const file = tree[index]
- let fileNode: IFolderTreeNodeProps
- if (file.type === 'tree') {
- fileNode = {
- id: file.id,
- isEditable: false,
- name: file.name,
- fileType: "Folder",
- location: parentPath ? parentPath + '/' + file.name : file.name,
- isLeaf: false,
- children: []
- }
- await getFolderInfo(fileNode, fileNode.location!)
- fileNode.location = path + "/" + fileNode.location
- parent.children?.push(fileNode)
- } else {
- fileNode = {
- id: file.id,
- isEditable: false,
- name: file.name,
- fileType: "File",
- location: parentPath ? parentPath + '/' + file.name : file.name,
- isLeaf: true,
- data: ''
- }
- const data = await client.RepositoryFiles.show(projectId, fileNode.location!, 'master')
- const frag = fileNode.name!.split('.');
- const lang = extToLang[frag[frag.length - 1]] || 'file'
- fileNode.data = {language: lang, value: window.atob(data.content)}
- fileNode.location = path + "/" + fileNode.location
- parent.children?.push(fileNode)
- }
- }
- return parent
- } catch (e) {
- store.dispatch(loadError(e))
- return {id: 'error', data: e}
- }
- }
- let data: IFolderTreeNodeProps = {
- id: 0,
- isEditable: false,
- name: path,
- fileType: "RootFolder",
- location: path,
- isLeaf: false,
- data: "",
- children: []
- }
- const res = getFolderInfo(data, "")
- res.then(data => {
- console.log(data)
- if (data.id !== 'error') store.dispatch(loadSuccess())
- })
- return res
- },
- search(value: string) {
- return http.get(`${basePath}/folderTree.json`, {query: value});
- },
- async query(query: string = '') {
- const data = molecule.folderTree.getState().folderTree;
- const result: any[] = [];
- const search = (nodeItem: any) => {
- if (!nodeItem) return;
- const target = nodeItem.name || '';
- if (target.includes(query) || query.includes(target)) {
- result.push(nodeItem);
- }
- if (nodeItem.children) {
- nodeItem.children.forEach((item: any) => {
- search(item)
- })
- }
- }
- search(data);
- return result;
- },
- current() {
- return http.get(`${apiPath}/auth/current`)
- },
- getOnlineCodeByExamId(examId: number | string, userId?: number | string) {
- return http.get(`${apiPath}/exam/${examId}/onlinecode`,
- {userId: userId})
- },
- updateOnlineCodeByExamIdAndQuestionId(
- examId: number | string,
- questionId: number | string,
- codeDTO: CodeDTO
- ) {
- return http.post(`${apiPath}/exam/${examId}/onlinecode/${questionId}`, codeDTO)
- },
- getByExamId(examId: number | string) {
- return http.get(`${apiPath}/exam/${examId}`)
- },
- getByResultId(resultId: number | string) {
- return http.get(`${apiPath}/result/${resultId}`)
- },
- getByCommitId(commitId: number | string) {
- return http.get(`${apiPath}/commit/${commitId}`)
- },
- getByRecordId(recordId: number | string) {
- return http.get(`${apiPath}/record/${recordId}`)
- },
- getExamTest(examId: number):Promise<any> {
- return new Promise((resolve => {
- setTimeout(()=>{
- resolve(JSON.parse("{\n" +
- " \"err\": 0,\n" +
- " \"res\": {\n" +
- " \"id\": 6553,\n" +
- " \"name\": \"联调\",\n" +
- " \"startAt\": 1667232000,\n" +
- " \"endAt\": 1669737600,\n" +
- " \"status\": \"AVAILABLE\",\n" +
- " \"creator\": {\n" +
- " \"id\": 271,\n" +
- " \"username\": \"kenny67nju\"\n" +
- " },\n" +
- " \"joined\": false,\n" +
- " \"courseId\": 52,\n" +
- " \"url\": null,\n" +
- " \"problems\": [\n" +
- " {\n" +
- " \"id\": 63,\n" +
- " \"name\": \"plus2\",\n" +
- " \"type\": \"JAVA\",\n" +
- " \"description\": \"plus2\"\n" +
- " },\n" +
- " {\n" +
- " \"id\": 113,\n" +
- " \"name\": \"hanoi\",\n" +
- " \"type\": \"JAVA\",\n" +
- " \"description\": \"汉诺塔问题\"\n" +
- " },\n" +
- " {\n" +
- " \"id\": 95,\n" +
- " \"name\": \"good-map-game-new\",\n" +
- " \"type\": \"JAVA\",\n" +
- " \"description\": \"面向对象\"\n" +
- " }\n" +
- " ],\n" +
- " \"result\": null,\n" +
- " \"created_at\": 1667473399,\n" +
- " \"course\": \"基于Java的面向对象编程范式2022\"\n" +
- " }\n" +
- "}"))
- }, 500)
- }))
- },
- getRecordTest(recordId: number | string) {
- return new Promise((resolve) => {
- setTimeout(() => {
- resolve(JSON.parse("{\"err\":0,\n" +
- " \"res\":{\n" +
- " \"id\":36464,\n" +
- " \"number\":1,\n" +
- " \"status\":\"UNSTABLE\",\n" +
- " \"consoleOutput\":\"Timeout set to expire in 1 min 0 sec\\r\\nPicked up JAVA_TOOL_OPTIONS: -Dfile.encoding=utf-8\\r\\nPicked up _JAVA_OPTIONS: -Djdk.net.URLClassPath.disableClassPathURLCheck=true\\r\\n[INFO] Scanning for projects...\\r\\n[INFO] \\r\\n[INFO] ------------------------------------------------------------------------\\r\\n[INFO] Building matrix-calculation 1.0.0\\r\\n[INFO] ------------------------------------------------------------------------\\r\\n[INFO] \\r\\n[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ matrix-calculation ---\\r\\n[INFO] Deleting /var/ws/tmp/target\\r\\n[INFO] \\r\\n[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ matrix-calculation ---\\r\\n[INFO] Using 'UTF-8' encoding to copy filtered resources.\\r\\n[INFO] skip non existing resourceDirectory /var/ws/tmp/src/main/resources\\r\\n[INFO] \\r\\n[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) @ matrix-calculation ---\\r\\n[INFO] Changes detected - recompiling the module!\\r\\n[INFO] Compiling 1 source file to /var/ws/tmp/target/classes\\r\\n[INFO] \\r\\n[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ matrix-calculation ---\\r\\n[INFO] Using 'UTF-8' encoding to copy filtered resources.\\r\\n[INFO] skip non existing resourceDirectory /var/ws/tmp/src/test/resources\\r\\n[INFO] \\r\\n[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) @ matrix-calculation ---\\r\\n[INFO] Changes detected - recompiling the module!\\r\\n[INFO] Compiling 1 source file to /var/ws/tmp/target/test-classes\\r\\n[INFO] \\r\\n[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ matrix-calculation ---\\r\\n[INFO] Surefire report directory: /var/ws/tmp/target/surefire-reports\\r\\n\\r\\n-------------------------------------------------------\\r\\n T E S T S\\r\\n-------------------------------------------------------\\r\\nPicked up JAVA_TOOL_OPTIONS: -Dfile.encoding=utf-8\\r\\nPicked up _JAVA_OPTIONS: -Djdk.net.URLClassPath.disableClassPathURLCheck=true\\r\\nRunning edu.nju.test.MatrixCalculationTest\\r\\nTests run: 21, Failures: 11, Errors: 2, Skipped: 0, Time elapsed: 0.125 sec <<< FAILURE! - in edu.nju.test.MatrixCalculationTest\\r\\ntestPrint(edu.nju.test.MatrixCalculationTest) Time elapsed: 0.007 sec <<< FAILURE!\\r\\norg.junit.ComparisonFailure: expected:<[\\r\\n]1 1 1\\r\\n1 1 1\\r\\n1 1 1\\r\\n> but was:<[]1 1 1\\r\\n1 1 1\\r\\n1 1 1\\r\\n>\\r\\n\\tat org.junit.Assert.assertEquals(Assert.java:115)\\r\\n\\tat org.junit.Assert.assertEquals(Assert.java:144)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testPrint(MatrixCalculationTest.java:111)\\r\\n\\r\\ntestTimes(edu.nju.test.MatrixCalculationTest) Time elapsed: 0 sec <<< FAILURE!\\r\\njava.lang.AssertionError: null\\r\\n\\tat org.junit.Assert.fail(Assert.java:86)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimes(MatrixCalculationTest.java:65)\\r\\n\\r\\ntestPlusFromConsole4(edu.nju.test.MatrixCalculationTest) Time elapsed: 0.003 sec <<< ERROR!\\r\\njava.lang.ArrayIndexOutOfBoundsException: 0\\r\\n\\tat edu.nju.MatrixCalculation.plus(MatrixCalculation.java:20)\\r\\n\\tat edu.nju.MatrixCalculation.plusFromConsole(MatrixCalculation.java:81)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testPlusFromConsole4(MatrixCalculationTest.java:323)\\r\\n\\r\\ntestTimesFromConsole(edu.nju.test.MatrixCalculationTest) Time elapsed: 0.001 sec <<< FAILURE!\\r\\njava.lang.AssertionError: null\\r\\n\\tat org.junit.Assert.fail(Assert.java:86)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole(MatrixCalculationTest.java:97)\\r\\n\\r\\ntestPrint1(edu.nju.test.MatrixCalculationTest) Time elapsed: 0 sec <<< FAILURE!\\r\\norg.junit.ComparisonFailure: expected:<[\\r\\n]1 1 1\\r\\n> but was:<[]1 1 1\\r\\n>\\r\\n\\tat org.junit.Assert.assertEquals(Assert.java:115)\\r\\n\\tat org.junit.Assert.assertEquals(Assert.java:144)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testPrint1(MatrixCalculationTest.java:255)\\r\\n\\r\\ntestPrint2(edu.nju.test.MatrixCalculationTest) Time elapsed: 0 sec <<< FAILURE!\\r\\norg.junit.ComparisonFailure: expected:<[\\r\\n]1\\r\\n1\\r\\n1\\r\\n> but was:<[]1\\r\\n1\\r\\n1\\r\\n>\\r\\n\\tat org.junit.Assert.assertEquals(Assert.java:115)\\r\\n\\tat org.junit.Assert.assertEquals(Assert.java:144)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testPrint2(MatrixCalculationTest.java:267)\\r\\n\\r\\ntestTimesFromConsole1(edu.nju.test.MatrixCalculationTest) Time elapsed: 0.001 sec <<< FAILURE!\\r\\njava.lang.AssertionError: null\\r\\n\\tat org.junit.Assert.fail(Assert.java:86)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole1(MatrixCalculationTest.java:340)\\r\\n\\r\\ntestTimesFromConsole2(edu.nju.test.MatrixCalculationTest) Time elapsed: 0.002 sec <<< FAILURE!\\r\\njava.lang.AssertionError: null\\r\\n\\tat org.junit.Assert.fail(Assert.java:86)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole2(MatrixCalculationTest.java:357)\\r\\n\\r\\ntestTimesFromConsole3(edu.nju.test.MatrixCalculationTest) Time elapsed: 0.001 sec <<< FAILURE!\\r\\njava.lang.AssertionError: null\\r\\n\\tat org.junit.Assert.fail(Assert.java:86)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole3(MatrixCalculationTest.java:372)\\r\\n\\r\\ntestTimesFromConsole4(edu.nju.test.MatrixCalculationTest) Time elapsed: 0 sec <<< ERROR!\\r\\njava.lang.ArrayIndexOutOfBoundsException: 0\\r\\n\\tat edu.nju.MatrixCalculation.times(MatrixCalculation.java:34)\\r\\n\\tat edu.nju.MatrixCalculation.timesFromConsole(MatrixCalculation.java:107)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole4(MatrixCalculationTest.java:383)\\r\\n\\r\\ntestTimes1(edu.nju.test.MatrixCalculationTest) Time elapsed: 0 sec <<< FAILURE!\\r\\njava.lang.AssertionError: null\\r\\n\\tat org.junit.Assert.fail(Assert.java:86)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimes1(MatrixCalculationTest.java:203)\\r\\n\\r\\ntestTimes2(edu.nju.test.MatrixCalculationTest) Time elapsed: 0 sec <<< FAILURE!\\r\\njava.lang.AssertionError: null\\r\\n\\tat org.junit.Assert.fail(Assert.java:86)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimes2(MatrixCalculationTest.java:223)\\r\\n\\r\\ntestTimes3(edu.nju.test.MatrixCalculationTest) Time elapsed: 0 sec <<< FAILURE!\\r\\njava.lang.AssertionError: null\\r\\n\\tat org.junit.Assert.fail(Assert.java:86)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\r\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\r\\n\\tat edu.nju.test.MatrixCalculationTest.testTimes3(MatrixCalculationTest.java:241)\\r\\n\\r\\n\\r\\nResults :\\r\\n\\r\\nFailed tests: \\r\\n MatrixCalculationTest.testPrint:111 expected:<[\\r\\n]1 1 1\\r\\n1 1 1\\r\\n1 1 1\\r\\n> but was:<[]1 1 1\\r\\n1 1 1\\r\\n1 1 1\\r\\n>\\r\\n MatrixCalculationTest.testTimes:65 null\\r\\n MatrixCalculationTest.testTimesFromConsole:97 null\\r\\n MatrixCalculationTest.testPrint1:255 expected:<[\\r\\n]1 1 1\\r\\n> but was:<[]1 1 1\\r\\n>\\r\\n MatrixCalculationTest.testPrint2:267 expected:<[\\r\\n]1\\r\\n1\\r\\n1\\r\\n> but was:<[]1\\r\\n1\\r\\n1\\r\\n>\\r\\n MatrixCalculationTest.testTimesFromConsole1:340 null\\r\\n MatrixCalculationTest.testTimesFromConsole2:357 null\\r\\n MatrixCalculationTest.testTimesFromConsole3:372 null\\r\\n MatrixCalculationTest.testTimes1:203 null\\r\\n MatrixCalculationTest.testTimes2:223 null\\r\\n MatrixCalculationTest.testTimes3:241 null\\r\\n\\r\\nTests in error: \\r\\n MatrixCalculationTest.testPlusFromConsole4:323 » ArrayIndexOutOfBounds 0\\r\\n MatrixCalculationTest.testTimesFromConsole4:383 » ArrayIndexOutOfBounds 0\\r\\n\\r\\nTests run: 21, Failures: 11, Errors: 2, Skipped: 0\\r\\n\\r\\n[INFO] ------------------------------------------------------------------------\\r\\n[INFO] BUILD FAILURE\\r\\n[INFO] ------------------------------------------------------------------------\\r\\n[INFO] Total time: 5.066 s\\r\\n[INFO] Finished at: 2022-10-12T04:45:26+00:00\\r\\n[INFO] Final Memory: 13M/33M\\r\\n[INFO] ------------------------------------------------------------------------\\r\\n[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project matrix-calculation: There are test failures.\\r\\n[ERROR] \\r\\n[ERROR] Please refer to /var/ws/tmp/target/surefire-reports for the individual test results.\\r\\n[ERROR] -> [Help 1]\\r\\n[ERROR] \\r\\n[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.\\r\\n[ERROR] Re-run Maven using the -X switch to enable full debug logging.\\r\\n[ERROR] \\r\\n[ERROR] For more information about the errors and possible solutions, please read the following articles:\\r\\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException\\r\\n[INFO] Build failures were ignored.\\r\\n\",\n" +
- " \"score\":38,\n" +
- " \"failures\": [\n" +
- " {\"name\":\"edu.nju.test.MatrixCalculationTest.testTimes1\",\n" +
- " \"details\":\"\",\n" +
- " \"trace\":\"java.lang.AssertionError: null\\n\\tat org.junit.Assert.fail(Assert.java:86)\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimes1(MatrixCalculationTest.java:203)\\n\"},\n" +
- " {\"name\":\"edu.nju.test.MatrixCalculationTest.testPrint1\",\"details\":\"expected:<[\\n]1 1 1\\n> but was:<[]1 1 1\\n>\",\"trace\":\"org.junit.ComparisonFailure: expected:<[\\n]1 1 1\\n> but was:<[]1 1 1\\n>\\n\\tat org.junit.Assert.assertEquals(Assert.java:115)\\n\\tat org.junit.Assert.assertEquals(Assert.java:144)\\n\\tat edu.nju.test.MatrixCalculationTest.testPrint1(MatrixCalculationTest.java:255)\\n\"},\n" +
- " {\"name\":\"edu.nju.test.MatrixCalculationTest.testTimesFromConsole2\",\"details\":\"\",\"trace\":\"java.lang.AssertionError: null\\n\\tat org.junit.Assert.fail(Assert.java:86)\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole2(MatrixCalculationTest.java:357)\\n\"},\n" +
- " {\"name\":\"edu.nju.test.MatrixCalculationTest.testTimes3\",\"details\":\"\",\"trace\":\"java.lang.AssertionError: null\\n\\tat org.junit.Assert.fail(Assert.java:86)\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimes3(MatrixCalculationTest.java:241)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testTimesFromConsole4\",\"details\":\"0\",\"trace\":\"java.lang.ArrayIndexOutOfBoundsException: 0\\n\\tat edu.nju.MatrixCalculation.times(MatrixCalculation.java:34)\\n\\tat edu.nju.MatrixCalculation.timesFromConsole(MatrixCalculation.java:107)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole4(MatrixCalculationTest.java:383)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testTimes\",\"details\":\"\",\"trace\":\"java.lang.AssertionError: null\\n\\tat org.junit.Assert.fail(Assert.java:86)\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimes(MatrixCalculationTest.java:65)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testPrint2\",\"details\":\"expected:<[\\n]1\\n1\\n1\\n> but was:<[]1\\n1\\n1\\n>\",\"trace\":\"org.junit.ComparisonFailure: expected:<[\\n]1\\n1\\n1\\n> but was:<[]1\\n1\\n1\\n>\\n\\tat org.junit.Assert.assertEquals(Assert.java:115)\\n\\tat org.junit.Assert.assertEquals(Assert.java:144)\\n\\tat edu.nju.test.MatrixCalculationTest.testPrint2(MatrixCalculationTest.java:267)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testTimesFromConsole1\",\"details\":\"\",\"trace\":\"java.lang.AssertionError: null\\n\\tat org.junit.Assert.fail(Assert.java:86)\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole1(MatrixCalculationTest.java:340)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testPlusFromConsole4\",\"details\":\"0\",\"trace\":\"java.lang.ArrayIndexOutOfBoundsException: 0\\n\\tat edu.nju.MatrixCalculation.plus(MatrixCalculation.java:20)\\n\\tat edu.nju.MatrixCalculation.plusFromConsole(MatrixCalculation.java:81)\\n\\tat edu.nju.test.MatrixCalculationTest.testPlusFromConsole4(MatrixCalculationTest.java:323)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testTimesFromConsole\",\"details\":\"\",\"trace\":\"java.lang.AssertionError: null\\n\\tat org.junit.Assert.fail(Assert.java:86)\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole(MatrixCalculationTest.java:97)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testTimesFromConsole3\",\"details\":\"\",\"trace\":\"java.lang.AssertionError: null\\n\\tat org.junit.Assert.fail(Assert.java:86)\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimesFromConsole3(MatrixCalculationTest.java:372)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testPrint\",\"details\":\"expected:<[\\n]1 1 1\\n1 1 1\\n1 1 1\\n> but was:<[]1 1 1\\n1 1 1\\n1 1 1\\n>\",\"trace\":\"org.junit.ComparisonFailure: expected:<[\\n]1 1 1\\n1 1 1\\n1 1 1\\n> but was:<[]1 1 1\\n1 1 1\\n1 1 1\\n>\\n\\tat org.junit.Assert.assertEquals(Assert.java:115)\\n\\tat org.junit.Assert.assertEquals(Assert.java:144)\\n\\tat edu.nju.test.MatrixCalculationTest.testPrint(MatrixCalculationTest.java:111)\\n\"},{\"name\":\"edu.nju.test.MatrixCalculationTest.testTimes2\",\"details\":\"\",\"trace\":\"java.lang.AssertionError: null\\n\\tat org.junit.Assert.fail(Assert.java:86)\\n\\tat org.junit.Assert.assertTrue(Assert.java:41)\\n\\tat org.junit.Assert.assertTrue(Assert.java:52)\\n\\tat edu.nju.test.MatrixCalculationTest.testTimes2(MatrixCalculationTest.java:223)\\n\"}],\n" +
- " \"commit\": {\n" +
- " \"id\":32552,\n" +
- " \"created_at\":1665549884\n" +
- " }\n" +
- " }\n" +
- "}"))
- }, 500)
- })
- },
- async test(examId: number, questionId: number):Promise<any> {
- http.get(`${apiPath}/auth/current`)
- return new Promise((resolve) => {
- setTimeout(() => {
- resolve(JSON.parse("{\"err\":0,\n" +
- " \"res\":{\n" +
- " \"examId\":6629,\n" +
- " \"fetchAt\":1669059664,\n" +
- " \"startAt\":1668441600,\n" +
- " \"endAt\":1669737600,\n" +
- " \"codeList\":[\n" +
- " {\"questionId\":113,\n" +
- " \"language\":\"JAVA\",\n" +
- " \"projectName\":\"113-hanoi\",\n" +
- " \"editable\":{\n" +
- " \"/src/main/java/TowerOfHanoi.java\":\"public class TowerOfHanoi {\\n public void Hanoi(int n) {}\\n}\\n\"},\n" +
- " \"uneditable\":{\n" +
- " \"/README.md\":\"2.实现Hanoi塔\\r\\n\\r\\n问题描述:递归实现汉诺塔,有三根杆(编号A、B、C),在A杆自下而上、由大到小按顺序放置n个盘子。\\r\\n要求把A杆上的盘子全部移到B杆上,并仍保持原有顺序叠好。\\r\\n操作规则:每次只能移动一个盘子,并且在移动过程中三根杆上都始终保持大盘在下,小盘在上,操作过程中盘子可以置于A、B、C任一杆上。\\r\\n\\r\\n完成函数Hanoi,使用标准输出打印移动盘子的过程。\\r\\n输入:n为正整数,n >= 1\\r\\n\\r\\n示例:\\r\\nn = 2\\r\\n打印结果(最后一行有换行符):\\r\\nMove disk 1 from A to C\\r\\nMove disk 2 from A to B\\r\\nMove disk 1 from C to B\\r\\n\"\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- "}"))
- }, 2500)
- })
- },
- // getQuestion(examId: number, questionId: number) {
- // return http.get(`${apiPath}/exam/${examId}/onlinecode/${questionId}`)
- // },
- getQuestion(examId: number, userId: number) {
- if (userId) return http.get(`${apiPath}/exam/${examId}/onlinecode`, {userId: userId})
- else return http.get(`${apiPath}/exam/${examId}/onlinecode`)
- }
- }
- export interface CodeDTO {
- code: { [key: string]: string }
- }
- export interface PageSerializer {
- page?: number
- limit?: number
- size?: number
- total?: number
- }
- export interface ResultSerializer {
- id?: number
- score?: number
- lastCommitAt?: number
- deleted?: boolean
- exam?: {
- id?: number
- name?: string
- course?: string
- }
- owner?: {
- id?: number
- username?: string
- }
- commits?: Array<{
- id?: number
- finished?: boolean
- score?: number
- // eslint-disable-next-line camelcase
- created_at?: number
- }>
- }
- export interface CommitSerializer {
- id?: number
- hash?: string
- finished?: boolean
- score?: number
- createdAt?: number
- result?: {
- id?: number
- score?: number
- exam?: {
- id?: number
- name?: string
- }
- owner?: {
- id?: number
- username?: string
- }
- }
- records?: Array<{
- id?: number
- status?: BuildStatus
- score?: number
- problem?: {
- id?: number
- name?: string
- }
- }>
- }
- export interface ExamSerializer {
- id?: number
- name?: string
- // eslint-disable-next-line camelcase
- created_at?: number
- startAt?: number
- endAt?: number
- status?: ExamStatus
- creator?: {
- id?: number
- username?: string
- }
- problems?: ProblemSerializer[]
- joined?: boolean
- courseId?: number
- courseName?: string
- result?: ResultSerializer
- isCodeAnalysisNeeded?: boolean
- url?: string
- }
- export type ProblemType =
- | 'JAVA' // 普通Java题目,统计测试用例通过情况
- | 'JAVA_DATABASE' // 带数据库的Java题目,统计测试用例通过情况
- | 'PYTHON' // 普通Python题目,统计测试用例通过情况
- | 'JAVA_COVERAGE' // Java测试覆盖率题目,统计测试覆盖率
- | 'PYTHON_COVERAGE' // Python测试覆盖率题目,统计测试覆盖率
- | 'JAVA_MUTATION' // Java变异覆盖题目,统计变异覆盖率
- | 'JAVA_DATA_STRUCTURE' // 带数据结构的Java题目,统计测试用例通过情况
- | 'JAVA_COMPUTER_ORGANIZATION' // 带计算机组成原理的Java题目,统计测试用例通过情况
- | 'JAVA_SOFTWARE_DESIGN' // 带软件设计的Java题目,统计测试用例通过情况
- export interface ProblemSerializer {
- id?: number
- name?: string
- type?: ProblemType
- description?: string
- publicFiles?: Array<string>
- protectedFiles?: Array<string>
- privateFiles?: Array<string>
- createdAt?: number
- modifiedAt?: number
- deprecated?: boolean
- creator?: {
- id?: number
- username?: string
- }
- }
- export interface ReceivedData<R = {}, E = 0> {
- msg?: string
- err?: E | 0 | 401
- res?: R
- page?: PageSerializer
- }
- export type UserRole =
- | 'STUDENT'
- | 'TEACHER'
- | 'ADMIN'
- | 'HR'
- | 'STAFF'
- | 'SEEC'
- | 'SEECX'
- | 'ASSISTANT'
- export interface UserSerializer {
- id?: number
- score?: number
- username?: string
- email?: string
- phone?: string
- role?: UserRole
- }
- export interface CodeSerializer {
- examId?: number
- fetchAt?: number
- startAt?: number
- endAt?: number
- codeList?: Array<NestedCodeItemVO>
- }
- export interface NestedCodeItemVO {
- questionId?: number
- language?: string
- projectName?: string
- editable?: {
- [key: string]: string
- }
- uneditable?: {
- [key: string]: string
- }
- }
- export type ExamStatus =
- | 'PREPARING' // 正在准备试题,通常是正在PUSH试题
- | 'UNAVAILABLE' // 考试不可用,通常是PUSH试题失败
- | 'READY' // 考试已准备好,在考试尚未开始时使用,不持久化到数据库中
- | 'AVAILABLE' // 考试可用,表示考试正在进行,持久化时考试从准备好到考试被关闭均为此状态
- | 'FINISHED' // 考试已完成,在考试结束后使用,不持久化到数据库中
- | 'CLOSED' // 考试已关闭,表示考试生命周期结束,所有试卷均被存档
- export type BuildStatus =
- | 'SUCCESS' // 构建成功,表示没有错误
- | 'UNSTABLE' // 构建不稳定,表示有测试错误等非致命错误
- | 'FAILURE' // 构建失败,表示有语法错误等致命错误
- | 'TIMEOUT' // 构建超时,表示运行测试时超时
- | 'WAITING' // 等待构建,表示构建尚未开始
- | 'RUNNING' // 正在构建,表示构建正在进行
- export default api;
|