Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Module Assembly - Web Arena - Match Configurations #381

Merged
merged 3 commits into from
Oct 25, 2014
Merged
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
12 changes: 9 additions & 3 deletions actions/srmRoundManagement.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/*
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
*/
/**
* Create, modify, list and delete SRM round.
*
* @version 1.0
* @author TCSASSEMBLER
* Changes in version 1.1 (Module Assembly - Web Arena - Match Configurations):
* - Updated ListSRMContestRounds to send UTC time in milliseconds for registration and coding start time
*
* Create, modify, list and delete SRM round.
* @version 1.1
* @author TCSASSEMBLER
*/
/*jslint node: true, nomen: true */
"use strict";
Expand Down Expand Up @@ -201,11 +205,13 @@ exports.listSRMContestRounds = {
switch (segment.segment_id) {
case 1:
rr.registrationStart = helper.formatDateWithTimezone(formatDateTimeFromDB(segment.start_time));
rr.registrationStartTime = start_time;
rr.registrationLength = segment.duration;
rr.registrationStatus = segment.status;
break;
case 2:
rr.codingStart = helper.formatDateWithTimezone(formatDateTimeFromDB(segment.start_time));
rr.codingStartTime = start_time;
rr.codingLength = segment.duration;
rr.codingStatus = segment.status;
break;
Expand Down
15 changes: 9 additions & 6 deletions actions/srmRoundQuestions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/*
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
*/
/**
* - Implement the srm round questions / answers / survey api.
* Changes in version 1.1 (Module Assembly - Web Arena - Match Configurations):
* - Updated getRoundQuestions to send roundId with response
*
* @version 1.0
* @version 1.1
* @author TCSASSEMBLER
*
* - Implement the srm round questions / answers / survey api.
*/

/*jslint node: true, nomen: true, plusplus: true, stupid: true, unparam: true */
Expand Down Expand Up @@ -94,7 +97,7 @@ var getRoundQuestions = function (api, connection, dbConnectionMap, next) {
if (err) {
helper.handleError(api, connection, err);
} else {
connection.response = {questions: result};
connection.response = {questions: result, roundId: roundId};
}
next(connection, true);
});
Expand Down Expand Up @@ -544,7 +547,7 @@ var addRoundQuestion = function (api, connection, dbConnectionMap, next) {
if (err) {
helper.handleError(api, connection, err);
} else {
connection.response = {"success": true};
connection.response = {"success": true, questionId: questionId};
}
next(connection, true);
});
Expand Down Expand Up @@ -744,4 +747,4 @@ exports.modifyRoundQuestion = {
api.helper.handleNoConnection(api, connection, next);
}
}
};
};
31 changes: 18 additions & 13 deletions actions/srmRoundSegments.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/*
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
*/
/**
* Implement the srm round segments api.
*
* Changes in version 1.1 (Module Assembly - Web Arena - Match Configurations):
* - Modified date format and make it norm to include timezone so that moment.js can parse time correctly
*
* @version 1.0
* @version 1.1
* @author TCSASSEMBLER
*
* - Implement the srm round segments api.
*/

/*jslint node: true, nomen: true, plusplus: true, stupid: true, unparam: true */
Expand All @@ -14,8 +18,8 @@ var _ = require('underscore');
var moment = require('moment');
var IllegalArgumentError = require('../errors/IllegalArgumentError');

var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss";

