|
1 | 1 | /*
|
2 | 2 | * Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
|
3 | 3 | *
|
4 |
| - * @version 1.19 |
| 4 | + * @version 1.20 |
5 | 5 | * @author Sky_, mekanizumu, TCSASSEMBLER, freegod, Ghost_141, kurtrips, xjtufreeman, ecnu_haozi, hesibo, LazyChild
|
6 | 6 | * @changes from 1.0
|
7 | 7 | * merged with Member Registration API
|
|
46 | 46 | * add clientSelection flag in studio results
|
47 | 47 | * changes in 1.19:
|
48 | 48 | * add new allowed sort columns.
|
| 49 | + * changes in 1.20: |
| 50 | + * add get challenge detail api for both design and develop challenge. |
49 | 51 | */
|
50 | 52 | "use strict";
|
51 | 53 | /*jslint stupid: true, unparam: true, continue: true */
|
@@ -786,6 +788,10 @@ var getChallenge = function (api, connection, dbConnectionMap, isStudio, next) {
|
786 | 788 | submissionEndDate : formatDate(data.submission_end_date)
|
787 | 789 | };
|
788 | 790 |
|
| 791 | + if (connection.action == "getChallenge") { |
| 792 | + challenge.type = isStudio ? 'design' : 'develop'; |
| 793 | + } |
| 794 | + |
789 | 795 | if (data.project_type === COPILOT_POSTING_PROJECT_TYPE && (isCopilot || helper.isAdmin(caller))) {
|
790 | 796 | challenge.copilotDetailedRequirements = data.copilot_detailed_requirements;
|
791 | 797 | }
|
@@ -1515,6 +1521,44 @@ exports.getStudioChallenge = {
|
1515 | 1521 | }
|
1516 | 1522 | };
|
1517 | 1523 |
|
| 1524 | +/** |
| 1525 | + * The API for getting challenge details. |
| 1526 | + * |
| 1527 | + * @since 1.19 |
| 1528 | + */ |
| 1529 | +exports.getChallenge = { |
| 1530 | + name: "getChallenge", |
| 1531 | + description: "getStudioChallenge", |
| 1532 | + inputs: { |
| 1533 | + required: ["contestId"], |
| 1534 | + optional: ["refresh"] |
| 1535 | + }, |
| 1536 | + blockedConnectionTypes: [], |
| 1537 | + outputExample: {}, |
| 1538 | + version: 'v2', |
| 1539 | + transaction: 'read', // this action is read-only |
| 1540 | + databases: ["tcs_catalog", "tcs_dw"], |
| 1541 | + run: function (api, connection, next) { |
| 1542 | + if (connection.dbConnectionMap) { |
| 1543 | + api.log("Execute getChallenge#run", 'debug'); |
| 1544 | + api.dataAccess.executeQuery('check_challenge_exists', {challengeId: connection.params.contestId}, connection.dbConnectionMap, function(err, result) { |
| 1545 | + if (err) { |
| 1546 | + api.helper.handleError(api, connection, err); |
| 1547 | + next(connection, true); |
| 1548 | + } else if (result.length == 0) { |
| 1549 | + api.helper.handleError(api, connection, new NotFoundError("Challenge not found.")); |
| 1550 | + next(connection, true); |
| 1551 | + } else { |
| 1552 | + var isStudio = Boolean(result[0].is_studio); |
| 1553 | + getChallenge(api, connection, connection.dbConnectionMap, isStudio, next); |
| 1554 | + } |
| 1555 | + }); |
| 1556 | + } else { |
| 1557 | + api.helper.handleNoConnection(api, connection, next); |
| 1558 | + } |
| 1559 | + } |
| 1560 | +}; |
| 1561 | + |
1518 | 1562 | /**
|
1519 | 1563 | * The API for searching challenges
|
1520 | 1564 | */
|
|
0 commit comments