sungjin

Fix cpp, add level when making post.

This diff is collapsed. Click to expand it.
......@@ -18,12 +18,21 @@ export class PostService {
example: string,
testinput: string[],
testoutput: string[],
difficulty: number,
) {
const user = await this.auth.validateUser(
(
await this.auth.getUserFromToken(token)
).id,
);
let level: Level;
if (difficulty == 1) {
level = 'LOW';
} else if (difficulty == 2) {
level = 'MEDIUM';
} else {
level = 'HIGH';
}
const post = await this.prisma.post.create({
data: {
author: {
......@@ -37,6 +46,7 @@ export class PostService {
example: example,
testinput: testinput,
testoutput: testoutput,
level: level,
},
});
return post;
......
......@@ -85,7 +85,7 @@ export class RunnerService {
cpp(body: any, location: string) {
const output: Array<string> = [];
if (body.input == []) {
const test = child_process.spawnSync('gcc', [location, '-o', 'tmp'], {
const test = child_process.spawnSync('g++', [location, '-o', 'tmp'], {
encoding: 'utf8',
shell: true,
});
......@@ -101,7 +101,7 @@ export class RunnerService {
output.push(result.stdout as string);
}
for (const ip of body.input) {
const test = child_process.spawnSync('gcc', [location, '-o', 'tmp'], {
const test = child_process.spawnSync('g++', [location, '-o', 'tmp'], {
encoding: 'utf8',
shell: true,
});
......@@ -176,7 +176,7 @@ export class RunnerService {
output.push(result.stdout as string);
}
for (const ip of body.input) {
const result = child_process.spawnSync('go', ['run', location], {
const result = child_process.spawnSync('ts-node', ['run', location], {
encoding: 'utf8',
shell: true,
input: ip,
......