Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Client/views/home.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@
<a href="/" class="nav-button active">Home</a>
<% if(imgUsername){%>
<a href="/contest" class="nav-button">BuildIT Lab</a>
<a href="/profile" class="nav-button">Profile</a>
<a href="/logout" class="nav-button">Logout</a>
<span class="username"><%=imgUsername%></span>
<img src="<%=imgUrl%>" alt="" />
Expand Down
1 change: 0 additions & 1 deletion Client/views/partials/header2.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<button class="nav-btn"><a href="/">Home</a></button>
<% if(imgUsername){ %>
<button class="nav-btn"><a href="/contest">BuildIT Lab</a></button>
<button class="nav-btn"><a href="/profile">Profile</a></button>
<button class="nav-btn"><a href="/logout">Logout</a></button>
<button class="nav-btn" style="color: white; font-weight: bold; font-family: poppins;" id="username"><%= imgUsername %></button>
<span style="margin-right: 20px;"><img src="<%=imgUrl%>" alt="img" style="width: 80px; height: 80px; border-radius: 1mm;"></span>
Expand Down
9 changes: 8 additions & 1 deletion Client/views/sets2.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@
name="questionIdsString"
required
/>

<input
class="form-control"
type="text"
placeholder="Enter Contest Id"
id="contestId"
name="contestId"
required
/>
<textarea
type="hidden"
name="token"
Expand Down
26 changes: 2 additions & 24 deletions Server/controllers/participation.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,6 @@ exports.acceptSubmission = (sub, callback) => {
},
},
{ new: true },
(err, doc) => {
if (err) {
console.log("Something wrong when updating data!");
}
// console.log(doc);
}
)
.then((participation) => {
if (!participation) {
Expand Down Expand Up @@ -325,11 +319,6 @@ exports.acceptSubmission = (sub, callback) => {
},
},
{ new: true },
(err, doc) => {
if (err) {
console.log("Something wrong when updating data!");
}
}
)
.then((participation) => {
if (!participation) {
Expand Down Expand Up @@ -393,12 +382,6 @@ exports.acceptSubmission = (sub, callback) => {
},
},
{ new: true },
(err, doc) => {
if (err) {
console.log("Something wrong when updating data!");
}
// console.log(doc);
}
)
.then((participation) => {
if (!participation) {
Expand Down Expand Up @@ -441,11 +424,6 @@ exports.acceptSubmission = (sub, callback) => {
},
},
{ new: true },
(err, doc) => {
if (err) {
console.log("Something wrong when updating data!");
}
}
)
.then((participation) => {
if (!participation) {
Expand Down Expand Up @@ -646,12 +624,12 @@ exports.saveResult = (req, res) => {
if (participation[0].mcqResults.compute) {
mcqs.findAllMcqContest(req.params.contestId, (err, mcq) => {
if (err) {
res.send({ success: false, message: "Error occured" });
res.send({ success: false, message: "Error occurred" });
}
let responses = participation[0].responses.map((e) => e.responses); // array of 4 arrays
mcq = mcq.map((v) => v.books); // array of 4 arrays each having mcqs array from 1 section
if (mcq.length !== responses.length) {
return res.send({ success: false, message: "Error occured" });
return res.send({ success: false, message: "Error occurred" });
}

let sectionCount = mcq.length;
Expand Down
27 changes: 21 additions & 6 deletions Server/controllers/question.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ exports.createSet = (req, res) => {

exports.addSetGivenQIdArray = (req, res) => {
let questionIdString = req.body.questionIdsString;

let pattern = /[^A-Z&a-z&0-9]/;
let questionIds = questionIdString
.split(",")
Expand All @@ -254,9 +253,25 @@ exports.addSetGivenQIdArray = (req, res) => {
message: "Question id does not exists!",
});
}

let set = question.map((e) => e.questionId);
updateSet(set);
Question.updateMany(
{ questionId: { $in: questionIds } },
{
$set:{
contestId : req.body.contestId
}
}
)
.then((questions) => {
let set = question.map((e) => e.questionId);
updateSet(set);
})
.catch((err) => {
res.status(500).send({
success: false,
message:
err.message || "Some error occurred while retrieving questions.",
});
})
})
.catch((err) => {
res.status(500).send({
Expand All @@ -269,15 +284,15 @@ exports.addSetGivenQIdArray = (req, res) => {
const updateSet = (set) => {
contests.findOneSet(req, (err, contest) => {
if (err) {
res.send({ success: false, message: "Error occured" });
res.send({ success: false, message: "Error occurred" });
}
let sets = contest.sets || [];
if (contest.sets) {
sets.push(set);
}
contests.updateOneSet(req, sets, (err, contest1) => {
if (err) {
res.send({ success: false, message: "Error occured" });
res.send({ success: false, message: "Error occurred" });
}
res.send("Done! Added to Set");
});
Expand Down