var DATE_FORMAT = "YYYY-MM-DD HH:mm:ssZZ";
var DB_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss";
/**
* Check round id.
*
Expand Down Expand Up @@ -169,34 +173,35 @@ var setRoundSegments = function (api, connection, dbConnectionMap, next) {
cb(error);
}
}, function (results, cb) {
sqlParams.startTime = helper.formatDate(registrationStart, DATE_FORMAT);
sqlParams.endTime = moment(registrationStart, DATE_FORMAT).add('minutes', registrationLength).format(DATE_FORMAT);
sqlParams.startTime = helper.formatDate(registrationStart, DB_DATE_FORMAT);
sqlParams.endTime = moment(registrationStart, DATE_FORMAT).add('minutes', registrationLength).format(DB_DATE_FORMAT);

sqlParams.segmentId = helper.SEGMENTS_ID_MAP.REGISTRATION_PHASE;
sqlParams.status = registrationStatus;
sqlParams.roundId = roundId;
api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb);
}, function (results, cb) {
//the registration end time plus 1 minute
sqlParams.startTime = moment(sqlParams.endTime, DATE_FORMAT).add('minutes', 1).format(DATE_FORMAT);
sqlParams.endTime = helper.formatDate(codingStart, DATE_FORMAT);
sqlParams.startTime = moment(sqlParams.endTime, DB_DATE_FORMAT).add('minutes', 1).format(DB_DATE_FORMAT);
sqlParams.endTime = helper.formatDate(codingStart, DB_DATE_FORMAT);
sqlParams.segmentId = helper.SEGMENTS_ID_MAP.ROOM_ASSIGNMENT_PHASE;
sqlParams.status = registrationStatus;
api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb);
}, function (results, cb) {
sqlParams.startTime = sqlParams.endTime;
sqlParams.endTime = moment(sqlParams.startTime, DATE_FORMAT).add('minutes', codingLength).format(DATE_FORMAT);
sqlParams.endTime = moment(sqlParams.startTime, DB_DATE_FORMAT).add('minutes', codingLength).format(DB_DATE_FORMAT);
sqlParams.segmentId = helper.SEGMENTS_ID_MAP.CODING_PHASE;
sqlParams.status = codingStatus;
api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb);
}, function (results, cb) {
sqlParams.startTime = sqlParams.endTime;
sqlParams.endTime = moment(sqlParams.startTime, DATE_FORMAT).add('minutes', intermissionLength).format(DATE_FORMAT);
sqlParams.endTime = moment(sqlParams.startTime, DB_DATE_FORMAT).add('minutes', intermissionLength).format(DB_DATE_FORMAT);
sqlParams.segmentId = helper.SEGMENTS_ID_MAP.INTERMISSION_PHASE;
sqlParams.status = intermissionStatus;
api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb);
}, function (results, cb) {
sqlParams.startTime = sqlParams.endTime;
sqlParams.endTime = moment(sqlParams.startTime, DATE_FORMAT).add('minutes', challengeLength).format(DATE_FORMAT);
sqlParams.endTime = moment(sqlParams.startTime, DB_DATE_FORMAT).add('minutes', challengeLength).format(DB_DATE_FORMAT);
sqlParams.segmentId = helper.SEGMENTS_ID_MAP.CHALLENGE_PHASE;
sqlParams.status = challengeStatus;
api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb);
Expand Down Expand Up @@ -241,4 +246,4 @@ exports.setRoundSegments = {
api.helper.handleNoConnection(api, connection, next);
}
}
};
};
5 changes: 2 additions & 3 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,15 @@ exports.routes = {
{ path: "/:apiVersion/data/srm/rounds/:roundId/segments", action: "setRoundSegments"},
{ path: "/:apiVersion/data/srm/rounds/:roundId/survey", action: "setRoundSurvey"},
{ path: "/:apiVersion/data/srm/questions/:questionId/answers", action: "addRoundQuestionAnswer"},

{ path: "/:apiVersion/data/srm/rounds/:questionId/question", action: "modifyRoundQuestion"},
{ path: "/:apiVersion/data/srm/rounds/:roundId/components", action: "setRoundComponents"},
{ path: "/:apiVersion/data/srm/rounds/:roundId/terms", action: "setRoundTerms"},
{ path: "/:apiVersion/data/srm/rounds", action: "createSRMContestRound" }
],
put: [

{ path: "/:apiVersion/data/srm/contests/:id", action: "updateSRMContest"},
{ path: "/:apiVersion/data/srm/rounds/:oldRoundId", action: "modifySRMContestRound" },
{ path: "/:apiVersion/data/srm/rounds/:questionId/question", action: "modifyRoundQuestion"}
{ path: "/:apiVersion/data/srm/rounds/:oldRoundId", action: "modifySRMContestRound" }
],
delete: [
{ path: "/:apiVersion/data/srm/rounds/:roundId", action: "deleteSRMContestRound" }
Expand Down