@elice/material-exercise 1.230312.0-helpi.0 → 1.230313.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,7 +87,7 @@ const ExerciseRunner = ({
87
87
  const error = runner.getProgrammingErrorResult(text);
88
88
 
89
89
  if (!!error && typeof onCodeHelpRequest === 'function') {
90
- onCodeHelpRequest(text, error);
90
+ onCodeHelpRequest(error.errorCode, error);
91
91
  }
92
92
  };
93
93
 
@@ -1,6 +1,7 @@
1
1
  declare type ErrorType = 'runtime' | 'compile' | 'syntax';
2
2
  declare type ErrorLangType = 'python' | 'c/cpp' | 'java' | 'javascript';
3
3
  export declare type CodeHelperError = {
4
+ errorCode: string;
4
5
  errorLangType: ErrorLangType;
5
6
  errorType: ErrorType;
6
7
  };
@@ -6,59 +6,68 @@ Object.defineProperty(exports, '__esModule', { value: true });
6
6
  // This logic is based on the following spreadsheet.
7
7
  // https://docs.google.com/spreadsheets/d/1AeIf1eIlxp2MFR5hZijr-s304xVHMdtuAzcODS6nL-g/edit#gid=0
8
8
  //
9
- const PythonRuntimeErrorRegex = new RegExp(/Traceback \(most recent call last\):\n\s*File "\S+", line \d+, in \S+\n\s*.*\n(.+\n)*\S+Error:\s.+/gm);
10
- const PythonSyntaxErrorRegex = new RegExp(/File "(.*?)", line (\d+)\n\s*.+\n\s*(\^+)\n(.+)Error:\s(.+)/gm);
11
- const CCCPCompileErrorRegex = new RegExp(/(.*?):(\d+):(\d+):\s+(warning|error|note):\s+(.*)(\n.+\n.+)?/gm);
12
- const CCCPRuntimeErrorRegex = new RegExp(/(\w+ fault)\s+\(.*\)/gm);
13
- const JavaCompileErrorRegex = new RegExp(/(.*?):(\d+):\s+error:\s+(.*)\n.+\n.+(\n\s*symbol.+)?(\n\s*location.+)?/gm);
14
- const JavaRuntimeErrorRegex = new RegExp(/^Exception in thread ".+" (.+)$\n((?:\s+at .+$\n)+)/gm);
15
- const JavascriptRuntimeErrorRegex = new RegExp(/(Uncaught )?(\w+Error):\s+(.*)\n((?:\s+at .+$\n)+)/gm);
9
+
16
10
  /**
17
11
  * Get Programming Error Results from text.
18
12
  */
19
-
20
13
  function getProgrammingErrorResult(text) {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
15
+
21
16
  const escapedText = text.replace(/[\r|\\]/gm, '');
17
+ const PythonRuntimeErrorRegex = new RegExp(/Traceback \(most recent call last\):\n\s*File "\S+", line \d+, in \S+\n\s*.*\n(.+\n)*\S+Error:\s.+/gm);
18
+ const PythonSyntaxErrorRegex = new RegExp(/File "(.*?)", line (\d+)\n\s*.+\n\s*(\^+)\n(.+)Error:\s(.+)/gm);
19
+ const CCCPCompileErrorRegex = new RegExp(/(.*?):(\d+):(\d+):\s+(warning|error|note):\s+(.*)(\n.+\n.+)?/gm);
20
+ const CCCPRuntimeErrorRegex = new RegExp(/(\w+ fault)\s+\(.*\)/gm);
21
+ const JavaCompileErrorRegex = new RegExp(/(.*?):(\d+):\s+error:\s+(.*)\n.+\n.+(\n\s*symbol.+)?(\n\s*location.+)?/gm);
22
+ const JavaRuntimeErrorRegex = new RegExp(/^Exception in thread ".+" (.+)$\n((?:\s+at .+$\n)+)/gm);
23
+ const JavascriptRuntimeErrorRegex = new RegExp(/(Uncaught )?(\w+Error):\s+(.*)\n((?:\s+at .+$\n)+)/gm);
22
24
 
23
25
  switch (true) {
24
26
  case PythonRuntimeErrorRegex.test(escapedText):
25
27
  return {
28
+ errorCode: (_b = (_a = escapedText.match(PythonRuntimeErrorRegex)) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => acc + '\n' + curr)) !== null && _b !== void 0 ? _b : '',
26
29
  errorLangType: 'python',
27
30
  errorType: 'runtime'
28
31
  };
29
32
 
30
33
  case PythonSyntaxErrorRegex.test(escapedText):
31
34
  return {
35
+ errorCode: (_d = (_c = escapedText.match(PythonSyntaxErrorRegex)) === null || _c === void 0 ? void 0 : _c.reduce((acc, curr) => acc + '\n' + curr)) !== null && _d !== void 0 ? _d : '',
32
36
  errorLangType: 'python',
33
37
  errorType: 'syntax'
34
38
  };
35
39
 
36
40
  case CCCPCompileErrorRegex.test(escapedText):
37
41
  return {
42
+ errorCode: (_f = (_e = escapedText.match(CCCPCompileErrorRegex)) === null || _e === void 0 ? void 0 : _e.reduce((acc, curr) => acc + '\n' + curr)) !== null && _f !== void 0 ? _f : '',
38
43
  errorLangType: 'c/cpp',
39
44
  errorType: 'compile'
40
45
  };
41
46
 
42
47
  case CCCPRuntimeErrorRegex.test(escapedText):
43
48
  return {
49
+ errorCode: (_h = (_g = escapedText.match(CCCPRuntimeErrorRegex)) === null || _g === void 0 ? void 0 : _g.reduce((acc, curr) => acc + '\n' + curr)) !== null && _h !== void 0 ? _h : '',
44
50
  errorLangType: 'c/cpp',
45
51
  errorType: 'runtime'
46
52
  };
47
53
 
48
54
  case JavaCompileErrorRegex.test(escapedText):
49
55
  return {
56
+ errorCode: (_k = (_j = escapedText.match(JavaCompileErrorRegex)) === null || _j === void 0 ? void 0 : _j.reduce((acc, curr) => acc + '\n' + curr)) !== null && _k !== void 0 ? _k : '',
50
57
  errorLangType: 'java',
51
58
  errorType: 'compile'
52
59
  };
53
60
 
54
61
  case JavaRuntimeErrorRegex.test(escapedText):
55
62
  return {
63
+ errorCode: (_m = (_l = escapedText.match(JavaRuntimeErrorRegex)) === null || _l === void 0 ? void 0 : _l.reduce((acc, curr) => acc + '\n' + curr)) !== null && _m !== void 0 ? _m : '',
56
64
  errorLangType: 'java',
57
65
  errorType: 'runtime'
58
66
  };
59
67
 
60
68
  case JavascriptRuntimeErrorRegex.test(escapedText):
61
69
  return {
70
+ errorCode: (_p = (_o = escapedText.match(JavascriptRuntimeErrorRegex)) === null || _o === void 0 ? void 0 : _o.reduce((acc, curr) => acc + '\n' + curr)) !== null && _p !== void 0 ? _p : '',
62
71
  errorLangType: 'javascript',
63
72
  errorType: 'runtime'
64
73
  };
@@ -80,7 +80,7 @@ const ExerciseRunner = ({
80
80
  const error = getProgrammingErrorResult(text);
81
81
 
82
82
  if (!!error && typeof onCodeHelpRequest === 'function') {
83
- onCodeHelpRequest(text, error);
83
+ onCodeHelpRequest(error.errorCode, error);
84
84
  }
85
85
  };
86
86
 
@@ -1,6 +1,7 @@
1
1
  declare type ErrorType = 'runtime' | 'compile' | 'syntax';
2
2
  declare type ErrorLangType = 'python' | 'c/cpp' | 'java' | 'javascript';
3
3
  export declare type CodeHelperError = {
4
+ errorCode: string;
4
5
  errorLangType: ErrorLangType;
5
6
  errorType: ErrorType;
6
7
  };
@@ -2,59 +2,68 @@
2
2
  // This logic is based on the following spreadsheet.
3
3
  // https://docs.google.com/spreadsheets/d/1AeIf1eIlxp2MFR5hZijr-s304xVHMdtuAzcODS6nL-g/edit#gid=0
4
4
  //
5
- const PythonRuntimeErrorRegex = new RegExp(/Traceback \(most recent call last\):\n\s*File "\S+", line \d+, in \S+\n\s*.*\n(.+\n)*\S+Error:\s.+/gm);
6
- const PythonSyntaxErrorRegex = new RegExp(/File "(.*?)", line (\d+)\n\s*.+\n\s*(\^+)\n(.+)Error:\s(.+)/gm);
7
- const CCCPCompileErrorRegex = new RegExp(/(.*?):(\d+):(\d+):\s+(warning|error|note):\s+(.*)(\n.+\n.+)?/gm);
8
- const CCCPRuntimeErrorRegex = new RegExp(/(\w+ fault)\s+\(.*\)/gm);
9
- const JavaCompileErrorRegex = new RegExp(/(.*?):(\d+):\s+error:\s+(.*)\n.+\n.+(\n\s*symbol.+)?(\n\s*location.+)?/gm);
10
- const JavaRuntimeErrorRegex = new RegExp(/^Exception in thread ".+" (.+)$\n((?:\s+at .+$\n)+)/gm);
11
- const JavascriptRuntimeErrorRegex = new RegExp(/(Uncaught )?(\w+Error):\s+(.*)\n((?:\s+at .+$\n)+)/gm);
5
+
12
6
  /**
13
7
  * Get Programming Error Results from text.
14
8
  */
15
-
16
9
  function getProgrammingErrorResult(text) {
10
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
11
+
17
12
  const escapedText = text.replace(/[\r|\\]/gm, '');
13
+ const PythonRuntimeErrorRegex = new RegExp(/Traceback \(most recent call last\):\n\s*File "\S+", line \d+, in \S+\n\s*.*\n(.+\n)*\S+Error:\s.+/gm);
14
+ const PythonSyntaxErrorRegex = new RegExp(/File "(.*?)", line (\d+)\n\s*.+\n\s*(\^+)\n(.+)Error:\s(.+)/gm);
15
+ const CCCPCompileErrorRegex = new RegExp(/(.*?):(\d+):(\d+):\s+(warning|error|note):\s+(.*)(\n.+\n.+)?/gm);
16
+ const CCCPRuntimeErrorRegex = new RegExp(/(\w+ fault)\s+\(.*\)/gm);
17
+ const JavaCompileErrorRegex = new RegExp(/(.*?):(\d+):\s+error:\s+(.*)\n.+\n.+(\n\s*symbol.+)?(\n\s*location.+)?/gm);
18
+ const JavaRuntimeErrorRegex = new RegExp(/^Exception in thread ".+" (.+)$\n((?:\s+at .+$\n)+)/gm);
19
+ const JavascriptRuntimeErrorRegex = new RegExp(/(Uncaught )?(\w+Error):\s+(.*)\n((?:\s+at .+$\n)+)/gm);
18
20
 
19
21
  switch (true) {
20
22
  case PythonRuntimeErrorRegex.test(escapedText):
21
23
  return {
24
+ errorCode: (_b = (_a = escapedText.match(PythonRuntimeErrorRegex)) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => acc + '\n' + curr)) !== null && _b !== void 0 ? _b : '',
22
25
  errorLangType: 'python',
23
26
  errorType: 'runtime'
24
27
  };
25
28
 
26
29
  case PythonSyntaxErrorRegex.test(escapedText):
27
30
  return {
31
+ errorCode: (_d = (_c = escapedText.match(PythonSyntaxErrorRegex)) === null || _c === void 0 ? void 0 : _c.reduce((acc, curr) => acc + '\n' + curr)) !== null && _d !== void 0 ? _d : '',
28
32
  errorLangType: 'python',
29
33
  errorType: 'syntax'
30
34
  };
31
35
 
32
36
  case CCCPCompileErrorRegex.test(escapedText):
33
37
  return {
38
+ errorCode: (_f = (_e = escapedText.match(CCCPCompileErrorRegex)) === null || _e === void 0 ? void 0 : _e.reduce((acc, curr) => acc + '\n' + curr)) !== null && _f !== void 0 ? _f : '',
34
39
  errorLangType: 'c/cpp',
35
40
  errorType: 'compile'
36
41
  };
37
42
 
38
43
  case CCCPRuntimeErrorRegex.test(escapedText):
39
44
  return {
45
+ errorCode: (_h = (_g = escapedText.match(CCCPRuntimeErrorRegex)) === null || _g === void 0 ? void 0 : _g.reduce((acc, curr) => acc + '\n' + curr)) !== null && _h !== void 0 ? _h : '',
40
46
  errorLangType: 'c/cpp',
41
47
  errorType: 'runtime'
42
48
  };
43
49
 
44
50
  case JavaCompileErrorRegex.test(escapedText):
45
51
  return {
52
+ errorCode: (_k = (_j = escapedText.match(JavaCompileErrorRegex)) === null || _j === void 0 ? void 0 : _j.reduce((acc, curr) => acc + '\n' + curr)) !== null && _k !== void 0 ? _k : '',
46
53
  errorLangType: 'java',
47
54
  errorType: 'compile'
48
55
  };
49
56
 
50
57
  case JavaRuntimeErrorRegex.test(escapedText):
51
58
  return {
59
+ errorCode: (_m = (_l = escapedText.match(JavaRuntimeErrorRegex)) === null || _l === void 0 ? void 0 : _l.reduce((acc, curr) => acc + '\n' + curr)) !== null && _m !== void 0 ? _m : '',
52
60
  errorLangType: 'java',
53
61
  errorType: 'runtime'
54
62
  };
55
63
 
56
64
  case JavascriptRuntimeErrorRegex.test(escapedText):
57
65
  return {
66
+ errorCode: (_p = (_o = escapedText.match(JavascriptRuntimeErrorRegex)) === null || _o === void 0 ? void 0 : _o.reduce((acc, curr) => acc + '\n' + curr)) !== null && _p !== void 0 ? _p : '',
58
67
  errorLangType: 'javascript',
59
68
  errorType: 'runtime'
60
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-exercise",
3
- "version": "1.230312.0-helpi.0",
3
+ "version": "1.230313.1",
4
4
  "description": "User view and editing components of Elice material exercise",
5
5
  "repository": "https://git.elicer.io/elice/frontend/library/elice-material",
6
6
  "license": "UNLICENSED",
@@ -79,8 +79,8 @@
79
79
  "@elice/design-tokens": "^1.220803.0",
80
80
  "@elice/icons": "^1.220803.0",
81
81
  "@elice/markdown": "^1.220803.0",
82
- "@elice/material-shared-types": "1.230312.0-helpi.0",
83
- "@elice/material-shared-utils": "1.230312.0-helpi.0",
82
+ "@elice/material-shared-types": "1.230313.1",
83
+ "@elice/material-shared-utils": "1.230313.1",
84
84
  "@elice/types": "^1.230306.0",
85
85
  "@elice/websocket": "^1.220803.0",
86
86
  "@types/classnames": "^2.3.1",
@@ -102,5 +102,5 @@
102
102
  "recoil": "^0.6.1",
103
103
  "styled-components": "^5.2.0"
104
104
  },
105
- "gitHead": "33fd75527b000d6c4ba0abf51963ad633a1b9f91"
105
+ "gitHead": "2c13705a151738af64422acb498a4f6cfe1dbc4b"
106
106
  }