Skip to content

Commit 04faef6

Browse files
Merge pull request #55 from Killerrekt/master
2 parents c60cbb2 + 8f9a0c3 commit 04faef6

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

api/controllers/questions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async function getByRound(req, res) {
8686
async function deleteQuestion(req, res) {
8787
try {
8888
const deletedItem = await ques.findByIdAndDelete(req.params.id);
89-
console.log(req.body.id);
89+
//console.log(req.body.id);
9090

9191
const testCases = await TestCaseModel.find()
9292
.where(`_id: ${req.params.id}`)

api/controllers/submission.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ class submission {
148148
expected_output: Buffer.from(current.expectedOutput, "binary").toString(
149149
"base64",
150150
),
151-
cpu_time_limit: current.time * multipler < 15
152-
? current.time * multipler
153-
: 15,
151+
cpu_time_limit:
152+
current.time * multipler < 15 ? current.time * multipler : 15,
153+
memory:
154+
current.memory * multipler<2048 ? 2048 : current.memory*multipler
154155
//redirect_stderr_to_stdout: true,
155156
});
156157
const group = current.group;
@@ -198,7 +199,7 @@ class submission {
198199
"/submissions/batch?tokens=" +
199200
str.toString() +
200201
"&base64_encoded=true&fields=status_id,stderr,compile_output,expected_output,stdout,time";
201-
console.log(url);
202+
//console.log(url);
202203
let completion = false;
203204
let data_sent_back = {
204205
error: [false, false, false, false], //false means it passed that grp
@@ -308,10 +309,9 @@ class submission {
308309
});
309310

310311
//comparing the score with the existing score and picking the best one
311-
data_sent_back.Score = !check || score >= check.score
312-
? score
313-
: check.score;
314-
console.log(data_sent_back.Score, score);
312+
data_sent_back.Score =
313+
!check || score >= check.score ? score : check.score;
314+
//console.log(data_sent_back.Score, score);
315315

316316
//If new score is higher or equal to the existing score, then sub DB is updated
317317
if (data_sent_back.Score == score) {
@@ -326,6 +326,7 @@ class submission {
326326
await this.create_score(reg_no);
327327
} else {
328328
data_sent_back.Sub_db = "No changes in Sub DB";
329+
await this.create_score(reg_no);
329330
}
330331

331332
//Creation of allPassesAt field when all testcases are passed
@@ -366,8 +367,7 @@ class submission {
366367
]);
367368
const score = ele[0].total;
368369
return User.updateOne({ regNo: user }, { score: score })
369-
.then(() => console.log("Score = " + score))
370-
.catch(() => console.error("Error occured while saving scores"));
370+
.catch(() => console.error("Error occured while saving scores \nRegno :"+regNo+"\tScore :"+score));
371371
}
372372

373373
async get_reg_no(req, res) {
@@ -394,12 +394,12 @@ class submission {
394394

395395
async get_all(req, res) {
396396
const { regno } = req.params;
397-
console.log(regno);
397+
//console.log(regno);
398398
const record = await submission_db.find(
399399
{ regNo: regno },
400400
"code score question_id lastResults language_id",
401401
);
402-
console.log(record);
402+
//console.log(record);
403403
if (record.length == 0) {
404404
res.status(400).json({
405405
Error: "Invalid regNo",
@@ -485,12 +485,12 @@ class submission {
485485
let items = Object.keys(leaderboard).map(function (key) {
486486
return [key, leaderboard[key]];
487487
});
488-
items.sort(function (a, b) {
489-
console.log(a[1][0]);
490-
if (a[1][0] > b[1][0]) return -1;
491-
if (a[1][0] < b[1][0]) return 1;
492-
if (a[1][1] > b[1][1]) return 1;
493-
if (a[1][1] < b[1][1]) return -1;
488+
items.sort(function(a,b){
489+
//console.log(a[1][0]);
490+
if(a[1][0]>b[1][0]) return -1;
491+
if(a[1][0]<b[1][0]) return 1;
492+
if(a[1][1]>b[1][1]) return 1;
493+
if(a[1][1]<b[1][1]) return -1;
494494
});
495495
res.status(200).json(items);
496496
}

api/controllers/testCasesController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const updateTestCase = async (req, res) => {
7777
}
7878

7979
const updated = await QuestionModel.findById(question);
80-
console.log(updated);
80+
//console.log(updated);
8181
updated.testCases.push(testCase._id);
8282
await updated.save();
8383

api/middleware/jwtMiddleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async function verifyQuestion(req, res, next) {
7979
try {
8080
const user = await User.findOne({ regNo: req.user.regNo });
8181
const ques = await Ques.findOne({ _id: question_id });
82-
console.log(ques);
82+
//console.log(ques);
8383
if (!ques) {
8484
return res.status(400).json({ message: "Question not found" });
8585
}

0 commit comments

Comments
 (0)