Skip to content

Commit

Permalink
Remove document run feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rrrobo committed May 25, 2024
1 parent 499e7a6 commit 69dbdf2
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 895 deletions.
86 changes: 0 additions & 86 deletions public/javascripts/document/run/mapSelector.js

This file was deleted.

11 changes: 0 additions & 11 deletions public/javascripts/documentReview.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,24 +148,13 @@ app.controller('DocumentReviewController', ['$scope', '$uibModal', '$log', '$htt

$scope.updateUploaded();
$scope.updateReviewUploaded();

$scope.runScore = [];

$http.get("/api/competitions/" + competitionId + "/documents/" + $scope.team.league + "/review").then(function (response) {
$scope.blocks = response.data.blocks;
$scope.notifications = response.data.notifications;
$scope.languages = response.data.languages;
$scope.review = response.data.review;

for(let r of $scope.review){
for(let q of r.questions){
if(q.type != "run") continue;
$http.get(`/api/document/run/${teamId}/${q._id}`).then(function (response) {
$scope.runScore[q._id] = response.data;
});
}
}

$http.get("/api/document/answer/"+ $scope.team._id + "/" + token).then(function (response) {
$scope.answers = response.data;
for(let b of $scope.blocks){
Expand Down
12 changes: 0 additions & 12 deletions public/javascripts/documentReviewed.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ app.controller('DocumentReviewController', ['$scope', '$uibModal', '$log', '$htt
$scope.updateUploaded();
$scope.updateReviewUploaded();

$scope.runScore = [];

$http.get("/api/competitions/" + competitionId + "/documents/" + $scope.team.league + "/review").then(function (response) {
$scope.blocks = response.data.blocks;
Expand All @@ -128,17 +127,6 @@ app.controller('DocumentReviewController', ['$scope', '$uibModal', '$log', '$htt
$scope.review = response.data.review;
publicToken = response.data.publicToken;


for(let r of $scope.review){
for(let q of r.questions){
reviewQuestions[q._id] = q;
if(q.type != "run") continue;
$http.get(`/api/document/run/${teamId}/${q._id}`).then(function (response) {
$scope.runScore[q._id] = response.data;
});
}
}

$http.get("/api/document/answer/"+ $scope.team._id + "/" + token).then(function (response) {
$scope.answers = response.data;
for(let b of $scope.blocks){
Expand Down
83 changes: 0 additions & 83 deletions routes/api/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const logger = require('../../config/logger').mainLogger;
const documentDb = require('../../models/document');
const escape = require('escape-html');
const sanitize = require("sanitize-filename");
const { lineRun } = require('../../models/lineRun');
const { mazeRun } = require('../../models/mazeRun');
read = gracefulFs.gracefulify(read);

const S = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
Expand Down Expand Up @@ -1721,87 +1719,6 @@ privateRouter.get('/map/:fileName',
}
);

privateRouter.get('/run/:teamId/:questionId', function (req, res, next) {
const { teamId } = req.params;
const { questionId } = req.params;

if (!ObjectId.isValid(teamId)) {
return next();
}

competitiondb.team
.findById(teamId)
.select('competition league')
.exec(function (err, dbTeam) {
if (err || dbTeam == null) {
if (!err) err = { message: 'No team found' };
res.status(400).send({
msg: 'Could not get team',
err: err.message,
});
} else if (dbTeam) {
if (auth.authCompetition(req.user, dbTeam.competition, ACCESSLEVELS.VIEW)) {
competitiondb.competition
.findById(dbTeam.competition)
.select('documents')
.exec(function (err, dbCompetition) {
let review = dbCompetition.documents.leagues.filter(l=>l.league == dbTeam.league)[0].review;
for(let b of review){
let q = b.questions.filter(q=>q._id == questionId && q.type=="run");
if(q.length > 0){
//Runs already exists?
if(GetleagueType(dbTeam.league) == "line"){
//LineRun
lineRun.find({
competition: dbTeam.competition,
team: dbTeam._id,
round: q[0].runReview.round,
map: q[0].runReview.map
})
.select('round score')
.populate('round')
.exec(function (err, dbRun) {
if(!dbRun || dbRun.length == 0){
res.status(400).send([]);
}else{
res.status(200).send(dbRun);
}
});
}else{
//MazeRun
mazeRun.find({
competition: dbTeam.competition,
team: dbTeam._id,
round: q[0].runReview.round,
map: q[0].runReview.map
})
.select('round score')
.populate('round')
.exec(function (err, dbRun) {
if(!dbRun || dbRun.length == 0){
res.status(400).send([]);
}else{
res.status(200).send(dbRun);
}
});
}
return;
}
}
res.status(401).send({
msg: 'Operation not permited',
});

});
} else {
res.status(401).send({
msg: 'Operation not permited',
});
}
}
});
});

publicRouter.all('*', function (req, res, next) {
next();
});
Expand Down
79 changes: 0 additions & 79 deletions routes/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const fs = require('fs');
const dateformat = require('dateformat');
const competitiondb = require('../models/competition');
const { LEAGUES_JSON } = competitiondb;
const { lineRun } = require('../models/lineRun');
const { mazeRun } = require('../models/mazeRun');
const logger = require('../config/logger').mainLogger;
const { ObjectId } = require('mongoose').Types;
const auth = require('../helper/authLevels');
Expand Down Expand Up @@ -82,83 +80,6 @@ privateRouter.get('/review/:teamId', function (req, res, next) {
});
});

privateRouter.get('/review/run/:teamId/:questionId', function (req, res, next) {
const { teamId } = req.params;
const { questionId } = req.params;

if (!ObjectId.isValid(teamId)) {
return next();
}

competitiondb.team
.findById(teamId)
.select('competition document.token league')
.exec(function (err, dbTeam) {
if (err || dbTeam == null) {
if (!err) err = { message: 'No team found' };
res.status(400).send({
msg: 'Could not get team',
err: err.message,
});
} else if (dbTeam) {
if (auth.authCompetition(req.user, dbTeam.competition, ACCESSLEVELS.JUDGE)) {
competitiondb.competition
.findById(dbTeam.competition)
.select('documents rule')
.exec(function (err, dbCompetition) {
let review = dbCompetition.documents.leagues.filter(l=>l.league == dbTeam.league)[0].review;
for(let b of review){
let q = b.questions.filter(q=>q._id == questionId && q.type=="run");
if(q.length > 0){
let simpleJudge = false;
if(q[0].runReview.round.length == 1 && q[0].runReview.movie == "") simpleJudge = true;
//Runs already exists?
if(GetleagueType(dbTeam.league) == "line"){
//LineRun
lineRun.find({
competition: dbTeam.competition,
team: dbTeam._id,
round: q[0].runReview.round,
map: q[0].runReview.map
})
.exec(function (err, dbRun) {
if(!dbRun || dbRun.length == 0){
res.render('document/run/mapSelector', { user: req.user, team: dbTeam._id, competition: dbTeam.competition, league: dbTeam.league, token: dbTeam.document.token, map: q[0].runReview.map, movie: q[0].runReview.movie, round: q[0].runReview.round, questionId });
}else{
if(simpleJudge) res.redirect('/line/judge/' + dbRun[0]._id);
else res.render('document/run/line', { user: req.user, team: dbTeam._id, id: dbRun.map((obj)=>obj._id), rule: dbCompetition.rule, token: dbTeam.document.token, movie: q[0].runReview.movie});
}
});
}else{
//MazeRun
mazeRun.find({
competition: dbTeam.competition,
team: dbTeam._id,
round: q[0].runReview.round,
map: q[0].runReview.map
})
.exec(function (err, dbRun) {
if(!dbRun || dbRun.length == 0){
res.render('document/run/mapSelector', { user: req.user, team: dbTeam._id, competition: dbTeam.competition, league: dbTeam.league, token: dbTeam.document.token, map: q[0].runReview.map, movie: q[0].runReview.movie, round: q[0].runReview.round, questionId });
}else{
if(simpleJudge) res.redirect('/maze/judge/' + dbRun[0]._id);
else res.render('document/run/maze', { user: req.user, team: dbTeam._id, id: dbRun.map((obj)=>obj._id), rule: dbCompetition.rule, token: dbTeam.document.token, movie: q[0].runReview.movie});
}
});
}
return;
}
}
res.render('access_denied', { user: req.user });

});
} else {
res.render('access_denied', { user: req.user });
}
}
});
});


privateRouter.get('/reviewed/:teamId', function (req, res, next) {
const { teamId } = req.params;
Expand Down
Loading

0 comments on commit 69dbdf2

Please sign in to comment.