Skip to content

Commit 34c1fd3

Browse files
authored
Merge pull request #162 from SPARSH1608/feature/sql-added
fixed locked contest issue
2 parents fa9177f + 7ae3a41 commit 34c1fd3

File tree

15 files changed

+125
-22
lines changed

15 files changed

+125
-22
lines changed

app/helpers/json-to-table.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { helper } from '@ember/component/helper';
2+
import convertToTable from '../util/json-to-table';
3+
4+
export default helper(function jsonToTable([data]) {
5+
return convertToTable(data);
6+
});

app/pods/components/code-editor-component/template.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
{{/if}}
2020
<SubmissionResult
2121
@fullScreen={{fullScreen}}
22+
@allowedLanguages={{contest.allowedLanguages}}
23+
2224
@judgeResult={{if (not submission.codeTaskGroup.isRunning) lastResult}} />
2325
</div>
2426
{{/if}}

app/pods/components/code-window/component.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ export default class CodeWindowComponent extends Component {
4848
code: "csharp",
4949
mode: "csharp",
5050
source: ""
51-
}
51+
}, {
52+
name: "MySQL 10",
53+
code: "mysql",
54+
mode: "mysql",
55+
source: ""
56+
}
5257
]
5358

5459
setSubmission = () => {

app/pods/components/full-screen-problem-view/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</div>
4949
<div class="w-100">
5050
{{#liquid-if (eq currentTab 'problem')}}
51-
<ProblemExplanation @problem={{problem}} />
51+
<ProblemExplanation @problem={{problem}} @contest={{contest}}/>
5252
{{else if (eq currentTab 'submissions')}}
5353
<SubmissionsList
5454
@contest={{contest}}
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
11
import Component from '@ember/component';
2+
import { inject as service } from '@ember/service';
3+
import jsonToTable from '../../../helpers/json-to-table';
24

35
export default Component.extend({
4-
});
6+
7+
languageSelection: service('language-selection'),
8+
init(){
9+
this._super(...arguments);
10+
let contest = this.get('contest').data;
11+
12+
document.addEventListener('contextmenu', function (event) {
13+
event.preventDefault();
14+
});
15+
document.addEventListener('keydown', function (event) {
16+
if (
17+
event.key === 'F12' ||
18+
(event.ctrlKey && event.shiftKey && event.key === 'I') ||
19+
(event.ctrlKey && event.shiftKey && event.key === 'C') ||
20+
(event.ctrlKey && event.shiftKey && event.key === 'J') ||
21+
(event.ctrlKey && event.key === 'U')
22+
) {
23+
event.preventDefault();
24+
}
25+
});
26+
27+
},
28+
jsonToTable(data) {
29+
30+
const table = jsonToTable(data);
31+
return table;
32+
}
33+
34+
});

app/pods/components/problem-explanation/template.hbs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
<div class="py-4">
2-
<p>
3-
{{markdown-to-html problem.details.description}}
4-
</p>
2+
<p class="no-select">{{markdown-to-html problem.details.description}}</p>
3+
54
<div class="extra-bold">Input Format</div>
6-
<p>
7-
{{markdown-to-html problem.details.input_format}}
8-
</p>
5+
6+
<pre>{{problem.details.input_format}}</pre>
7+
8+
99
<div class="extra-bold">Constraints</div>
1010
<div class="bg-grey br-5 w-60 px-4 py-2 my-2">
11-
<p>
12-
{{markdown-to-html problem.details.constraints}}
13-
</p>
11+
<p>{{markdown-to-html problem.details.constraints}}</p>
1412
</div>
13+
1514
<div class="extra-bold">Output Format</div>
16-
<p>
17-
{{markdown-to-html problem.details.output_format}}
18-
</p>
15+
<pre>{{problem.details.output_format}}</pre>
1916
<div class="extra-bold">Sample Input</div>
2017
<div class="bg-grey br-5 w-60 px-4 py-2 my-2">
21-
<pre>{{problem.details.sample_input}}</pre>
18+
<pre>{{ problem.details.sample_input}}</pre>
2219
</div>
20+
2321
<div class="extra-bold">Sample Output</div>
2422
<div class="bg-grey br-5 w-60 px-4 py-2 my-2">
23+
{{#if (includes contest.allowedLanguages "mysql")}}
24+
<pre>{{json-to-table problem.details.sample_output}}</pre>
25+
{{else}}
2526
<pre>{{problem.details.sample_output}}</pre>
27+
{{/if}}
28+
2629
</div>
30+
2731
{{#if problem.details.explanation}}
2832
<div class="extra-bold">Explanation</div>
2933
<div class="bg-grey br-5 w-60 px-4 py-2 my-2">

app/pods/components/problem-view/template.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
{{#liquid-if (eq selectedTab "problem")}}
3535
<ProblemExplanation
36-
@problem={{problem}} />
36+
@problem={{problem}}
37+
@contest="{{this.contest}}"/>
3738
{{else if (eq selectedTab "submissions")}}
3839
<SubmissionsList
3940
@contest={{contest}}

app/pods/components/project-view/template.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
{{#if (or submitProjectTask.isRunning lastResult)}}
6161
<div class="mt-4">
6262
<SubmissionResult
63+
@allowedLanguages={{contest.allowedLanguages}}
64+
6365
@contentType={{content.type}}
6466
@judgeResult={{if (not submitProjectTask.isRunning) lastResult}}
6567
/>

app/pods/components/submission-result/component.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Component from '@ember/component';
22
import { computed } from '@ember/object';
3-
3+
import { jsonToTable } from '../../../util/json-to-table';
44
export default class SubmissionResult extends Component {
55
didRender() {
66
this.element.scrollIntoView({ behavior: "smooth", block: "end" })
@@ -41,4 +41,8 @@ export default class SubmissionResult extends Component {
4141
return this.judgeResult.testcases
4242
}
4343
}
44+
jsonToTable(data) {
45+
const table = jsonToTable(data);
46+
return table;
47+
}
4448
}

app/pods/components/submission-result/submission-success/template.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
<span class="font-sm bold">
33
Compilation Successful
44
</span>
5+
56
{{#if output}}
6-
<pre class="mt-3 bg-grey p-4">{{output}}</pre>
7+
{{#if (includes allowedLanguages "mysql")}}
8+
<pre class="mt-3 bg-grey p-4">{{json-to-table output}}</pre>
9+
{{else}}
10+
<pre class="mt-3 bg-grey p-4">{{output}}</pre>
11+
{{/if}}
712
{{/if}}
813
</div>

0 commit comments

Comments
 (0)