├── .bowerrc ├── .editorconfig ├── .ember-cli ├── .gitignore ├── .jshintrc ├── .nvmrc ├── .travis.yml ├── .watchmanconfig ├── README.md ├── app ├── adapters │ └── contest-attempt.js ├── app.js ├── authenticators │ └── custom.js ├── authorizers │ └── custom.js ├── controllers │ └── .gitkeep ├── helpers │ ├── ago-time.js │ ├── avatarIndex.js │ ├── base64-decode.js │ ├── decimal-to-whole.js │ ├── eq-prim.js │ ├── first-name.js │ ├── get-day-name.js │ ├── get-difficulty.js │ ├── get-element-at.js │ ├── get-rand.js │ ├── getlang.js │ ├── in.js │ ├── is-tag-selected.js │ ├── lang.js │ ├── multiply.js │ ├── sum.js │ └── unix-to-time.js ├── index.html ├── instance-initializers │ └── embed.js ├── models │ ├── attachment.js │ ├── batch-code.js │ ├── buser.js │ ├── choice.js │ ├── college.js │ ├── competition-attempt.js │ ├── competition.js │ ├── competition_leaderboard.js │ ├── contest.js │ ├── contest_leaderboard.js │ ├── dailycb.js │ ├── editorial.js │ ├── level.js │ ├── notification.js │ ├── organization.js │ ├── practice_category.js │ ├── problem-attempt.js │ ├── problem.js │ ├── problem_leaderboard.js │ ├── question.js │ ├── quiz-attempt.js │ ├── quiz-submission.js │ ├── quiz.js │ ├── submission.js │ ├── tag.js │ ├── track.js │ ├── unlocked-editorial.js │ ├── unlocked-level.js │ ├── unlocked-testcase.js │ └── user.js ├── pods │ ├── application-error │ │ ├── route.js │ │ └── template.hbs │ ├── application │ │ ├── adapter.js │ │ ├── controller.js │ │ ├── route.js │ │ └── template.hbs │ ├── competitions │ │ ├── index │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── overview │ │ │ ├── controller.js │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── route.js │ │ ├── template.hbs │ │ └── view │ │ │ ├── controller.js │ │ │ ├── route.js │ │ │ └── template.hbs │ ├── components │ │ ├── ace-editor │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── bread-crumb │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── c-review-pad │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── circular-loader │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── clock-view │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── code-editor │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── college-leaderboard │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── competition-card │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── contest-banner-view │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── contest-view │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── countdown-timer │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── current-cb-card │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── editorial-view │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── home-statistics │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── left-side-bar │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── live-reload │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── login-dialog │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── nagarro-cnc │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── nav-bar │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── notification-button │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── problem-leaderboard │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── problem-my-submissions │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── problem-parent │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── problem-view │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── question-container │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── quiz-result │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── review-circle │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── right-side-bar │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── share-buttons │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── submission-explanation │ │ │ ├── component.js │ │ │ └── template.hbs │ │ ├── tab-nav │ │ │ ├── component.js │ │ │ └── template.hbs │ │ └── tutorials-container │ │ │ ├── component.js │ │ │ └── template.hbs │ ├── contest-attempt │ │ └── model.js │ ├── contests │ │ ├── contest │ │ │ ├── attachment │ │ │ │ ├── index │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── attempt │ │ │ │ ├── controller.js │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── contest-result │ │ │ │ ├── controller.js │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── ended │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── index │ │ │ │ ├── controller.js │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── leaderboard │ │ │ │ ├── controller.js │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── problem │ │ │ │ ├── controller.js │ │ │ │ ├── editorial │ │ │ │ │ ├── controller.js │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ │ ├── index │ │ │ │ │ ├── controller.js │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ │ ├── route.js │ │ │ │ ├── submissions │ │ │ │ │ ├── controller.js │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ │ ├── template.hbs │ │ │ │ └── testcases │ │ │ │ │ ├── controller.js │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ ├── quiz-attempts │ │ │ │ ├── index │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ │ ├── route.js │ │ │ │ ├── show │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ │ └── template.hbs │ │ │ ├── quiz │ │ │ │ ├── attempts │ │ │ │ │ ├── index │ │ │ │ │ │ ├── route.js │ │ │ │ │ │ └── template.hbs │ │ │ │ │ ├── route.js │ │ │ │ │ ├── show │ │ │ │ │ │ ├── route.js │ │ │ │ │ │ └── template.hbs │ │ │ │ │ └── template.hbs │ │ │ │ ├── index │ │ │ │ │ ├── controller.js │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── denied │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── index │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── route.js │ │ ├── template.hbs │ │ └── upcoming │ │ │ ├── route.js │ │ │ └── template.hbs │ ├── courses │ │ ├── route.js │ │ └── template.hbs │ ├── dcb │ │ ├── index │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── route.js │ │ ├── template.hbs │ │ └── weekly-problem │ │ │ ├── index │ │ │ ├── controller.js │ │ │ ├── route.js │ │ │ └── template.hbs │ │ │ ├── route.js │ │ │ └── template.hbs │ ├── help │ │ ├── route.js │ │ └── template.hbs │ ├── index │ │ ├── route.js │ │ └── template.hbs │ ├── info │ │ ├── route.js │ │ └── template.hbs │ ├── loading │ │ ├── route.js │ │ └── template.hbs │ ├── logout │ │ ├── route.js │ │ └── template.hbs │ ├── practice │ │ ├── index │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── problems │ │ │ ├── index │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── problem │ │ │ │ ├── index │ │ │ │ │ ├── controller.js │ │ │ │ │ ├── route.js │ │ │ │ │ └── template.hbs │ │ │ │ ├── route.js │ │ │ │ └── template.hbs │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── route.js │ │ └── template.hbs │ ├── solution-stub │ │ └── model.js │ ├── submission │ │ ├── route.js │ │ └── template.hbs │ ├── tracks │ │ ├── controller.js │ │ ├── index │ │ │ ├── route.js │ │ │ └── template.hbs │ │ ├── route.js │ │ ├── show │ │ │ ├── controller.js │ │ │ ├── route.js │ │ │ └── template.hbs │ │ └── template.hbs │ └── users │ │ ├── index │ │ ├── route.js │ │ └── template.hbs │ │ ├── route.js │ │ ├── template.hbs │ │ └── user │ │ ├── controller.js │ │ ├── route.js │ │ └── template.hbs ├── resolver.js ├── router.js ├── services │ ├── api.js │ ├── chat.js │ ├── current-attempt.js │ ├── current-contest.js │ ├── current-user.js │ ├── pn.js │ └── server-time.js ├── session-stores │ └── application.js ├── styles │ ├── app.css │ └── app.scss ├── templates │ └── components │ │ └── .gitkeep └── utils │ ├── get-course-description.js │ ├── get-error-details.js │ ├── get-snippet.js │ └── http-validator.js ├── bower.json ├── config └── environment.js ├── deployToProduction.sh ├── deployToStaging.sh ├── ember-cli-build.js ├── jsconfig.json ├── key.pem.enc ├── mirage ├── config.js ├── scenarios │ └── default.js └── serializers │ └── application.js ├── package.json ├── public ├── crossdomain.xml ├── favicon.ico ├── fonts │ └── Material-Design-Iconic-Font.woff2 ├── images │ ├── about.svg │ ├── badge.png │ ├── clockface.png │ ├── compe.svg │ ├── competitive.png │ ├── correct-icon.png │ ├── course-3.jpg │ ├── desc.svg │ ├── disable-icon.png │ ├── docs.svg │ ├── error-icon.png │ ├── generic-1.jpg │ ├── hourhand.png │ ├── logo.png │ ├── logo.svg │ ├── logo_1.svg │ ├── logo_2.svg │ ├── logo_3.svg │ ├── logo_4.svg │ ├── logo_5.svg │ ├── minhand.png │ ├── ngnc.jpg │ ├── partially-correct.jpg │ ├── placeholder-avatar.png │ ├── prize.svg │ ├── profile-bg.jpg │ ├── question.svg │ ├── sechand.png │ ├── student │ │ ├── random-avatar1.jpg │ │ ├── random-avatar2.jpg │ │ ├── random-avatar3.jpg │ │ ├── random-avatar4.jpg │ │ ├── random-avatar5.jpg │ │ └── random-avatar6.jpg │ ├── tag.png │ └── wrong-icon.png ├── media │ └── notification-tone.mp3 └── robots.txt ├── start-development-server.sh ├── testem.js ├── tests ├── .jshintrc ├── helpers │ ├── destroy-app.js │ ├── module-for-acceptance.js │ ├── resolver.js │ └── start-app.js ├── index.html ├── integration │ ├── .gitkeep │ └── pods │ │ └── components │ │ ├── college-leaderboard │ │ └── component-test.js │ │ ├── question-container │ │ └── component-test.js │ │ ├── quiz-result │ │ └── component-test.js │ │ ├── submission-explanation │ │ └── component-test.js │ │ └── tutorials-container │ │ └── component-test.js ├── test-helper.js └── unit │ ├── .gitkeep │ ├── adapters │ └── contest-attempt-test.js │ ├── helpers │ ├── ago-time-test.js │ ├── first-name-test.js │ └── get-element-at-test.js │ ├── instance-initializers │ └── embed-test.js │ └── pods │ └── current-contest │ └── service-test.js ├── typings └── ember │ └── ember.d.ts ├── vendor ├── .gitkeep ├── css │ ├── all-themes.css │ ├── bootstrap.min.css │ ├── login-popup.css │ ├── main.css │ └── morris.css └── js │ ├── bootstrap.min.js │ ├── jquery.min.js │ ├── libscripts.bundle.js │ ├── mainscripts.bundle.js │ └── vendorscripts.bundle.js └── yarn.lock /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.hbs] 17 | insert_final_newline = false 18 | 19 | [*.{diff,md}] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": true, 9 | "usePods": true, 10 | "liveReload": true, 11 | "watcher": "polling" 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log* 17 | testem.log 18 | .idea/* 19 | package-lock.json 20 | .DS_Store 21 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "-Promise", 6 | "$", 7 | "jQuery", 8 | "ace" 9 | ], 10 | "browser": true, 11 | "boss": true, 12 | "curly": true, 13 | "debug": false, 14 | "devel": true, 15 | "eqeqeq": true, 16 | "evil": true, 17 | "forin": false, 18 | "immed": false, 19 | "laxbreak": false, 20 | "newcap": true, 21 | "noarg": true, 22 | "noempty": false, 23 | "nonew": false, 24 | "nomen": false, 25 | "onevar": false, 26 | "plusplus": false, 27 | "regexp": false, 28 | "undef": true, 29 | "sub": true, 30 | "strict": false, 31 | "white": false, 32 | "eqnull": true, 33 | "esversion": 6, 34 | "unused": true, 35 | "asi": true 36 | } 37 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 8.14.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | - "7" 5 | 6 | branches: 7 | only: 8 | - master 9 | - unstable 10 | cache: 11 | yarn: true 12 | directories: 13 | - ~/.npm 14 | - ~/.bower 15 | 16 | install: 17 | - yarn install 18 | - npm install -g bower 19 | - bower install 20 | 21 | before_script: 22 | - openssl aes-256-cbc -d -in key.pem.enc -out key.pem -k $ENC_KEY 23 | 24 | script: 25 | - if [ "$TRAVIS_BRANCH" = "master" ]; then bash ./deployToProduction.sh; fi 26 | - if [ "$TRAVIS_BRANCH" = "unstable" ]; then bash ./deployToStaging.sh; fi 27 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hacker Blocks 2 | 3 | **NOTE** 4 | This is the source code of the old hackerblocks platform. Newer application is the complete re-write of this one from scratch. It can be found here: https://github.com/coding-blocks/hackerblocks.projectx. 5 | 6 | 7 | Online coding platform by Coding Blocks. 8 | 9 | ## Prerequisites 10 | 11 | You will need the following things properly installed on your computer. 12 | 13 | * [Git](https://git-scm.com/) 14 | * [Node.js](https://nodejs.org/) (with NPM) 15 | * [Bower](https://bower.io/) 16 | * [Ember CLI](https://ember-cli.com/) 17 | 18 | ## Installation 19 | 20 | * `git clone ` this repository 21 | * `cd hack` 22 | * `npm install` 23 | * `bower install` 24 | 25 | ## Running / Development 26 | 27 | * `export oss=true && ember serve` 28 | * Visit your app at [http://localhost:4200](http://localhost:4200). 29 | 30 | ### Running Tests 31 | 32 | * `ember test` 33 | * `ember test --server` 34 | 35 | ### Building 36 | 37 | * `ember build` (development) 38 | * `ember build --environment production` (production) 39 | 40 | ## Useful Links 41 | 42 | * [ember.js](http://emberjs.com/) 43 | * [ember-cli](https://ember-cli.com/) 44 | -------------------------------------------------------------------------------- /app/adapters/contest-attempt.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | import ApplicationAdapter from 'hack/pods/application/adapter' 3 | 4 | export default ApplicationAdapter.extend({ 5 | urlForUpdateRecord(id, modelName, snapshot) { 6 | return this._super(...arguments) + '/submit' 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /app/app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | let App; 7 | 8 | Ember.MODEL_FACTORY_INJECTIONS = true; 9 | 10 | App = Ember.Application.extend({ 11 | modulePrefix: config.modulePrefix, 12 | podModulePrefix: config.podModulePrefix, 13 | Resolver 14 | }); 15 | 16 | Raven.config(config.RavenDsn).install(); 17 | loadInitializers(App, config.modulePrefix); 18 | 19 | export default App; 20 | -------------------------------------------------------------------------------- /app/authorizers/custom.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 2/21/17. 3 | */ 4 | 5 | import Base from 'ember-simple-auth/authorizers/base'; 6 | 7 | export default Base.extend({ 8 | authorize(sessionData, block) { 9 | block("oauth-id", sessionData.oauth_id); //This won't be required most probably. Need to remove it. 10 | block("Authorization", `JWT ${sessionData.jwt}`); 11 | block("user-id", sessionData.user_id); 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/app/controllers/.gitkeep -------------------------------------------------------------------------------- /app/helpers/ago-time.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export function agoTime(unixtime) { 4 | var current = new Date(); 5 | var previous = new Date(unixtime * 1000); 6 | var msPerMinute = 60 * 1000; 7 | var msPerHour = msPerMinute * 60; 8 | var msPerDay = msPerHour * 24; 9 | var msPerMonth = msPerDay * 30; 10 | var msPerYear = msPerDay * 365; 11 | 12 | var elapsed = current - previous; 13 | 14 | if (elapsed < msPerMinute) { 15 | return Math.round(elapsed/1000) + ' seconds ago'; 16 | } 17 | 18 | else if (elapsed < msPerHour) { 19 | return Math.round(elapsed/msPerMinute) + ' minutes ago'; 20 | } 21 | 22 | else if (elapsed < msPerDay ) { 23 | return Math.round(elapsed/msPerHour ) + ' hours ago'; 24 | } 25 | 26 | else if (elapsed < msPerMonth) { 27 | return Math.round(elapsed/msPerDay) + ' days ago'; 28 | } 29 | 30 | else if (elapsed < msPerYear) { 31 | return Math.round(elapsed/msPerMonth) + ' months ago'; 32 | } 33 | 34 | else { 35 | return Math.round(elapsed/msPerYear ) + ' years ago'; 36 | } 37 | } 38 | 39 | export default Ember.Helper.helper(agoTime); 40 | -------------------------------------------------------------------------------- /app/helpers/avatarIndex.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by himank on 1/3/18. 3 | */ 4 | 5 | export function getAvatarIndex(num) { 6 | return num % 36 + 1; 7 | } 8 | 9 | export default Ember.Helper.helper(getAvatarIndex); 10 | -------------------------------------------------------------------------------- /app/helpers/base64-decode.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by omerjerk on 18/2/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export function bas64decode(encodedData) { 8 | return atob(encodedData); 9 | } 10 | 11 | export default Ember.Helper.helper(bas64decode); 12 | -------------------------------------------------------------------------------- /app/helpers/decimal-to-whole.js: -------------------------------------------------------------------------------- 1 | 2 | import Ember from 'ember'; 3 | 4 | export function decimalToWhole(params) { 5 | return Math.round(parseFloat(params)); 6 | } 7 | 8 | export default Ember.Helper.helper(decimalToWhole); 9 | -------------------------------------------------------------------------------- /app/helpers/eq-prim.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 6/17/17. 3 | */ 4 | 5 | 6 | import Ember from 'ember'; 7 | 8 | export function eq(params) { 9 | return params.reduce((a, b) => { 10 | return a == b; 11 | }); 12 | } 13 | 14 | export default Ember.Helper.helper(eq); 15 | 16 | -------------------------------------------------------------------------------- /app/helpers/first-name.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export function firstName([fullName]) { 4 | if (fullName === undefined) { 5 | return "" 6 | } 7 | 8 | const firstName = fullName.w () [0] 9 | 10 | return firstName.capitalize () 11 | } 12 | 13 | export default Ember.Helper.helper(firstName); 14 | -------------------------------------------------------------------------------- /app/helpers/get-day-name.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 01/02/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export function getDayName(params) { 8 | let weekday = new Array(7); 9 | weekday[0] = "Sunday"; 10 | weekday[1] = "Monday"; 11 | weekday[2] = "Tuesday"; 12 | weekday[3] = "Wednesday"; 13 | weekday[4] = "Thursday"; 14 | weekday[5] = "Friday"; 15 | weekday[6] = "Saturday"; 16 | return params.reduce((index, today) => { 17 | return weekday[(index + today) % 7]; 18 | }); 19 | } 20 | 21 | export default Ember.Helper.helper(getDayName); 22 | -------------------------------------------------------------------------------- /app/helpers/get-difficulty.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 27/01/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export function getDifficulty(param) { 8 | let diff_codes = { 9 | 0: "Easy", 10 | 1: "Medium", 11 | 2: "Hard", 12 | 3: "Very Hard" 13 | }; 14 | return diff_codes[param]; 15 | } 16 | 17 | export default Ember.Helper.helper(getDifficulty); 18 | -------------------------------------------------------------------------------- /app/helpers/get-element-at.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export function getElementAt(params/*, hash*/) { 4 | const [ array, index] = params 5 | console.log ("==============darsh============", params) 6 | return array[index] 7 | } 8 | 9 | export default Ember.Helper.helper(getElementAt); 10 | -------------------------------------------------------------------------------- /app/helpers/get-rand.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 4/13/17. 3 | */ 4 | 5 | export function getRandom(num) { 6 | return Math.floor((Math.random() * num) + 1); 7 | } 8 | 9 | export default Ember.Helper.helper(getRandom); 10 | -------------------------------------------------------------------------------- /app/helpers/getlang.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 09/01/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export function getlang(param) { 8 | let lang_codes = { 9 | "c": "C", 10 | "cpp": "C++", 11 | "py2": "Python", 12 | "py3": "Python3", 13 | "java": "Java", 14 | "js": "NodeJS" 15 | }; 16 | return lang_codes[param]; 17 | } 18 | 19 | export default Ember.Helper.helper(getlang); 20 | -------------------------------------------------------------------------------- /app/helpers/in.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export function present(list) { 4 | return list[1].includes(list[0]); 5 | } 6 | 7 | export default Ember.Helper.helper(present); 8 | 9 | -------------------------------------------------------------------------------- /app/helpers/is-tag-selected.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | 4 | export function isTagSelected(params) { 5 | return params.reduce((problem, selectedTag) => { 6 | let submission = problem.get('top'); 7 | if(selectedTag === "All") { 8 | return true; 9 | } else if(selectedTag === "Solved" && submission.get('result') === 1) { 10 | // console.log("Solved"); 11 | return true; 12 | } else if (selectedTag === "Unsolved" && submission.get('result') !== 1){ 13 | // console.log("Unsolved"); 14 | return true; 15 | } else if(selectedTag === "Wrong" && (submission.get('score') === 0 || submission.get('result') === -1)) { 16 | // console.log("Wrong"); 17 | return true; 18 | } else if(selectedTag === "Psolved" && submission.get('score') >0 && submission.get('result') === 0) { 19 | // console.log("Psolved"); 20 | return true; 21 | } else { 22 | let tags = problem.get('tags'); 23 | if (tags == null) { 24 | return false; 25 | } 26 | return tags.indexOf(selectedTag) !== -1; 27 | } 28 | }); 29 | } 30 | 31 | export default Ember.Helper.helper(isTagSelected); 32 | -------------------------------------------------------------------------------- /app/helpers/lang.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 09/01/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export function lang(param) { 8 | let lang_codes = { 9 | "c": "C", 10 | "cpp": "C++", 11 | "py2": "Python", 12 | "py3": "Python3", 13 | "java": "Java" 14 | }; 15 | return lang_codes; 16 | } 17 | 18 | export default Ember.Helper.helper(lang); 19 | -------------------------------------------------------------------------------- /app/helpers/multiply.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 2/25/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export function multiply(params) { 8 | return params.reduce((a, b) => { 9 | return a * b; 10 | }); 11 | } 12 | 13 | export default Ember.Helper.helper(multiply); 14 | 15 | -------------------------------------------------------------------------------- /app/helpers/sum.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 05/01/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export function sum(params) { 8 | return params.reduce((a, b) => { 9 | return a + b; 10 | }); 11 | } 12 | 13 | export default Ember.Helper.helper(sum); 14 | -------------------------------------------------------------------------------- /app/helpers/unix-to-time.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 07/02/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export function unixToTime(unix_time) { 8 | let monthNames = ["January", "February", "March", "April", "May", "June", 9 | "July", "August", "September", "October", "November", "December" 10 | ]; 11 | let date = new Date(unix_time*1000); 12 | var month = monthNames[date.getMonth()]; 13 | var day = date.getDate(); 14 | var hour = date.getHours(); 15 | var minutes = ("0"+date.getMinutes()).substr(-2); 16 | 17 | return day+" "+month; 18 | } 19 | 20 | export default Ember.Helper.helper(unixToTime); 21 | -------------------------------------------------------------------------------- /app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Hacker Blocks 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | 19 | 20 | 29 | {{content-for "body"}} 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {{content-for "body-footer"}} 43 | 44 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /app/instance-initializers/embed.js: -------------------------------------------------------------------------------- 1 | export function initialize( appInstance ) { 2 | var insideFrame = true 3 | 4 | try { 5 | insideFrame = window.self !== window.top 6 | } finally { 7 | appInstance.register("flag:embeded", insideFrame, { 8 | instantiate: false, 9 | singleton: true 10 | }) 11 | appInstance.inject('route', 'embeded', "flag:embeded") 12 | appInstance.inject('controller', 'embeded', "flag:embeded"); 13 | //window.embedded = this.get('embeded'); 14 | window.embed = insideFrame; 15 | } 16 | } 17 | 18 | export default { 19 | name: 'embed', 20 | initialize 21 | }; 22 | -------------------------------------------------------------------------------- /app/models/attachment.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | title : DS.attr (), 5 | description : DS.attr (), 6 | url : DS.attr (), 7 | mime : DS.attr (), 8 | contentType : DS.attr (), 9 | createdAt : DS.attr (), 10 | updatedAt : DS.attr (), 11 | createdBy : DS.attr (), 12 | publishedBy : DS.attr () 13 | }); 14 | -------------------------------------------------------------------------------- /app/models/batch-code.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | batchCode: DS.attr() 5 | }); 6 | -------------------------------------------------------------------------------- /app/models/buser.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | "batch-code": DS.belongsTo('batch-code'), 5 | batchCodeText: DS.attr(), 6 | userId: DS.attr(), 7 | createdBy: DS.attr(), 8 | batchCodeId: DS.attr(), 9 | }); 10 | -------------------------------------------------------------------------------- /app/models/choice.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | title: DS.attr(), 5 | description: DS.attr() 6 | }) -------------------------------------------------------------------------------- /app/models/college.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | name: DS.attr (), 5 | oneauthId: DS.attr () 6 | }); 7 | -------------------------------------------------------------------------------- /app/models/competition-attempt.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | userId: DS.attr(), 5 | competitionId: DS.attr() 6 | }); 7 | -------------------------------------------------------------------------------- /app/models/competition.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | import moment from 'npm:moment'; 3 | 4 | export default DS.Model.extend ({ 5 | name : DS.attr (), 6 | organization : DS.belongsTo ('organization'), 7 | thumbnail : DS.attr(), 8 | banner : DS.attr(), 9 | overview : DS.attr(), 10 | description : DS.attr(), 11 | prizes : DS.attr(), 12 | faqs : DS.attr (), 13 | startDate : DS.attr(), 14 | endDate : DS.attr(), 15 | createdBy : DS.attr (), 16 | lastModifiedBy : DS.attr (), 17 | createdAt : DS.attr (), 18 | updatedAt : DS.attr (), 19 | deletedAt : DS.attr (), 20 | contests : DS.hasMany (), 21 | 22 | startDateString: Ember.computed ('startDate', function () { 23 | return moment.unix (this.get ('startDate')).format ('DD MMMM YYYY') 24 | }), 25 | 26 | endDateString: Ember.computed ('endDate', function () { 27 | return moment.unix (this.get ('endDate')).format ('DD MMMM YYYY') 28 | }) 29 | }); 30 | -------------------------------------------------------------------------------- /app/models/competition_leaderboard.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | score: DS.attr(), 5 | competition: DS.belongsTo('competition'), 6 | user: DS.belongsTo('user'), 7 | college: DS.belongsTo('college') 8 | }) -------------------------------------------------------------------------------- /app/models/contest_leaderboard.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data' 2 | 3 | export default DS.Model.extend({ 4 | score: DS.attr(), 5 | contest: DS.belongsTo('contest'), 6 | user: DS.belongsTo('user'), 7 | college: DS.belongsTo('college') 8 | }) -------------------------------------------------------------------------------- /app/models/dailycb.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | import moment from 'npm:moment'; 3 | import Ember from 'ember'; 4 | 5 | let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; 6 | 7 | export default DS.Model.extend({ 8 | date : Ember.computed('day', { 9 | get(key) { 10 | return moment(this.get('day'), 'YYYYMMDD').format('YYYY-MM-DD'); 11 | }, 12 | set(key,val) { 13 | this.set('day', moment(val,'YYYY-MM-DD').format('YYYYMMDD')); 14 | } 15 | }), 16 | day : DS.attr(), 17 | UTCDay: Ember.computed('day', function () { 18 | return this.get('day').toString().substring(6,8); 19 | }), 20 | UTCMonth: Ember.computed('day', function () { 21 | let month = this.get('day').toString().substring(4, 6); 22 | return months[parseInt(month) - 1]; 23 | }), 24 | problem : DS.belongsTo(), 25 | maxscore : DS.attr(), 26 | count: DS.attr(), 27 | isArchived: Ember.computed('day', function () { 28 | let dayStamp = moment.unix(moment().unix()).format('YYYYMMDD'); 29 | if (this.get('day') < dayStamp) { 30 | return true; 31 | } 32 | return false; 33 | }) 34 | }); 35 | -------------------------------------------------------------------------------- /app/models/editorial.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | content: DS.attr(), 5 | p_id: DS.attr(), 6 | video: DS.attr() 7 | }); 8 | 9 | -------------------------------------------------------------------------------- /app/models/level.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | title : DS.attr (), 5 | description : DS.attr (), 6 | createdBy : DS.attr (), 7 | image : DS.attr (), 8 | createdAt : DS.attr (), 9 | updatedAt : DS.attr (), 10 | deletedAt : DS.attr (), 11 | track : DS.belongsTo ('track'), 12 | contests : DS.hasMany ('contest'), 13 | unlockedLevels: DS.hasMany ('unlocked-level'), 14 | unlocked: Ember.computed ('unlockedLevels', function () { 15 | return (this.get ('unlockedLevels').toArray ().length > 0) 16 | }) 17 | }); 18 | -------------------------------------------------------------------------------- /app/models/notification.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | message: DS.attr(), 5 | notiIcon: DS.attr(), 6 | bgColor: DS.attr(), 7 | link: DS.attr(), 8 | }); -------------------------------------------------------------------------------- /app/models/organization.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | name : DS.attr (), 5 | url : DS.attr (), 6 | createdBy : DS.attr (), 7 | lastModifiedBy : DS.attr (), 8 | createdAt : DS.attr (), 9 | updatedAt : DS.attr (), 10 | deletedAt : DS.attr () 11 | }); 12 | -------------------------------------------------------------------------------- /app/models/practice_category.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 30/12/16. 3 | */ 4 | 5 | import DS from 'ember-data'; 6 | 7 | export default DS.Model.extend({ 8 | name: DS.attr(), 9 | cId: DS.attr(), 10 | problemCount: DS.attr (), 11 | contests: DS.belongsTo('contest') 12 | }); 13 | -------------------------------------------------------------------------------- /app/models/problem-attempt.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | userId: DS.attr (), 5 | contestId: DS.attr (), 6 | problemId: DS.attr (), 7 | createdAt: DS.attr (), 8 | updatedAt: DS.attr () 9 | }); 10 | -------------------------------------------------------------------------------- /app/models/problem.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 02/01/17. 3 | */ 4 | 5 | import DS from 'ember-data'; 6 | 7 | export default DS.Model.extend({ 8 | name: DS.attr(), 9 | content: DS.attr(), 10 | submitCount: DS.attr(), 11 | difficulty: DS.attr(), 12 | image: DS.attr('string', {defaultValue: "https://s1.postimg.org/wyhyiimtb/image.png"}), 13 | tags: DS.hasMany (), 14 | submissions: DS.hasMany('submissions',{inverse:'problem'}), 15 | top:DS.belongsTo('submission'), 16 | leaderboard: DS.hasMany('submissions', {async: true}), 17 | userCount: DS.attr(), 18 | solutionStubs: DS.hasMany('solutionStub'), 19 | timeLimit: DS.attr({defaultValue: 2}), 20 | }); 21 | -------------------------------------------------------------------------------- /app/models/problem_leaderboard.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | score: DS.attr(), 5 | submit_at: DS.attr(), 6 | language: DS.attr(), 7 | problem: DS.belongsTo('problem'), 8 | contest: DS.belongsTo('contest'), 9 | user: DS.belongsTo('user'), 10 | college: DS.belongsTo('college') 11 | }) -------------------------------------------------------------------------------- /app/models/question.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | title: DS.attr(), 5 | description: DS.attr(), 6 | difficulty: DS.attr(), 7 | choices: DS.hasMany('choice') 8 | }) -------------------------------------------------------------------------------- /app/models/quiz-attempt.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | userId: DS.attr (), 5 | contest: DS.belongsTo ('contest'), 6 | quizSubmissions: DS.attr (), 7 | quiz: DS.belongsTo ('quiz'), 8 | result: DS.attr (), 9 | submission: DS.attr () 10 | }); 11 | -------------------------------------------------------------------------------- /app/models/quiz-submission.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | currentattemptId: DS.belongsTo ('quiz_attempt'), 5 | questionId: DS.attr(), 6 | answerId: DS.attr() 7 | }); 8 | -------------------------------------------------------------------------------- /app/models/quiz.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | title: DS.attr(), 5 | description: DS.attr(), 6 | duration: DS.attr(), 7 | maxAttempts: DS.attr(), 8 | questions: DS.hasMany('question', { async: true }) 9 | }) 10 | -------------------------------------------------------------------------------- /app/models/submission.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 05/01/17. 3 | */ 4 | 5 | import DS from 'ember-data'; 6 | 7 | export default DS.Model.extend({ 8 | userId: DS.attr(), 9 | userName: DS.attr(), 10 | photo:DS.attr(), 11 | source: DS.attr(), 12 | judgeResult: DS.attr(), 13 | submitAt: DS.attr(), 14 | language: DS.attr(), 15 | score: DS.attr(), 16 | explanation: DS.attr ('string'), 17 | result: DS.attr(), 18 | problemId: DS.attr('string'), 19 | collegeName: DS.attr ('string'), 20 | problemName:DS.attr('string'), 21 | isTopSubmission:DS.attr('boolean'), 22 | tcRuns: DS.attr(), 23 | problem:DS.belongsTo('problem',{inverse:'top'}), 24 | contest:DS.belongsTo('contest'), 25 | user: DS.belongsTo('user'), 26 | certificateEarned: DS.attr ('boolean'), 27 | plagiarismDetected: DS.attr('boolean') 28 | }); 29 | -------------------------------------------------------------------------------- /app/models/tag.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | name : DS.attr (), 5 | title : Ember.computed.oneWay ('name') 6 | }); 7 | -------------------------------------------------------------------------------- /app/models/track.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend ({ 4 | title : DS.attr (), 5 | description : DS.attr (), 6 | createdBy : DS.attr (), 7 | order : DS.attr (), 8 | createdAt : DS.attr (), 9 | updatedAt : DS.attr (), 10 | deletedAt : DS.attr (), 11 | levels : DS.hasMany ('levels') 12 | }); 13 | -------------------------------------------------------------------------------- /app/models/unlocked-editorial.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | problem_id: DS.attr (), 5 | user_id: DS.attr (), 6 | contest_id: DS.attr () 7 | }); 8 | 9 | -------------------------------------------------------------------------------- /app/models/unlocked-level.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | level: DS.belongsTo ('level'), 5 | user_id: DS.attr () 6 | }); 7 | 8 | -------------------------------------------------------------------------------- /app/models/unlocked-testcase.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | problem_id: DS.attr (), 5 | user_id: DS.attr (), 6 | contest_id: DS.attr (), 7 | urls: DS.attr () 8 | }); 9 | 10 | -------------------------------------------------------------------------------- /app/models/user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 12/01/17. 3 | */ 4 | 5 | import DS from 'ember-data'; 6 | import courseDescriptionProvider from '../utils/get-course-description'; 7 | 8 | export default DS.Model.extend({ 9 | name: DS.attr(), 10 | roll_number: DS.attr(), 11 | email: DS.attr(), 12 | oauthId: DS.attr(), 13 | photo: DS.attr('string', { 14 | defaultValue() { return "https://hack.codingblocks.com/images/placeholder-avatar.png" } 15 | }), 16 | course: DS.attr('string'), 17 | courseDescription: Ember.computed('course', function () { 18 | return courseDescriptionProvider(this.get('course')); 19 | }), 20 | is_active: DS.attr(), 21 | bCode:DS.attr() 22 | }); 23 | -------------------------------------------------------------------------------- /app/pods/application-error/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | setupController(controller, errors) { 5 | let error = errors.errors.get('firstObject'); 6 | if (!error.message) { 7 | if (error.status === "403") { 8 | error.message = 'You are not authorized to view that page.'; 9 | error.image = '/images/disable-icon.png' 10 | } 11 | 12 | else if (error.status === "404") { 13 | error.message = 'The page you asked for doesn\'t exist!'; 14 | error.image = '/images/disable-icon.png' 15 | } 16 | 17 | else if (error.status === "500") { 18 | error.message = 'HackerBlocks is down!'; 19 | error.image = '/images/error-icon.png' 20 | 21 | } 22 | 23 | } 24 | 25 | this._super(...arguments) 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /app/pods/application/adapter.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | import env from '../../config/environment'; 3 | import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin'; 4 | 5 | export default DS.JSONAPIAdapter.extend(DataAdapterMixin, { 6 | namespace: 'api', 7 | host: env.apiEndpoint, 8 | headers: { 9 | 'client': 'hacker-blocks', 10 | }, 11 | urlForQueryRecord(query) { 12 | if(query.custom) { 13 | switch (query.custom.ext){ 14 | case 'url' : 15 | let url = query.custom.url; 16 | delete query.custom; 17 | return `${this._super(...arguments)}/${url}`; 18 | case 'weekly': 19 | return `${this._super(...arguments)}/weekly/${query.problem_id}`; 20 | } 21 | } else { 22 | return this._super(...arguments); 23 | } 24 | }, 25 | urlForQuery(query) { 26 | if(query.custom) { 27 | switch (query.custom.ext) { 28 | case 'url' : 29 | let url = query.custom.url; 30 | delete query.custom; 31 | return `${this._super(...arguments)}/${url}`; 32 | } 33 | } else { 34 | return this._super(...arguments); 35 | } 36 | }, 37 | authorizer: 'authorizer:custom' 38 | }); 39 | -------------------------------------------------------------------------------- /app/pods/application/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/application/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; 3 | 4 | const { inject: { service }, Route } = Ember; 5 | 6 | export default Ember.Route.extend(ApplicationRouteMixin, { 7 | routing: Ember.inject.service('-routing'), 8 | session: service('session'), 9 | currentUserSer: service('current-user'), 10 | url: Ember.observer('router.url', function () { 11 | this.set('controller.link', this.get('router.url')); 12 | }), 13 | model() { 14 | if (this.get('session.isAuthenticated')) { 15 | return this._loadCurrentUser() 16 | .then (currentUser => ( 17 | ga ('set', 'userId', currentUser.get ('oauthId')), 18 | currentUser 19 | )) 20 | } 21 | }, 22 | beforeModel(transition) { 23 | 24 | if (!this.get('session.isAuthenticated') && transition.queryParams.code !== undefined) { 25 | //debugger; 26 | return this.get('session') 27 | .authenticate('authenticator:custom', transition.queryParams.code) 28 | .then(()=>{ 29 | 30 | var retrievedPath = localStorage.getItem('redirection-path'); 31 | 32 | if(retrievedPath) { 33 | 34 | localStorage.removeItem('redirection-path'); 35 | window.location.href = retrievedPath; 36 | 37 | } 38 | 39 | })/*.catch((err) => { 40 | Raven.captureException(err); 41 | if (err.message === 'GRANT_INVALID') 42 | 43 | // console.log("not logged in", reason); 44 | });*/ 45 | } 46 | }, 47 | /* 48 | setupController: function(controller, model){ 49 | this._super(controller, model); 50 | Ember.run.schedule('afterRender', this, function () { 51 | 52 | }); 53 | },*/ 54 | sessionAuthenticated() { 55 | this._super(...arguments); 56 | // this._loadCurrentUser().catch(() => this.get('session').invalidate()); 57 | this.refresh(); 58 | }, 59 | _loadCurrentUser() { 60 | return this.get('currentUserSer').load(); 61 | }, 62 | afterModel(user) { 63 | //debugger; 64 | if(user) { 65 | Raven.setUserContext({username:user.get('name'),id:user.get('oauthId'),email:user.get('email')}); 66 | } 67 | /* 68 | if (this.get('session.isAuthenticated')) { 69 | let user_id = this.get('session.data.authenticated.user_id'); 70 | this.get('chat').init(user_id, config.GLOBAL_CHAT_NAME); 71 | }*/ 72 | }, 73 | actions: { 74 | error (err, transition) { 75 | if (err.status == 405) { 76 | this.transitionTo('info', 405, {queryParams: {code: undefined}}); 77 | } else { 78 | this._super(...arguments) 79 | } 80 | } 81 | } 82 | }); 83 | -------------------------------------------------------------------------------- /app/pods/application/template.hbs: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | {{#unless embeded}} 5 | {{#nav-bar model=model}}{{/nav-bar}} 6 | {{#left-side-bar model=model}}{{/left-side-bar}} 7 | {{/unless}} 8 | 9 | {{outlet}} 10 | 11 |
12 | -------------------------------------------------------------------------------- /app/pods/competitions/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | breadCrumb: { 5 | title: 'All Competitions' 6 | }, 7 | 8 | model () { 9 | return this.get ('store').findAll ('competition') 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /app/pods/competitions/index/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |

Competitions

3 |
4 | 5 |
6 |
7 | {{#each model as |competition|}} 8 |
9 | {{#competition-card competition=competition}} 10 | {{/competition-card}} 11 |
12 | {{/each}} 13 |
14 |
15 | -------------------------------------------------------------------------------- /app/pods/competitions/overview/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from '../../../config/environment'; 3 | const { inject: { service }, Component } = Ember; 4 | 5 | export default Ember.Controller.extend({ 6 | currentUser: service ('current-user'), 7 | session: service ('session'), 8 | notifications: service ('toast'), 9 | tabs: [ 10 | { 11 | name: 'About', 12 | icon: '/images/about.svg' 13 | }, 14 | { 15 | name: 'Description', 16 | icon: '/images/desc.svg' 17 | }, 18 | { 19 | name: 'Prizes', 20 | icon: '/images/prize.svg' 21 | }, 22 | { 23 | name: 'FAQ\'s', 24 | icon: '/images/question.svg' 25 | } 26 | ], 27 | 28 | activeTab: 0, 29 | 30 | actions: { 31 | participate (competitionId) { 32 | const store = this.get ('store'), 33 | userId = this.get('session').get('data').authenticated.user_id, 34 | notifications = this.get ('notifications') 35 | ; 36 | 37 | store 38 | .queryRecord ('CompetitionAttempt', { 39 | competitionId: competitionId, 40 | custom: { 41 | ext: 'url', 42 | url: 'current' 43 | } 44 | }) 45 | .then (attempt => { 46 | if (attempt) 47 | return attempt 48 | 49 | return store.createRecord ('CompetitionAttempt', { 50 | competitionId: competitionId, 51 | userId: userId 52 | }).save () 53 | }) 54 | .then (attempt => { 55 | this.transitionToRoute ('competitions.view', competitionId) 56 | }) 57 | .catch (error => { 58 | notifications.error ('Something went wrong, please refresh the page or try again later!') 59 | }) 60 | }, 61 | popup() { 62 | var redirectionPath = window.location.pathname; 63 | redirectionPath = redirectionPath.replace(/^\/|\/$/g, ''); 64 | localStorage.setItem('redirection-path', redirectionPath); 65 | window.location = "https://account.codingblocks.com/oauth/authorize?" + 66 | "response_type=code" + 67 | "&client_id=" + config.oneauthClientId + 68 | "&redirect_uri=" + config.publicUrl 69 | } 70 | } 71 | }); 72 | -------------------------------------------------------------------------------- /app/pods/competitions/overview/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model (params) { 5 | let store = this.get ('store') 6 | 7 | return store.findRecord ('competition', params.id, { reload:true }) 8 | }, 9 | setupController(controller, model){ 10 | controller.set('competition', model); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /app/pods/competitions/overview/template.hbs: -------------------------------------------------------------------------------- 1 | 26 | 27 |
28 | {{!--
--}} 29 |
30 | 31 | {{tab-nav tabs=tabs activeTab=activeTab}} 32 | 33 | {{#if (eq activeTab 0)}} 34 |
35 |

36 | {{markdown-to-html competition.overview}} 37 |

38 |
39 | {{/if}} 40 | 41 | {{#if (eq activeTab 1)}} 42 |
43 | {{markdown-to-html competition.description}} 44 |
45 | {{/if}} 46 | 47 | {{#if (eq activeTab 2)}} 48 |
49 | {{markdown-to-html competition.prizes}} 50 |
51 | {{/if}} 52 | 53 | {{#if (eq activeTab 3)}} 54 |
55 |

56 | {{markdown-to-html competition.faqs}} 57 |

58 |
59 | {{/if}} 60 |
61 | -------------------------------------------------------------------------------- /app/pods/competitions/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/competitions/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{outlet}} 4 |
5 |
-------------------------------------------------------------------------------- /app/pods/competitions/view/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | tabs: [ 5 | { 6 | name: 'About', 7 | icon: '/images/about.svg' 8 | }, 9 | { 10 | name: 'Contests', 11 | icon: '/images/question.svg' 12 | }, 13 | { 14 | name: 'Leaderboard', 15 | icon: '/images/prize.svg' 16 | }, 17 | { 18 | name: 'FAQ\'s', 19 | icon: '/images/question.svg' 20 | } 21 | ], 22 | 23 | activeTab: 2 24 | }); 25 | -------------------------------------------------------------------------------- /app/pods/competitions/view/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | api: Ember.inject.service(), 5 | beforeModel (transition) { 6 | let store = this.get ('store'), 7 | competitionId = transition.params['competitions.view'].id, 8 | attempt = store.queryRecord ('CompetitionAttempt', { 9 | competitionId: competitionId, 10 | custom: { 11 | ext: 'url', 12 | url: 'current' 13 | } 14 | }) 15 | ; 16 | 17 | attempt 18 | .then (attempt => { 19 | if (! attempt) throw new Error ('Competition Attempt Not Found!') 20 | }) 21 | .catch (_ => { 22 | this.transitionTo ('competitions.overview', competitionId) 23 | }) 24 | }, 25 | 26 | model (params) { 27 | let store = this.get ('store') 28 | 29 | const competition = store.findRecord ('competition', params.id, { reload:true }) 30 | const leaderboard = store.query ('competition', { 31 | custom: { 32 | ext: 'url', 33 | url: `${params.id}/leaderboard` 34 | } 35 | }) 36 | const collegeLeaderboard = this.get('api').request(`competitions/${params.id}/collegeLeaderboard`) 37 | return Ember.RSVP.hash({ 38 | competition, 39 | leaderboard, 40 | collegeLeaderboard 41 | }) 42 | }, 43 | 44 | afterModel (model, transition) { 45 | model.competition.get ('contests').map (contest => this.get ('store').findRecord ('contest', contest.id)) 46 | }, 47 | 48 | setupController(controller, model){ 49 | controller.set('competition', model.competition); 50 | controller.set('leaderboard', model.leaderboard); 51 | controller.set('collegeLeaderboard', model.collegeLeaderboard); 52 | } 53 | }); 54 | -------------------------------------------------------------------------------- /app/pods/components/ace-editor/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import getSnippet from '../../../utils/get-snippet'; 3 | 4 | export default Ember.Component.extend({ 5 | didRender() { 6 | ace.require("ace/src/ext-language_tools"); 7 | ace.require("ace/src/snippets"); 8 | this._super(...arguments); 9 | let editor = ace.edit("editor"); 10 | let theme = this.get('theme') || "ace/theme/monokai"; 11 | editor.setTheme(theme); 12 | const code = this.get("lang_codes"); 13 | const allowedLanguages = this.get("allowedLanguages"); 14 | let mode = null; 15 | if(allowedLanguages) { 16 | mode = code[allowedLanguages[0]].mode; 17 | } 18 | editor.getSession().setMode(mode || "ace/mode/c_cpp"); 19 | editor.setOptions({ 20 | enableBasicAutocompletion: true, 21 | enableSnippets: true, 22 | enableLiveAutocompletion: true 23 | }); 24 | if (this.get('readOnly') === true) { 25 | editor.setReadOnly(true); 26 | }; 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /app/pods/components/ace-editor/template.hbs: -------------------------------------------------------------------------------- 1 |
{{yield}}
2 | -------------------------------------------------------------------------------- /app/pods/components/bread-crumb/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | const { 4 | getOwner, 5 | computed, 6 | getWithDefault, 7 | A: emberArray, 8 | String: { classify } 9 | } = Ember; 10 | const { 11 | bool, 12 | readOnly 13 | } = computed; 14 | 15 | /* 16 | * This file contains one of the hackiest codes I've written. So please don't judge. 17 | * - omerjerk 18 | * */ 19 | 20 | const indexPath = { 21 | 'contests': true, 22 | 'contests.contest': true, 23 | 'contests.contest.problem': true, 24 | 'contests.contest.problem.main': false, 25 | 'contests.contest.problem.leaderboard': false, 26 | 'contests.contest.problem.submissions': false, 27 | 'dcb': true, 28 | 'practice': true, 29 | 'practice.problems': true, 30 | 'practice.problems.problem': true 31 | }; 32 | 33 | export default Ember.Component.extend({ 34 | routing: Ember.inject.service('-routing'), 35 | breadCrumbs: computed('routing.currentRouteName', { 36 | get() { 37 | const routeName = this.get('routing.currentRouteName'); 38 | return this._lookupBreadCrumbs(routeName); 39 | } 40 | }).readOnly(), 41 | 42 | _lookupBreadCrumbs: function (routeName) { 43 | let routeNames = routeName.split('.'); 44 | let lastRouteName = ''; 45 | let breadCrumbs = []; 46 | for (let i = 0; i < routeNames.length; ++i) { 47 | let routeTitle = routeNames[i]; 48 | if (routeTitle === 'index') { break; } 49 | let modifiedRouteName = (lastRouteName === ''? '' : lastRouteName + '.') + routeTitle; 50 | let route; 51 | if (indexPath[modifiedRouteName] === true) { 52 | modifiedRouteName = modifiedRouteName + '.index'; 53 | } 54 | route = getOwner(this).lookup(`route:${modifiedRouteName}`); 55 | let breadCrumb = getWithDefault(route, 'breadCrumb', { 56 | title: routeTitle 57 | }); 58 | // console.log("breadcrumb title = " + breadCrumb.title); 59 | breadCrumbs.push({name: breadCrumb.title, route: modifiedRouteName, id: 'bcrumb-' + routeTitle}); 60 | lastRouteName = (lastRouteName === ''? '' : lastRouteName + '.') + routeTitle; 61 | } 62 | return breadCrumbs; 63 | } 64 | }); 65 | -------------------------------------------------------------------------------- /app/pods/components/bread-crumb/template.hbs: -------------------------------------------------------------------------------- 1 | 6 | {{yield}} 7 | -------------------------------------------------------------------------------- /app/pods/components/c-review-pad/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | store: Ember.inject.service (), 5 | questions: null, 6 | 7 | didReceiveAttrs () { 8 | this._super (...arguments) 9 | 10 | let quizState = this.get ('quizState'), 11 | questionIds = this.get ('questionIds') 12 | ; 13 | 14 | this.set ('questions', questionIds.map (questionId => { 15 | let question = { questionId, answerId: null, review: false } 16 | 17 | if (quizState) { 18 | quizState.map (attempt => { 19 | if (attempt.get('questionId') === questionId) { 20 | question.answerId = attempt.get('answerId') 21 | } 22 | }) 23 | } 24 | 25 | if (localStorage.getItem (`review-${questionId}`) === 'true') { 26 | question.review = true 27 | } 28 | 29 | return question 30 | })) 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /app/pods/components/c-review-pad/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
Review Questions {{what}}
3 |
4 | {{#each questions as |question index|}} 5 | {{review-circle question=question index=index onCircleClick=(action onReview)}} 6 | {{/each}} 7 |
8 |
9 | 10 | 35 | -------------------------------------------------------------------------------- /app/pods/components/circular-loader/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/components/circular-loader/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
-------------------------------------------------------------------------------- /app/pods/components/clock-view/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 |

{{month}} {{date}}

7 |

{{year}} {{day}}

8 |

{{hours}}{{minutes}}{{seconds}}

9 |
10 |
    11 |
  • 12 |
  • 13 |
  • 14 |
15 |
16 |

This code byte is available till midnight only

17 |
18 |
19 |
20 |
21 | -------------------------------------------------------------------------------- /app/pods/components/college-leaderboard/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/components/college-leaderboard/template.hbs: -------------------------------------------------------------------------------- 1 | {{#if leaderboard}} 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {{#each leaderboard as |row index|}} 13 | 14 | 15 | 18 | 21 | 22 | {{/each}} 23 | 24 |
RankCollegeScore
{{sum index 1}} 16 | {{row.collegeName}} 17 | 19 | {{row.score}} 20 |
25 |
26 | {{else}} 27 |

28 | We can't show you a leaderboard until the submissions start rolling in, 29 | stay tuned! 30 |

31 | {{/if}} 32 | -------------------------------------------------------------------------------- /app/pods/components/competition-card/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/components/competition-card/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{#if competition.thumbnail}} 4 | alt text 5 | {{else}} 6 | alt text 7 | {{/if}} 8 |
9 | 10 |

11 | {{competition.name}} 12 |

13 | 14 |
15 | {{#link-to 'competitions.view' competition.id class="btn btn-red"}} 16 | Participate! 17 | {{/link-to}} 18 |
19 |
20 | -------------------------------------------------------------------------------- /app/pods/components/contest-banner-view/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import ENV from '../../../config/environment'; 3 | export default Ember.Component.extend({ 4 | submissionCount: null, 5 | init () { 6 | this._super(...arguments); 7 | Ember.$.ajax({ 8 | method: "GET", 9 | data:{ 10 | contestId: this.get('contest.id'), 11 | }, 12 | url: (ENV.apiEndpoint + '/api/submissions/submissionCount') 13 | }).done(res => { 14 | this.set("submissionCount",res[0].count); 15 | }).fail (err => { 16 | console.log(err); 17 | }); 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /app/pods/components/contest-banner-view/template.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{#link-to link contest.id}} 3 |
4 |
5 |
6 |
7 | {{contest.name}} 8 |
9 |
10 | {{log submissionCount}} 11 |

{{contest.name}}

12 |

{{contest.description}}

13 | Total Correct Submissions: {{submissionCount}} 14 |
15 |
16 |
17 | {{#if archived}}Ended:{{else}}Ends:{{/if}} 18 | {{contest.endTimeObj.day}} 20 | {{contest.endTimeObj.month}} 22 | {{contest.endTimeObj.hour}} 24 | : {{contest.endTimeObj.min}} 25 |
26 |
27 | {{contest.problems.length}} 28 | Problems 30 |
31 | {{#if showPoints}} 32 |
33 | {{multiply contest.problems.length 100}} 34 | Points 36 |
37 | {{/if}} 38 |
39 |
40 |
41 | {{/link-to}} 42 |
43 | -------------------------------------------------------------------------------- /app/pods/components/contest-view/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | didReceiveAttrs() { 5 | this._super(...arguments); 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /app/pods/components/contest-view/template.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{#link-to link contest.id}} 3 |
4 |
5 | {{contest.name}} 6 |
7 |

{{contest.name}}

8 |
9 | {{#if noEndTime}} 10 |
11 | {{else}} 12 |
13 | {{#if archived}}Ended:{{else}}Ends:{{/if}} 14 | {{contest.endTimeObj.day}} 16 | {{contest.endTimeObj.month}} 18 | {{contest.endTimeObj.hour}} 20 | : {{contest.endTimeObj.min}} 21 |
22 | {{/if}} 23 | {{#if contest.showCounts}} 24 |
25 | 26 | {{#if problem-count}} 27 | {{problem-count}} 28 | {{else}} 29 | {{contest.problemCount}} 30 | {{/if}} 31 | 32 | Problems 33 |
34 | 35 | {{#if contest.quizCount}} 36 |
37 | {{contest.quizCount}} 38 | Quizzes 39 |
40 | {{else}} 41 | {{#if showPoints}} 42 |
43 | {{contest.points}} 44 | Points 46 |
47 | {{/if}} 48 | {{/if}} 49 | {{/if}} 50 |
51 |

{{truncate-multiline text = contest.description lines=2 showButton=false}}

52 |
53 |
54 | {{/link-to}} 55 |
56 | -------------------------------------------------------------------------------- /app/pods/components/countdown-timer/component.js: -------------------------------------------------------------------------------- 1 | import Ember, { TransformEachInToHash } from 'ember'; 2 | import moment from 'npm:moment'; 3 | 4 | /* 5 | @params 6 | startTime: Unix Timestamp(in seconds) When the user clicks attempt 7 | duration: Unix Timestamp(in seconds) the duration for the contest 8 | onComplete: an Action/method to call when the countdown ends 9 | */ 10 | 11 | export default Ember.Component.extend({ 12 | //pollId: Id of the current tick poll 13 | //endTime: Unix Timestamp(in seconds) of the endTime (startTime+duration) 14 | 15 | poll: Ember.inject.service(), 16 | serverTime: Ember.inject.service (), 17 | 18 | didReceiveAttrs () { 19 | //setup an poll to call tick function with interval NO LESS than 1 sec 20 | const pollId = this.get('poll').addPoll({ 21 | interval: 1000, 22 | callback: () => this.send('tick') 23 | }) 24 | 25 | this.set('pollId', pollId) 26 | 27 | const startTime = this.get('startTime') 28 | const duration = this.get('duration') 29 | this.set('endTime', startTime+duration) 30 | 31 | this.send('tick') 32 | 33 | return this._super(...arguments) 34 | }, 35 | 36 | willDestroyElement () { 37 | this.get('poll').stopAll(); 38 | return this._super(...arguments) 39 | }, 40 | 41 | 42 | countdownEndTime: Ember.computed('duration', 'startTime', function() { 43 | return this.get('startTime') + this.get('duration') 44 | }), 45 | 46 | // The actual string to display in the coundown timer. 47 | // The difference between now and endTime 48 | displayString: Ember.computed('now', function () { 49 | const now = this.get('now') 50 | const endTime = this.get('countdownEndTime') 51 | 52 | let diff = Math.floor(endTime - now) 53 | const hrs = Math.floor(diff/3600) 54 | diff %= 3600 55 | const min = Math.floor(diff/60) 56 | diff %= 60 57 | const sec = diff 58 | return `${hrs} Hours ${min} Mins and ${sec} Seconds` 59 | }), 60 | 61 | isCompleted: Ember.computed('now', function () { 62 | const now = this.get('now') 63 | const endTime = this.get('countdownEndTime') 64 | if (now >= endTime) { 65 | this.get('poll').stopAll(); 66 | Ember.run.scheduleOnce('render', () => { 67 | this.get('onComplete')() 68 | }) 69 | return true; 70 | } else { 71 | return false 72 | } 73 | }), 74 | 75 | actions: { 76 | tick() { 77 | // set now equal to unix timestamp in seconds 78 | this.set ('now', this.get ('serverTime').getUnixTime ()) ; 79 | }, 80 | } 81 | }); 82 | -------------------------------------------------------------------------------- /app/pods/components/countdown-timer/template.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{#unless noIcon}} 3 | timer 4 | {{/unless}} 5 | {{#if isCompleted}} 6 | Time Over! 7 | {{else}} 8 | Time Left: 9 |

{{displayString}}

10 | {{/if}} 11 |
12 | -------------------------------------------------------------------------------- /app/pods/components/current-cb-card/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | init() { 5 | this._super(...arguments); 6 | }, 7 | didRender() { 8 | this._super(...arguments); 9 | if($('#daily-problem-description')[0].scrollHeight > $('#daily-problem-description')[0].clientHeight){ 10 | $('#overflow-description').css('display','block'); 11 | } 12 | } 13 | 14 | }); 15 | -------------------------------------------------------------------------------- /app/pods/components/editorial-view/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/components/editorial-view/template.hbs: -------------------------------------------------------------------------------- 1 | {{#if model}} 2 | {{#if model.video}} 3 | 4 | {{/if}} 5 | {{markdown-to-html model.content}} 6 | {{else}} 7 |

No Editorial Exists for the given problem.

8 | {{/if}} 9 | -------------------------------------------------------------------------------- /app/pods/components/home-statistics/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | didInsertElement() { 5 | const $ = Ember.$; 6 | $(document).ready(function () { 7 | $('.count').each(function () { 8 | $(this).prop('Counter', 0).animate({ 9 | Counter: $(this).text() 10 | }, { 11 | duration: 2000, 12 | easing: 'swing', 13 | step: function (now) { 14 | $(this).text(Math.ceil(now)); 15 | } 16 | }); 17 | }); 18 | }); 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /app/pods/components/home-statistics/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

{{model.contests.meta.userCount}}

5 |

Total Registered Users

6 |
7 |
8 |
9 |
10 |
11 | {{#link-to 'contests.index' tagName="div" class="panel-body pointer"}} 12 |

{{model.contests.length}}

13 |

Contests

14 | {{/link-to}} 15 |
16 |
17 |
18 |
19 |
20 |

{{model.contests.meta.subCount}}

21 |

Submissions

22 |
23 |
24 |
25 | -------------------------------------------------------------------------------- /app/pods/components/left-side-bar/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from '../../../config/environment'; 3 | 4 | export default Ember.Component.extend({ 5 | didRenderDone: false, 6 | didRender() { 7 | if (this.get('didRenderDone') === false) { 8 | $.AdminBSB.leftSideBar.activate(); 9 | $.AdminBSB.navbar.activate(); 10 | this.set('didRenderDone', true); 11 | } 12 | }, 13 | session: Ember.inject.service('session'), 14 | actions: { 15 | popup() { 16 | var redirectionPath = window.location.pathname; 17 | redirectionPath = redirectionPath.replace(/^\/|\/$/g, ''); 18 | localStorage.setItem('redirection-path', redirectionPath); 19 | window.location = "https://account.codingblocks.com/oauth/authorize?" + 20 | "response_type=code" + 21 | "&client_id=" + config.oneauthClientId + 22 | "&redirect_uri=" + config.publicUrl 23 | } 24 | } 25 | }); 26 | -------------------------------------------------------------------------------- /app/pods/components/live-reload/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import moment from 'moment'; 3 | 4 | export default Ember.Component.extend({ 5 | seconds: null, 6 | minutes: null, 7 | days: null, 8 | hours: null, 9 | routing: Ember.inject.service('-routing'), 10 | serverTime: Ember.inject.service (), 11 | didRender() { 12 | this._super(...arguments); 13 | var _this = this; 14 | const currentContest = _this.get('contest'); 15 | let unixTime = currentContest.get('startTime'); 16 | const timer = setInterval(function () { 17 | var current = _this.get ('serverTime').getTime (); 18 | var future = unixTime * 1000; 19 | var diff = future - current; 20 | var tempTime = moment.duration(diff); 21 | 22 | 23 | if (diff <= 100) { 24 | // TODO: Force model refresh if possible. 25 | _this.get ('routing').router.replaceWith ('contests.contest', currentContest.get('id')); 26 | clearInterval (timer); 27 | return; 28 | } 29 | 30 | _this.set('seconds', tempTime.seconds()); 31 | _this.set('minutes', tempTime.minutes()); 32 | _this.set('hours', tempTime.hours()); 33 | _this.set('days', tempTime.days()); 34 | 35 | }, 1000); 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /app/pods/components/live-reload/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{days}} days 4 |
5 |
6 | {{hours}} hrs 7 |
8 |
9 | {{minutes}} mins 10 |
11 | 12 |
13 | {{seconds}} secs 14 |
15 |
16 | -------------------------------------------------------------------------------- /app/pods/components/login-dialog/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | const { inject: { service } } = Ember; 3 | 4 | export default Ember.Component.extend({ 5 | session: Ember.inject.service('session'), 6 | PN: service('pn'), 7 | didRender() { 8 | this._super(...arguments); 9 | }, 10 | actions: { 11 | authenticate() { 12 | var self = this; 13 | let username = $('#username').val(); 14 | let password = window.btoa($('#password').val()); 15 | this.get('session').authenticate('authenticator:custom', username, password).catch((reason) => { 16 | Raven.captureException(reason); 17 | this.set('errorMessage', reason.error || reason); 18 | }); 19 | this.get('session').on('authenticationSucceeded', function () { 20 | let user_id = self.get('session.data.authenticated.user_id'); 21 | self.get('PN').init(user_id); 22 | $('#loginModal').modal('hide'); 23 | }); 24 | } 25 | } 26 | }); 27 | -------------------------------------------------------------------------------- /app/pods/components/login-dialog/template.hbs: -------------------------------------------------------------------------------- 1 | 33 | -------------------------------------------------------------------------------- /app/pods/components/nagarro-cnc/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/components/nagarro-cnc/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 | Nagarro Code-N-Counter 7 |
8 |
9 | Code-N-Counter 2.0 is a coding challenge organized by Nagarro for emerging programmers, currently pursuing their college degree. It’s an exciting and challenging competition that will allow participants to test, demonstrate and improve their programming skills. Nagarro is a company of brightest minds and it is our constant endeavor to identify and encourage like-minded talent. 10 |
11 | Register 12 |
13 |
14 |
15 | -------------------------------------------------------------------------------- /app/pods/components/nav-bar/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from '../../../config/environment'; 3 | 4 | const { inject: { service } } = Ember; 5 | export default Ember.Component.extend({ 6 | session: Ember.inject.service('session'), 7 | store: service('store'), 8 | notiCount:0, 9 | notifications: Ember.A(), 10 | navBarInitDone: false, 11 | init () { 12 | this._super(...arguments); 13 | this.get('store').query('notification', {}).then(result=>{ 14 | this.set('notifications', result) 15 | let readNoti = parseInt(window.localStorage.getItem("readNoti")); 16 | if (readNoti===null || readNoti === undefined) { 17 | readNoti = 0; 18 | } 19 | let notiCount = result.get('meta').notiCount - readNoti; 20 | if (!notiCount) 21 | { 22 | notiCount = 0; 23 | } else { 24 | this.set('notiCount',result.get('meta').notiCount - readNoti) // - loc storage 25 | } 26 | }) 27 | 28 | this.set("logoutURL", config.oneauthURL + 'logout?redirect=' + config.publicUrl + '/logout') 29 | }, 30 | actions: { 31 | storeNotiCount() { 32 | let notiCount = this.get('notiCount'); 33 | window.localStorage.setItem("readNoti",notiCount); 34 | this.set('notiCount',0); 35 | } 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /app/pods/components/nav-bar/template.hbs: -------------------------------------------------------------------------------- 1 | 35 |
36 | 37 | -------------------------------------------------------------------------------- /app/pods/components/notification-button/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | didRender() { 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /app/pods/components/notification-button/template.hbs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/pods/components/problem-leaderboard/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | import { task } from 'ember-concurrency'; 4 | 5 | export default Ember.Component.extend({ 6 | store: Ember.inject.service(), 7 | getLeaderBoard: task(function * () { 8 | let competitionId = this.get ('competitionId'); 9 | let store = this.get ('store') 10 | 11 | if (competitionId) { 12 | let leaderBoard = yield store.query ('competition', { 13 | custom: { 14 | ext: 'url', 15 | url: `${competitionId}/leaderboard` 16 | }, 17 | all: true 18 | }) 19 | 20 | this.set('leaderBoard', leaderBoard); 21 | this.set('yourRank', leaderBoard.meta.yourRank); 22 | 23 | return; 24 | } 25 | 26 | let contestId = this.get('contestId'); 27 | let problemId = this.get('problemId'); 28 | let customParams = { 29 | contest_id: contestId, 30 | custom: { 31 | ext: 'url', 32 | url: 'leaderboard' 33 | }, 34 | ...(this.get('limit') ? {} : {all: true}) 35 | }; 36 | if (problemId) { 37 | customParams.problem_id = problemId; 38 | } 39 | 40 | let leaderBoard = yield this.get('store').query('submission', customParams); 41 | 42 | leaderBoard.map (e => { 43 | if (e.get ('collegeId')) { 44 | store.findRecord ('college', e.get ('collegeId')).get ('name') 45 | } 46 | }) 47 | 48 | this.set('leaderBoard', leaderBoard); 49 | this.set('yourRank', leaderBoard.meta.yourRank); 50 | }), 51 | 52 | init () { 53 | this._super (...arguments); 54 | 55 | this.get ('getLeaderBoard').perform (); 56 | 57 | this.set('contest', this.get('store').peekRecord('contest', this.get('contestId'))) 58 | 59 | let refreshInterval = this.get ('refreshInterval') 60 | 61 | if (refreshInterval) { 62 | setInterval ( 63 | _ => this.get ('getLeaderBoard').perform (), 64 | refreshInterval 65 | ) 66 | } 67 | } 68 | }); 69 | -------------------------------------------------------------------------------- /app/pods/components/problem-my-submissions/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | session: Ember.inject.service('session'), 5 | currentContest: Ember.inject.service('current-contest'), 6 | store: Ember.inject.service(), 7 | init(){ 8 | this._super(...arguments); 9 | const currentContestId = this.get('currentContest').getContest() 10 | this.set('contest', this.get('store').peekRecord('contest', currentContestId)) 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /app/pods/components/problem-my-submissions/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |

My Submissions

3 |
4 | {{#if session.isAuthenticated}} 5 | {{#if (eq submissions.length 0)}} 6 | You haven't made a submission to this problem yet 7 | {{else}} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | {{#each submissions as |submission index|}} 20 | {{#link-to "submission" submission.id tagName="tr" class="pointer"}} 21 | 22 | 23 | {{#if (eq submission.result -2)}} 24 | 25 | {{else}} 26 | 27 | {{/if}} 28 | 29 | {{#if (and contest.plagiarismFiltering submission.plagiarismDetected)}} 30 | 33 | {{else if (eq submission.result -1)}} 34 | 37 | {{else if (eq submission.result -3)}} 38 | 41 | {{else if (eq submission.result 1)}} 42 | 45 | {{else }} 46 | 49 | {{/if}} 50 | {{/link-to}} 51 | {{/each}} 52 | 53 |
#Submit timeScoreLanguageResult
{{sum index 1}}{{ago-time submission.submitAt}}N/A{{submission.score}} (?) {{getlang submission.language}} 31 |
warningPlagiarism Detected
32 |
35 |
warningCompilation Error
36 |
39 |
access_timeTime Limit Exceeded
40 |
43 |
doneCorrect Answer
44 |
47 |
errorWrong Answer
48 |
54 | {{/if}} 55 | {{else}} 56 | Please Log In to see your submissions. 57 | {{/if}} 58 | -------------------------------------------------------------------------------- /app/pods/components/problem-parent/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | 5 | }); 6 | -------------------------------------------------------------------------------- /app/pods/components/problem-view/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | submissionResult: null, 5 | didRender() { 6 | this._super(...arguments); 7 | let submission = this.get('problem.top'); 8 | /* 9 | submissionResult -1 WA 10 | submissionResult 0 Partially Solved 11 | submissionResult 1 Correct Answer 12 | */ 13 | if (submission.get('isTopSubmission')) { 14 | if (submission.get('result') === -1) { 15 | this.set('submissionResult', -1); 16 | } else if (submission.get('result') === 1) { 17 | this.set('submissionResult', 1); 18 | } else if (submission.get('result') === 0) { 19 | if (submission.get('score') === 0) { 20 | this.set('submissionResult', -1); 21 | } else if (submission.get('score') > 0) { 22 | this.set('submissionResult', 0); 23 | } 24 | } 25 | } 26 | } 27 | 28 | }); 29 | -------------------------------------------------------------------------------- /app/pods/components/question-container/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | selectedChoiceId: Ember.computed.alias('questionSubmission.answerId'), 5 | didRender () { 6 | const questionContainer = document.querySelector('.questions-container') 7 | if (window.MathJax && questionContainer) { 8 | Ember.run.later (_ => MathJax.Hub.Queue(["Typeset", MathJax.Hub, questionContainer])) 9 | } 10 | }, 11 | actions: { 12 | async toggleChoice (choiceId) { 13 | const selectedChoiceId = choiceId === this.get('selectedChoiceId') ? null : choiceId 14 | this.get('updateQuestionSubmissionTask').perform(selectedChoiceId) 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /app/pods/components/question-container/template.hbs: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | Q {{questionNumber}}. 5 | {{markdown-to-html question.description}} 6 |
7 | 8 | {{#each question.choices as |choice|}} 9 |
10 |
11 |
12 | {{markdown-to-html choice.description}} 13 |
14 |
15 | {{/each}} 16 |
17 | -------------------------------------------------------------------------------- /app/pods/components/quiz-result/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | const { inject: { service } } = Ember; 3 | 4 | export default Ember.Component.extend({ 5 | store: service ('store'), 6 | question: null, 7 | correct: null, 8 | answerId: null, 9 | didReceiveAttrs () { 10 | const submission = this.get ('submission'), 11 | questionId = submission['question-id'], 12 | answerId = submission['answer-id'] 13 | ; 14 | 15 | this.set ('correct', (submission['score'] > 0)) 16 | this.set ('answerId', answerId) 17 | this.set ('question', this.get ('store').findRecord ('question', questionId)) 18 | 19 | console.log ('--> ', submission) 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /app/pods/components/quiz-result/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |

Q: {{question.description}}

3 |
4 | {{#each question.choices as |choice|}} 5 |
6 | {{#if (eq choice.id answerId)}} 7 | {{#if correct}} 8 | ✔︎ 9 | {{else}} 10 | 11 | {{/if}} 12 | {{choice.description}} 13 | {{else}} 14 | 15 | {{choice.description}} 16 | {{/if}} 17 |
18 | {{/each}} 19 |
20 | -------------------------------------------------------------------------------- /app/pods/components/review-circle/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | className: Ember.computed ('question.state', function () { 5 | const question = this.get ('question') 6 | return (question.answerId) ? 'bg-green' : '' 7 | }), 8 | 9 | reviewClass: Ember.computed ('question.review', function () { 10 | const question = this.get ('question') 11 | return (question.review) ? 'bg-yellow' : '' 12 | }) 13 | }); 14 | -------------------------------------------------------------------------------- /app/pods/components/review-circle/template.hbs: -------------------------------------------------------------------------------- 1 |
5 | {{sum index 1}} 6 |
7 | 8 | 23 | -------------------------------------------------------------------------------- /app/pods/components/right-side-bar/template.hbs: -------------------------------------------------------------------------------- 1 | 44 | -------------------------------------------------------------------------------- /app/pods/components/share-buttons/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import env from '../../../config/environment'; 3 | 4 | export default Ember.Component.extend({ 5 | publicUrl: env.publicUrl 6 | }); 7 | -------------------------------------------------------------------------------- /app/pods/components/share-buttons/template.hbs: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | Email 6 | 7 | 8 | 9 | 10 | Facebook 11 | 12 | 13 | 14 | 15 | Google 16 | 17 | 18 | 19 | 20 | Twitter 21 | 22 | 23 |
24 | -------------------------------------------------------------------------------- /app/pods/components/submission-explanation/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | alertClass: Ember.computed ('explanation', function () { 5 | let explanation = this.get ('explanation') 6 | 7 | switch (explanation) { 8 | case "Perfect": 9 | return "isa_success" 10 | break 11 | case "FailedTestcase": 12 | case "TimeLimitExceeded": 13 | case "CompilationError": 14 | return "alert alert-danger" 15 | break; 16 | default: 17 | return "alert alert-info" 18 | } 19 | 20 | if (explanation === "Perfect") { 21 | return "isa_success" 22 | } 23 | else { 24 | return "alert alert-info" 25 | } 26 | }) 27 | }); 28 | -------------------------------------------------------------------------------- /app/pods/components/submission-explanation/template.hbs: -------------------------------------------------------------------------------- 1 | {{#if explanation}} 2 |
3 | {{#if (eq explanation "Perfect")}} 4 | Congratulations, you passed every test case! Surely Hacker Blocks has harder 5 | problems for you to solve! 6 | {{else if (eq explanation "FailedTestcase")}} 7 | Dang! You couldn't score a perfect 100 because you failed one or 8 | more testcases. This means that your program didn't account for 9 | all input cases (did you account for negative numbers, for example?). 10 | {{else if (eq explanation "TimeLimitExceeded")}} 11 | Dang! Your program was too slow to compute the answer to one or more 12 | testcases. Think - is there a more efficient way to arrive at the 13 | solution than brute force? 14 | {{else if (eq explanation "CompilationError")}} 15 | Your code failed to compile. Check your program carefully for mistakes 16 | (missing semicolons, for example). 17 | {{else if (eq explanation "ContestOver")}} 18 | Note: You were not awarded any points as this contest 19 | has ended. Find more contests you can participate in 20 | here! 21 | {{else if (eq explanation "TestcaseUnlocked")}} 22 | Note: You were not awarded any points for this solution 23 | because you have unlocked the testcases to this problem. 24 | {{else if (eq explanation "EditorialUnlocked")}} 25 | Note: You were not awarded any points for this solution 26 | because you have unlocked the editorial to this problem. 27 | {{/if}} 28 |
29 | 30 |
31 | Our problems are designed, and tested by professionals that strive to 32 | ensure every testcase is perfect. However, if you believe this score to 33 | be incorrect, please let us know by clicking 34 | here. 35 |
36 | {{/if}} 37 | -------------------------------------------------------------------------------- /app/pods/components/tab-nav/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | actions:{ 5 | setActiveTab(index){ 6 | this.set('activeTab', index); 7 | } 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /app/pods/components/tab-nav/template.hbs: -------------------------------------------------------------------------------- 1 |
2 | {{#each tabs as |tab index|}} 3 |
4 | {{tab.name}} 5 |
6 | 7 |
8 | 9 |
10 | {{/each}} 11 |
-------------------------------------------------------------------------------- /app/pods/components/tutorials-container/component.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Component.extend({ 4 | attachments: null, 5 | selectedAttachment: null, 6 | 7 | init () { 8 | this._super (...arguments) 9 | let attachments = this.get ('contest.attachments').toArray () 10 | this.set ('attachments', attachments) 11 | attachments.map (attachment => attachment.set ('displayClass', '')) 12 | attachments[0].set ('displayClass', 'active') 13 | }, 14 | 15 | actions: { 16 | selectAttachment (id) { 17 | let attachments = this.get ('attachments') 18 | attachments.map (attachment => { 19 | attachment.set ('displayClass', '') 20 | 21 | if (attachment.id === id) { 22 | attachment.set ('displayClass', 'active') 23 | } 24 | }) 25 | } 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /app/pods/components/tutorials-container/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

Learning & Resources

6 |
7 |
8 |
9 |
10 |
11 |
12 | {{#each attachments as |attachment|}} 13 |
{{attachment.title}}
14 | {{/each}} 15 |
16 |
17 | {{#each attachments as |attachment|}} 18 | {{#if (eq "active" attachment.displayClass)}} 19 | {{#if (eq attachment.contentType 'pdf')}} 20 | 21 | {{/if}} 22 | 23 | {{#if (eq attachment.contentType 'youtube')}} 24 | 25 | {{/if}} 26 | {{/if}} 27 | {{/each}} 28 |
29 |
30 |
31 |
32 |
33 |
34 | -------------------------------------------------------------------------------- /app/pods/contest-attempt/model.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | startTime: DS.attr(), 5 | endTime: DS.attr(), 6 | userId: DS.attr(), 7 | contestId: DS.attr() 8 | }); 9 | -------------------------------------------------------------------------------- /app/pods/contests/contest/attachment/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model (params) { 5 | const attachment = this.modelFor ('contests.contest.attachment') 6 | ; 7 | 8 | return attachment 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /app/pods/contests/contest/attachment/index/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | {{model.title}} 6 |
7 |
8 |
9 | {{#link-to 'contests.contest' model.contest.id class="btn btn-red"}} 10 | Back to Contest 11 | {{/link-to}} 12 |
13 |
14 |
15 |
16 |
17 | {{markdown-to-html model.description}} 18 |
19 |
20 | {{#if (eq model.contentType 'pdf')}} 21 |
22 | 23 |
24 | {{/if}} 25 | 26 | {{#if (eq model.contentType 'youtube')}} 27 |
28 | 29 |
30 | {{/if}} 31 | 32 |
33 | 34 | 35 | 36 | 48 | -------------------------------------------------------------------------------- /app/pods/contests/contest/attachment/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | session: Ember.inject.service('session'), 5 | notifications: Ember.inject.service ('toast'), 6 | 7 | beforeModel (transition) { 8 | let session = this.get ('session'), 9 | notifications = this.get ('notifications') 10 | ; 11 | 12 | if (! session.get ('isAuthenticated')) { 13 | transition.abort () 14 | notifications.error ('You must be logged in to view that!') 15 | this.transitionTo ('contests.index') 16 | } 17 | }, 18 | 19 | model (params) { 20 | let store = this.get ('store') 21 | let { contest } = this.modelFor ('contests.contest'); 22 | 23 | let attachment = store.findRecord ('attachment', params.attachment_id, { reload: true }) 24 | .then (attachment => { 25 | attachment.set ('contest', contest) 26 | 27 | return attachment 28 | }) 29 | 30 | return attachment 31 | } 32 | 33 | }); 34 | -------------------------------------------------------------------------------- /app/pods/contests/contest/attachment/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/contests/contest/attempt/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | const { inject: { service } } = Ember; 3 | import { task, timeout } from 'ember-concurrency'; 4 | import Moment from 'npm:moment' 5 | 6 | export default Ember.Controller.extend({ 7 | session: service('session'), 8 | currentUser: service('current-user'), 9 | currentAttempt: service('current-attempt'), 10 | serverTime: service('server-time'), 11 | started: false, 12 | 13 | init() { 14 | const wait = (Math.random()*100) % 60 15 | this.set('wait', wait) 16 | this.set('start', this.get('serverTime').getUnixTime()) 17 | this.get('tickTask').perform() 18 | }, 19 | 20 | tickTask: task(function *() { 21 | while (this.get('serverTime').getUnixTime() < this.get('start') + this.get('wait')) { 22 | const left = Math.floor(this.get('start') + this.get('wait') - this.get('serverTime').getUnixTime()) 23 | this.set('left', left) 24 | yield timeout(1000) 25 | } 26 | this.set('started', true) 27 | }), 28 | 29 | attemptContestTask: task(function *(contestId) { 30 | const store = this.get('store') 31 | return this 32 | .get('currentAttempt') 33 | .getCurrentAttempts(contestId) 34 | .then(contestAttempt => { 35 | if (!contestAttempt) { 36 | return store 37 | .createRecord('ContestAttempt', { contestId: contestId }) 38 | .save() 39 | .then((result) => { 40 | if (result.data.startTime && result.data.startTime !== 0) { 41 | return this.transitionToRoute('contests.contest', contestId); 42 | } 43 | }).catch(err => { 44 | if (err.name !== "TransitionAborted") { 45 | this.set('error', 'You can\'t attempt this contest. You may have reached your max possible attempts on this contest.'); 46 | } 47 | }) 48 | } 49 | return this.transitionToRoute('contests.contest', contestId); 50 | }) 51 | }).drop() 52 | }); 53 | -------------------------------------------------------------------------------- /app/pods/contests/contest/attempt/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | session: Ember.inject.service('session'), 5 | currentContest: Ember.inject.service('current-contest'), 6 | breadCrumb: { 7 | title: 'Attempt' 8 | }, 9 | model() { 10 | return this.get('currentContest').getContest() 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /app/pods/contests/contest/attempt/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Attempt

5 | 6 | Click below to start this contest. Note that if you close your 7 | browser, your session will resume from where you left off, but the 8 | timer will NOT stop. 9 | 10 |
11 |
12 | {{markdown-to-html this.model.description}} 13 |
14 | {{#if error}} 15 |
16 | {{error}} 17 |
18 | {{/if}} 19 |
20 | {{#if session.isAuthenticated}} 21 | {{#if started}} 22 | 31 | {{else}} 32 | Please wait while we queue you for the contest 33 | Estimated time: {{left}} seconds 34 | {{/if}} 35 | {{else}} 36 | Please login to attempt this contest. 37 | {{/if}} 38 |
39 |
40 |
41 | -------------------------------------------------------------------------------- /app/pods/contests/contest/contest-result/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | 5 | totalScore: Ember.computed('model',function() { 6 | var sum = 0; 7 | this.get('model.submissionModel').forEach(submission=>{ 8 | sum += parseInt(submission.get('score')); 9 | }); 10 | return sum; 11 | }) 12 | }); 13 | -------------------------------------------------------------------------------- /app/pods/contests/contest/contest-result/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | const { inject: { service }, Route } = Ember; 3 | 4 | export default Ember.Route.extend({ 5 | session: service('session'), 6 | breadCrumb: { 7 | title: 'Result' 8 | }, 9 | model() { 10 | let { contest } = this.modelFor('contests.contest'); 11 | 12 | let userId = this.get('session.data.authenticated.user_id'); 13 | return Ember.RSVP.hash({ 14 | contest, 15 | submissionModel:this.get('store').query('submission', { contest_id: contest.id, user_id: userId, timedContest: true }), 16 | }); 17 | }, 18 | }); 19 | -------------------------------------------------------------------------------- /app/pods/contests/contest/contest-result/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Result

5 | The result of your contest is available 6 |
7 |
8 |

Total Score - {{totalScore}}

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | {{#if model.submissionModel}} {{#each model.submissionModel as |submission index|}} 20 | 21 | 22 | 25 | 26 | 27 | 28 | {{/each}} 29 | {{else}} 30 | {{#each model.contest.problems as |problem index|}} 31 | 32 | 33 | 36 | 37 | 38 | 39 | {{/each}} 40 | {{/if}} 41 | 42 |
#ProblemScoreLanguage
{{sum index 1}} 23 | {{submission.problemName}} 24 | {{decimal-to-whole submission.score}}{{getlang submission.language}}
{{sum index 1}} 34 | {{problem.name}} 35 | 0NA
43 |
44 |
45 |
46 | {{outlet}} -------------------------------------------------------------------------------- /app/pods/contests/contest/ended/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import moment from 'moment'; 3 | export default Ember.Route.extend({ 4 | model() { 5 | let {contest} = this.modelFor('contests.contest'); 6 | return Ember.RSVP.hash({ 7 | contest: contest 8 | }); 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /app/pods/contests/contest/ended/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

{{model.contest.name}}

6 |

{{moment-format model.contest.startTime 'MMMM Do YYYY, hh:mm a' 'X'}} to {{moment-format model.contest.endTime 'MMMM Do YYYY, hh:mm a' 'X'}}

7 |

Contest has Ended.

8 |

Go to practice section.

9 |
10 |
11 |

About This Contest

12 |

{{model.contest.description}}

13 |
14 |
15 |
16 | {{outlet}} 17 | -------------------------------------------------------------------------------- /app/pods/contests/contest/index/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | selectedTag:"All", 5 | attemptDuration: Ember.computed('contest.endTime', 'contest.duration', 'currentAttempt', function () { 6 | const userStartedAt = this.get('currentAttempt.startTime') 7 | const duration = this.get('contest.duration'); 8 | const contestStartTime = this.get('contest.startTime') 9 | const contestEndTime = this.get('contest.endTime') 10 | 11 | if (userStartedAt < contestStartTime) { 12 | return 0 13 | } 14 | 15 | // If contest is over, give total duration (no marks) 16 | if (userStartedAt > contestEndTime) { 17 | return duration 18 | } 19 | 20 | // if time left < duration, only time left is available 21 | if (contestEndTime - userStartedAt < duration) { 22 | return contestEndTime - userStartedAt 23 | } else { 24 | return duration 25 | } 26 | 27 | 28 | //return (duration > timeLeft && timeLeft > 0) ? timeLeft: duration; 29 | //return startTime + duration < endTime ? duration : timeLeft 30 | }), 31 | actions: { 32 | redirectToContest(model) { 33 | //this.get('target.router').refresh() 34 | this.transitionToRoute('contests.contest.contest-result', model.contest.id); 35 | }, 36 | updateSelection(tag) { 37 | this.set('selectedTag',tag); 38 | } 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /app/pods/contests/contest/leaderboard/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend ({ 4 | }) 5 | -------------------------------------------------------------------------------- /app/pods/contests/contest/leaderboard/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | const { inject: { service }, Route } = Ember; 3 | 4 | export default Ember.Route.extend ({ 5 | session: service ('session'), 6 | 7 | breadCrumb: { 8 | title: 'Leaderboard' 9 | }, 10 | 11 | beforeModel (transition) { 12 | // QuickFix: Don't show leaderboards for certain contests. 13 | let { contest } = this.modelFor ('contests.contest') 14 | 15 | if (! contest.get ('showLeaderboard')) { 16 | return transition.abort () 17 | } 18 | }, 19 | 20 | model () { 21 | let { contest } = this.modelFor ('contests.contest') 22 | 23 | let userId = this.get ('session.data.authenticated.user_id') 24 | 25 | return contest 26 | } 27 | }) 28 | -------------------------------------------------------------------------------- /app/pods/contests/contest/leaderboard/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Contest Leaderboard

5 | Refreshing every 10 seconds. 6 |
7 | 8 |
9 |
10 |

{{model.name}}

11 |

{{model.description}}

12 |
13 |
14 | 15 |
16 | {{#problem-leaderboard avatar=true contestId=model.id refreshInterval = 10000}}{{/problem-leaderboard}} 17 |
18 |
19 |
20 | 21 | {{outlet}} 22 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | attemptDuration: Ember.computed('contest.endTime', 'contest.duration', 'currentAttempt', function () { 5 | const userStartedAt = this.get('currentAttempt.startTime') 6 | const duration = this.get('contest.duration'); 7 | const contestStartTime = this.get('contest.startTime') 8 | const contestEndTime = this.get('contest.endTime') 9 | 10 | if (userStartedAt < contestStartTime) { 11 | return 0 12 | } 13 | 14 | // If contest is over, give total duration (no marks) 15 | if (userStartedAt > contestEndTime) { 16 | return duration 17 | } 18 | 19 | // if time left < duration, only time left is available 20 | if (contestEndTime - userStartedAt < duration) { 21 | return contestEndTime - userStartedAt 22 | } else { 23 | return duration 24 | } 25 | 26 | 27 | //return (duration > timeLeft && timeLeft > 0) ? timeLeft: duration; 28 | //return startTime + duration < endTime ? duration : timeLeft 29 | }), 30 | actions: { 31 | redirectToContest (model) { 32 | this.transitionToRoute('contests.contest.contest-result', model.contest.id); 33 | } 34 | } 35 | }); 36 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/editorial/controller.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by siddharth on 28/11/17. 3 | */ 4 | import Ember from 'ember'; 5 | const { inject: { service }, Component } = Ember; 6 | 7 | export default Ember.Controller.extend({ 8 | store: service (), 9 | session: service (), 10 | routing: service ('-routing'), 11 | actions: { 12 | unlock () { 13 | const store = this.get ('store'), 14 | problem = this.get ('model.problem'), 15 | contest = this.get ('model.contest'), 16 | userId = this.get('session').get('data').authenticated.user_id 17 | ; 18 | 19 | const unlockedEditorial = store.createRecord ('unlocked_editorial', { 20 | problem_id: problem.id, 21 | contest_id: contest.id, 22 | user_id: userId 23 | }) 24 | 25 | unlockedEditorial 26 | .save () 27 | .then (() => this.send ('editorialUnlocked')) 28 | .catch ((error) => { 29 | this.set ('error', 'Could not fetch editorial! It is likely that an editorial does not exist for this problem, or that the contest does not have hints enabled. If you believe this to be in error, please contact us at support@codingblocks.com.') 30 | }) 31 | } 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/editorial/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model () { 5 | let contest = this.modelFor('contests.contest').contest; 6 | let editorial = null; 7 | let problem = this.modelFor('contests/contest/problem').problem; 8 | 9 | editorial = this.store.queryRecord ('editorial' , { p_id: problem.id, contest_id: contest.id }) 10 | .catch (() => (void 0)) 11 | 12 | return Ember.RSVP.hash({ 13 | editorial: editorial, 14 | contest: contest, 15 | problem: problem 16 | }); 17 | }, 18 | 19 | actions: { 20 | editorialUnlocked () { 21 | this.refresh () 22 | } 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/editorial/template.hbs: -------------------------------------------------------------------------------- 1 | {{#if model.contest.allowEditorialUnlocks}} 2 | {{#if model.editorial}} 3 | {{#editorial-view model=model.editorial}}{{/editorial-view}} 4 | {{else}} 5 | {{#if error}} 6 |

{{error}}

7 | {{else}} 8 |
9 |

Note: You will not be awarded any points for 10 | solutions to this particular problem in the contest once you 11 | unlock the editorial!

12 |
13 | 14 | {{/if}} 15 | {{/if}} 16 | {{else}} 17 |

Editorials are locked for this contest!

18 | {{/if}} 19 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/index/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | actions: { 5 | redirectToContest(model) { 6 | //this.get('target.router').refresh() 7 | this.transitionToRoute('contests.contest.contest-result', model.contest.id); 8 | }, 9 | refreshModel(model) { 10 | var problem_id = model.problem.id; 11 | var contest_id = model.contest.id; 12 | this.get('store').queryRecord('problem', { problem_id, contest_id }).then(fetchedProblem => { 13 | this.set('model.problem', fetchedProblem); 14 | }); 15 | } 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model(){ 5 | return this.modelFor('contests/contest/problem'); 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/index/template.hbs: -------------------------------------------------------------------------------- 1 | {{#problem-parent problem=model.problem contestId=model.contest.id 2 | userCount=model.meta.userCount onComplete=(action 'redirectToContest' model) contest=model.contest 3 | currentAttempt=model.currentAttempt refreshModel = (action 'refreshModel' model) 4 | parentRoute='contests.contest.problem'}} 5 | {{/problem-parent}} 6 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/route.js: -------------------------------------------------------------------------------- 1 | 2 | import Ember from 'ember'; 3 | 4 | const { inject: { service } } = Ember; 5 | 6 | var lang_codes = { 7 | "c": "C", 8 | "cpp": "C++", 9 | "py2": "Python", 10 | "java": "Java" 11 | }; 12 | 13 | export default Ember.Route.extend({ 14 | session: Ember.inject.service('session'), 15 | currentAttemptService: service('current-attempt'), 16 | breadCrumb: Ember.Object.create({ 17 | title: 'Problem' 18 | }), 19 | model(params) { 20 | let contest = this.modelFor('contests.contest').contest; 21 | let store = this.get ('store') 22 | let editorial = null; 23 | let problem_id = params.problem_id; 24 | let problem = null; 25 | let problems = contest.get('problems'); 26 | 27 | // TODO: Block if this fails 28 | let problemAttempt = store.createRecord ('problemAttempt', { 29 | contestId: contest.id, 30 | problemId: problem_id 31 | }).save () 32 | 33 | problems.forEach((p) => { 34 | if(problem_id == p.id) { 35 | problem = this.get('store').queryRecord('problem', {problem_id, contest_id: contest.id}); 36 | } 37 | }); 38 | 39 | return Ember.RSVP.hash({ 40 | editorial:editorial, 41 | lang_codes: lang_codes, 42 | problem: problem, 43 | contest: contest, 44 | problem_id: params.problem_id, 45 | currentAttempt: this.get('currentAttemptService').getCurrentAttempts(contest.id) 46 | }); 47 | }, 48 | afterModel(model, transition) { 49 | const { currentAttempt, contest,problem } = model; 50 | this.set('breadCrumb.title',problem.get('name')); 51 | 52 | if ( Ember.isNone(contest.get('duration')) ) { 53 | return 54 | } 55 | 56 | if ( Ember.isNone(currentAttempt.data) ) { 57 | this.transitionTo('contests.contest.attempt', model.contest.id) 58 | } 59 | }, 60 | setupController (controller, model) { 61 | controller.set('contest', model.contest) 62 | controller.set('currentAttempt', model.currentAttempt) 63 | this._super(...arguments) 64 | } 65 | }); 66 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/submissions/controller.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by siddharth on 28/11/17. 3 | */ 4 | import Ember from 'ember'; 5 | 6 | export default Ember.Controller.extend({ 7 | 8 | }); 9 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/submissions/route.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by siddharth on 28/11/17. 3 | */ 4 | import Ember from 'ember'; 5 | 6 | export default Ember.Route.extend({ 7 | model(params) { 8 | let contest = this.modelFor('contests.contest').contest; 9 | let problem_id = this.modelFor('contests/contest/problem').problem_id; 10 | let problem = this.get('store').queryRecord('problem', {problem_id, contest_id: contest.id}); 11 | return Ember.RSVP.hash({ 12 | problem: problem, 13 | contest: contest, 14 | problem_id: params.problem_id 15 | }); 16 | } 17 | }); 18 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/submissions/template.hbs: -------------------------------------------------------------------------------- 1 | {{#problem-my-submissions submissions=model.problem.submissions}}{{/problem-my-submissions}} -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/testcases/controller.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by siddharth on 28/11/17. 3 | */ 4 | import Ember from 'ember'; 5 | const { inject: { service }, Component } = Ember; 6 | 7 | export default Ember.Controller.extend({ 8 | store: service (), 9 | session: service (), 10 | routing: service ('-routing'), 11 | actions: { 12 | download () { 13 | console.log ('TODO') 14 | }, 15 | 16 | unlock () { 17 | const store = this.get ('store'), 18 | problem = this.get ('model.problem'), 19 | contest = this.get ('model.contest'), 20 | userId = this.get('session').get('data').authenticated.user_id 21 | ; 22 | 23 | // const existingTestcase = store.queryRecord ('unlocked_testcase', { 24 | // p_id: problem.id, 25 | // contest_id: contest.id 26 | // }) 27 | 28 | const unlockedTestcase = store.createRecord ('unlocked_testcase', { 29 | problem_id: problem.id, 30 | contest_id: contest.id, 31 | user_id: userId 32 | }) 33 | 34 | unlockedTestcase 35 | .save () 36 | .then (() => this.send ('testcaseUnlocked')) 37 | .catch ((error) => { 38 | this.set ('error', 'Could not unlock testcases for downloading! It is likely that downloading is disabled for this contest. If you believe this to be in error, please contact us at support@codingblocks.com.') 39 | }) 40 | } 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/testcases/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model () { 5 | let contest = this.modelFor('contests.contest').contest; 6 | let unlockedTestcase = null; 7 | let problem = this.modelFor('contests/contest/problem').problem; 8 | unlockedTestcase = this.get ('store').queryRecord ('unlocked_testcase' , { p_id: problem.id, contest_id: contest.id }) 9 | .catch ((e) => (console.log (e))) 10 | 11 | return Ember.RSVP.hash({ 12 | unlockedTestcase: unlockedTestcase, 13 | contest: contest, 14 | problem: problem 15 | }); 16 | }, 17 | 18 | actions: { 19 | testcaseUnlocked () { 20 | this.refresh () 21 | } 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /app/pods/contests/contest/problem/testcases/template.hbs: -------------------------------------------------------------------------------- 1 | {{#if model.contest.allowTestcaseUnlocks}} 2 | {{#if model.unlockedTestcase}} 3 | {{#each model.unlockedTestcase.urls as |testcase index|}} 4 |
5 | Download Input {{sum index 1}} 7 | Download Output {{sum index 1}} 9 |
10 | {{/each}} 11 | {{else}} 12 | {{#if error}} 13 |

{{error}}

14 | {{else}} 15 |
16 |

Note: You will not be awarded any points for 17 | solutions to this particular problem in the contest once you 18 | unlock the testcases!

19 |
20 | 21 | {{/if}} 22 | {{/if}} 23 | {{else}} 24 |

Testcase downloads are locked for this contest!

25 | {{/if}} 26 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz-attempts/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz-attempts/index/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | Attempt History 6 |
7 |
8 |
9 | {{#link-to 'contests.contest' model.contest.id class="btn btn-red"}} 10 | Back to Contest 11 | {{/link-to}} 12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 20 |
21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {{#each model.attempts as |attempt index|}} 32 | 33 | 34 | 35 | 40 | 41 | {{/each}} 42 | 43 |
AttemptScore
{{index}}{{attempt.result.score}} 36 | {{#link-to 'contests.contest.quiz-attempts.show' model.contest.id model.quiz.id attempt.id class="btn btn-red"}} 37 | View 38 | {{/link-to}} 39 |
44 |
45 |
46 |
47 | 48 | 49 | 50 | 75 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz-attempts/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | session: Ember.inject.service('session'), 5 | notifications: Ember.inject.service ('toast'), 6 | 7 | beforeModel (transition) { 8 | let session = this.get ('session'), 9 | notifications = this.get ('notifications') 10 | ; 11 | 12 | if (! session.get ('isAuthenticated')) { 13 | transition.abort () 14 | notifications.error ('You must be logged in to view that!') 15 | 16 | return this.transitionTo ('contests.index') 17 | } 18 | 19 | return { } 20 | }, 21 | 22 | model (params) { 23 | const store = this.get ('store') 24 | const { contest } = this.modelFor ('contests.contest') 25 | const quiz = store.findRecord ('quiz', params.quiz_id, { reload: true }) 26 | .then (quiz => { 27 | quiz.set ('contest', contest) 28 | 29 | return quiz 30 | }) 31 | 32 | const attempts = store.query ('quiz-attempt', { quiz_id: params.quiz_id }) 33 | 34 | return Ember.RSVP.hash ({ 35 | contest, 36 | quiz, 37 | attempts 38 | }) 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz-attempts/show/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model (params) { 5 | const store = this.get ('store') 6 | const { contest, quiz } = this.modelFor ('contests.contest.quiz-attempts') 7 | const attempt = store.findRecord ('quiz-attempt', params.attempt_id) 8 | 9 | return Ember.RSVP.hash ({ 10 | contest, 11 | quiz, 12 | attempt 13 | }) 14 | }, 15 | 16 | afterModel (model) { 17 | // const store = this.get ('store') 18 | // const questionIds = model.quiz.hasMany ('questions').ids () 19 | // 20 | // const questions = Promise.all (questionIds.map (id => { 21 | // const record = store.findRecord ('question', id) 22 | // return record 23 | // })) 24 | // 25 | // model.questions = questions 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz-attempts/show/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | Attempt 6 |
7 |
8 |
9 | {{#link-to 'contests.contest' model.contest.id class="btn btn-red"}} 10 | Back to Contest 11 | {{/link-to}} 12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 20 |
21 |
22 | {{#each model.attempt.quizSubmissions as |submission|}} 23 | {{quiz-result submission=submission}} 24 | {{/each}} 25 |
26 |
27 |
28 | 29 | 30 | 31 | 56 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz-attempts/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz/attempts/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz/attempts/index/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz/attempts/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model (params) { 5 | let store = this.get ('store') 6 | let quiz = this.modelFor ('contests.contest.quiz') 7 | 8 | return Ember.RSVP.hash ({ 9 | attempt: store.query ('quiz-attempt', { 10 | quizId: quiz.id 11 | }), 12 | quiz: quiz 13 | }) 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz/attempts/show/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model (params) { 5 | let store = this.get ('store') 6 | let quiz = this.modelFor ('contests.contest.quiz') 7 | 8 | return Ember.RSVP.hash ({ 9 | attempt: store.findRecord ('quiz-attempt', params.attempt_id), 10 | quiz: quiz 11 | }) 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz/attempts/show/template.hbs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/app/pods/contests/contest/quiz/attempts/show/template.hbs -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz/attempts/template.hbs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/app/pods/contests/contest/quiz/attempts/template.hbs -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | session: Ember.inject.service('session'), 5 | notifications: Ember.inject.service ('toast'), 6 | currentContest: Ember.inject.service('current-contest'), 7 | 8 | beforeModel (transition) { 9 | const session = this.get ('session') 10 | const notifications = this.get ('notifications') 11 | 12 | if (! session.get ('isAuthenticated')) { 13 | transition.abort () 14 | notifications.error ('You must be logged in to view that!') 15 | 16 | this.transitionTo ('contests.index') 17 | } 18 | }, 19 | 20 | async model (params) { 21 | const store = this.get ('store') 22 | const contest = this.get('currentContest').getContest() 23 | const quiz = await store.findRecord('quiz', params.quiz_id, {reload: true}) 24 | quiz.set('contest', contest) 25 | 26 | return quiz 27 | } 28 | }); 29 | -------------------------------------------------------------------------------- /app/pods/contests/contest/quiz/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/contests/contest/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from 'hack/config/environment'; 3 | 4 | const { inject: { service } } = Ember; 5 | 6 | export default Ember.Route.extend({ 7 | currentContest: service('current-contest'), 8 | session: service(), 9 | 10 | model (params) { 11 | const contestId = params.contest_id; 12 | const contest = this.get('store').findRecord('contest', contestId) 13 | return Ember.RSVP.hash({ 14 | contest 15 | }) 16 | }, 17 | 18 | afterModel(model) { 19 | this.get('currentContest').setContest(model.contest) 20 | }, 21 | 22 | actions: { 23 | error(error, transition) { 24 | if (!this.get('session.isAuthenticated')) { 25 | const redirectionPath = window.location.pathname.replace(/^\/|\/$/g, ''); 26 | localStorage.setItem('redirection-path', redirectionPath); 27 | window.location = "https://account.codingblocks.com/oauth/authorize?" + 28 | "response_type=code" + 29 | "&client_id=" + config.oneauthClientId + 30 | "&redirect_uri=" + config.publicUrl 31 | return 32 | } 33 | const contestId = transition.params['contests.contest'].contest_id 34 | this.transitionTo('contests.denied', contestId) 35 | } 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /app/pods/contests/contest/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} -------------------------------------------------------------------------------- /app/pods/contests/denied/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model (params) { 5 | return params 6 | }, 7 | 8 | actions: { 9 | goBack (contest_id) { 10 | this.transitionTo ('contests.contest', contest_id) 11 | } 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /app/pods/contests/denied/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | Access Denied 6 |
7 |
8 |
9 |
10 |
11 | 12 |
13 |

14 | You do not have permission to access that contest! If you think this 15 | is an error, please drop us an email at 16 | support@codingblocks.com 17 | 18 |

19 |

20 | If you have just been granted access, please click the button below to 21 | try again. 22 |

23 | 24 | 25 |
26 |
27 | -------------------------------------------------------------------------------- /app/pods/contests/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | breadCrumb: { 5 | title: 'All Contests' 6 | }, 7 | 8 | serverTime: Ember.inject.service (), 9 | 10 | model: function () { 11 | var activeContests = []; 12 | var upcomingContests = []; 13 | var previousContests = []; 14 | 15 | const contestTypes = this.get('store').query('contest', {custom: {ext: 'url', url: 'public'}}).then((contest) => { 16 | var presentDate = this.get ('serverTime').getUnixTime (); 17 | contest.forEach(function (element) { 18 | if (element.get('startTime') <= presentDate && element.get('endTime') >= presentDate) { 19 | activeContests.pushObject(element); 20 | } else if (element.get('startTime') > presentDate) { 21 | upcomingContests.pushObject(element); 22 | } else { 23 | previousContests.pushObject(element); 24 | } 25 | }) 26 | }); 27 | 28 | return contestTypes.then( ()=> { 29 | return Ember.RSVP.hash({ 30 | activeContests : activeContests, 31 | upcomingContests: upcomingContests, 32 | previousContests: previousContests 33 | }); 34 | }); 35 | 36 | }, 37 | 38 | setupController(controller, model) { 39 | this._super(...arguments); 40 | Ember.set(controller, 'activeContests', model.activeContests); 41 | Ember.set(controller, 'upcomingContests', model.upcomingContests); 42 | Ember.set(controller, 'previousContests', model.previousContests); 43 | } 44 | }); 45 | -------------------------------------------------------------------------------- /app/pods/contests/index/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Contests

5 | Take these challenges and prove your mettle 6 |
7 |
8 |
9 |
10 | 11 | {{#if (not-eq activeContests.length 0)}} 12 |
13 |

ACTIVE CONTESTS

14 |
15 |
16 |
17 | {{#each activeContests as |contest|}} 18 | {{#contest-view showPoints=true link='contests.contest' 19 | contest=contest class="contestCardWrapper"}} {{/contest-view}} 20 | {{/each}} 21 |
22 |
23 | {{/if}} 24 | 25 | {{#if (not-eq upcomingContests.length 0)}} 26 |
27 |

UPCOMING CONTESTS

28 |
29 |
30 |
31 | {{#each upcomingContests as |contest|}} 32 | {{#contest-view showPoints=true link='contests.contest' contest=contest class="contestCardWrapper"}} {{/contest-view}} 33 | {{/each}} 34 |
35 |
36 | {{/if}} 37 | 38 | {{#if (not-eq previousContests.length 0)}} 39 |
40 |

PREVIOUS CONTESTS

41 |
42 |
43 |
44 | {{#each previousContests as |contest|}} 45 | {{#contest-view link='contests.contest' showPoints=true contest=contest archived=true class="contestCardWrapper"}}{{/contest-view}} 46 | {{/each}} 47 |
48 |
49 | {{/if}} 50 | 51 |
52 |
53 |
54 |
55 |
56 | -------------------------------------------------------------------------------- /app/pods/contests/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model () { 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /app/pods/contests/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} -------------------------------------------------------------------------------- /app/pods/contests/upcoming/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import moment from 'moment'; 3 | export default Ember.Route.extend({ 4 | model(params) { 5 | let contest = this.get('store').findRecord('contest', params.contest_id); 6 | return Ember.RSVP.hash({ 7 | contest: contest 8 | }); 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /app/pods/contests/upcoming/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

{{model.contest.name}}

6 |

{{moment-format model.contest.startTime 'MMMM Do YYYY, hh:mm a' 'X'}} to {{moment-format model.contest.endTime 'MMMM Do YYYY, hh:mm a' 'X'}}

7 |

Contest Starts In

8 |

{{#live-reload contest=model.contest}} {{/live-reload}}

9 |
10 |
11 |

About This Contest

12 |

{{markdown-to-html model.contest.description}}

13 |
14 |
15 |
16 | {{outlet}} 17 | -------------------------------------------------------------------------------- /app/pods/courses/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | breadCrumb: { 5 | title: "Courses" 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /app/pods/courses/template.hbs: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |

All Courses

6 | Courses we offer 7 |
8 | 9 |
10 |
11 | -------------------------------------------------------------------------------- /app/pods/dcb/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import moment from 'moment'; 3 | 4 | export default Ember.Route.extend({ 5 | breadCrumb: { 6 | title: "Daily CodeBytes" 7 | }, 8 | model() { 9 | let mainProblem = []; 10 | let otherProblems = []; 11 | let day = moment(moment().unix(), 'X').format("YYYYMMDD"); 12 | 13 | const dailycbTypes = this.get('store').query('dailycb', {count: 7, day}).then(function (problem) { 14 | problem.forEach(function (element, index) { 15 | if (index == 0) { 16 | mainProblem.pushObject(element); 17 | } else { 18 | otherProblems.pushObject(element); 19 | } 20 | }); 21 | }); 22 | 23 | return dailycbTypes.then( () => { 24 | return Ember.RSVP.hash({ 25 | mainProblem: mainProblem, 26 | otherProblems: otherProblems 27 | }); 28 | }); 29 | 30 | }, 31 | 32 | setupController(controller, model) { 33 | this._super(...arguments); 34 | Ember.set(controller, 'mainProblem', model.mainProblem); 35 | Ember.set(controller, 'otherProblems', model.otherProblems); 36 | Ember.set(controller, 'leaderboard', model.leaderboard); 37 | } 38 | }); 39 | -------------------------------------------------------------------------------- /app/pods/dcb/index/template.hbs: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |

This Week's Code Bytes

6 | One question each day, to see what you are made of 7 |
8 | {{#each mainProblem as |dailycb|}} 9 | {{#current-cb-card dailycb = dailycb }}{{/current-cb-card}} 10 | {{/each}} 11 |
12 |
13 |
14 |
15 |

PREVIOUS CODE BYTES

16 |
17 |
18 |
19 | 20 | {{#each otherProblems as |dailycb|}} 21 | {{#problem-view dailycb=dailycb archived=true link='dcb.weekly-problem.index' problem=dailycb.problem.content class="problemCardWrapper"}}{{/problem-view}} 22 | {{/each}} 23 | 24 |
25 |
26 |
27 |
28 |
29 |
30 |
-------------------------------------------------------------------------------- /app/pods/dcb/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | 5 | }); 6 | -------------------------------------------------------------------------------- /app/pods/dcb/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} -------------------------------------------------------------------------------- /app/pods/dcb/weekly-problem/index/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | actions:{ 5 | refreshModel(){ 6 | var model = this.get('model'); 7 | var p_id = model.p_id; 8 | this.set('model.dailycb',this.get('store').queryRecord('dailycb', {p_id})); 9 | } 10 | } 11 | }); -------------------------------------------------------------------------------- /app/pods/dcb/weekly-problem/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | var lang_codes = { 4 | "c": "C", 5 | "cpp": "C++", 6 | "py2": "Python", 7 | "java": "Java" 8 | }; 9 | 10 | export default Ember.Route.extend({ 11 | session: Ember.inject.service('session'), 12 | breadCrumb: { 13 | title: 'Description' 14 | }, 15 | model() { 16 | let p_id = this.modelFor('dcb/weekly-problem').p_id; 17 | return Ember.RSVP.hash({ 18 | lang_codes: lang_codes, 19 | dailycb: this.get('store').queryRecord('dailycb', {custom: {ext: 'url', url: p_id}}), 20 | p_id : p_id 21 | }); 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /app/pods/dcb/weekly-problem/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | store: Ember.inject.service(), 5 | breadCrumb: { 6 | title: 'Problem' 7 | }, 8 | model(params) { 9 | const problemAttempt = this.get('store').createRecord ('problemAttempt', { 10 | contestId: 0, 11 | problemId: params.problem_id 12 | }).save () 13 | return Ember.RSVP.hash({ 14 | problemAttempt, 15 | p_id: params.problem_id, 16 | dailycb: this.get('store').queryRecord('dailycb', {custom: {ext: 'url', url: params.problem_id}}) 17 | }); 18 | }, 19 | afterModel(model, transition) { 20 | const {dailycb} = model; 21 | this.set('breadCrumb.title',dailycb.get('problem.name')); 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /app/pods/dcb/weekly-problem/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} -------------------------------------------------------------------------------- /app/pods/help/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model() { 5 | return Ember.RSVP.hash({ 6 | dailyCBs: this.get('store').query('dailycb', {count: 4}), 7 | contests: this.get('store').query('contest', {custom : { ext : 'url',url : 'public'} }), 8 | }); 9 | }, 10 | 11 | setupController(controller, model) { 12 | this._super(...arguments); 13 | const blocksOfCode = model.contests.filter(contest => { 14 | if (contest.get('name').toLowerCase().match('blocks of code')) { 15 | if (!contest.get('isFinished')) { 16 | return true; 17 | } 18 | } 19 | }).pop(); 20 | let ans = false; 21 | ans = model.contests.filter(contest => { 22 | if (!contest.get('isFinished')) { 23 | return true; 24 | } 25 | }); 26 | controller.set('anyActiveContest',ans); 27 | controller.set('blocksOfCode', blocksOfCode); 28 | } 29 | }); 30 | -------------------------------------------------------------------------------- /app/pods/info/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import GetErrorDetail from '../../utils/get-error-details' 3 | export default Ember.Route.extend({ 4 | breadCrumb: { 5 | title: 'Information' 6 | }, 7 | model (params) { 8 | let errorId = params.id; 9 | return Ember.RSVP.hash({ 10 | error: GetErrorDetail(errorId) 11 | }) 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /app/pods/info/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

{{{model.error}}}

5 |
6 |
7 |
8 | -------------------------------------------------------------------------------- /app/pods/loading/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/loading/template.hbs: -------------------------------------------------------------------------------- 1 | {{!-- 2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |

Please wait...

15 |
16 |
17 |

LOADING........

18 | 19 | --}} 20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | -------------------------------------------------------------------------------- /app/pods/logout/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | session: Ember.inject.service(), 5 | 6 | beforeModel () { 7 | this.get('session').invalidate() 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /app/pods/logout/template.hbs: -------------------------------------------------------------------------------- 1 | // TODO: have some css-loader to hide the ugly page -------------------------------------------------------------------------------- /app/pods/practice/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | breadCrumb: { 5 | title: 'Practice Section' 6 | }, 7 | 8 | model: function () { 9 | var practiceContests = []; 10 | 11 | const practiceTypes = this.get('store').findAll('practice_category').then(function (practice) { 12 | practice.forEach(function (element) { 13 | practiceContests.pushObject(element); 14 | }); 15 | }); 16 | return practiceTypes.then( ()=>{ 17 | return Ember.RSVP.hash({ 18 | practiceContests: practiceContests 19 | }); 20 | }); 21 | }, 22 | 23 | setupController(controller, model) { 24 | this._super(...arguments); 25 | Ember.set(controller, 'practiceContests', model.practiceContests); 26 | } 27 | }); 28 | -------------------------------------------------------------------------------- /app/pods/practice/index/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Practice Section

5 | Take these challenges and improve your skills 6 |
7 |
8 |
9 |
10 | 11 | {{#if (not-eq activeContests.length 0)}} 12 |
13 |

CATEGORIES

14 |
15 |
16 |
17 | {{#each practiceContests as |contest|}} 18 | {{#contest-view link='practice.problems' contest=contest.contests noEndTime=true problem-count=contest.problemCount class="contestCardWrapper"}} {{/contest-view}} 19 | {{/each}} 20 |
21 |
22 | {{/if}} 23 | 24 |
25 |
26 |
27 |
28 |
29 | -------------------------------------------------------------------------------- /app/pods/practice/problems/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | const { inject: { service } } = Ember; 4 | 5 | export default Ember.Route.extend({ 6 | breadCrumb:Ember.Object.create({ 7 | title: 'Problems' 8 | }), 9 | model() { 10 | let {contest} = this.modelFor('practice.problems'); 11 | return Ember.RSVP.hash({ 12 | contest: contest, 13 | }); 14 | }, 15 | afterModel(model, transition){ 16 | const { contest } = model; 17 | this.set('breadCrumb.title',contest.get('name')); 18 | }, 19 | setupController: function (controller, model) { 20 | this._super(controller, model); 21 | let contest = model.contest; 22 | let contestId = contest.get('id'); 23 | }, 24 | }); 25 | -------------------------------------------------------------------------------- /app/pods/practice/problems/index/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

All Problems

6 | Solve these problem and prove yourself 7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | {{#each model.contest.problems as |problem|}} 15 | {{#problem-view link='practice.problems.problem.index' problem=problem class="problemCardWrapper"}}{{/problem-view}} 16 | {{/each}} 17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | -------------------------------------------------------------------------------- /app/pods/practice/problems/problem/index/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | actions: { 5 | redirectToContest(model) { 6 | //this.get('target.router').refresh() 7 | this.transitionToRoute('contests.contest.contest-result', model.contest.id); 8 | }, 9 | refreshModel(){ 10 | var model = this.get('model'); 11 | var problem_id = model.problem.id; 12 |       var contest_id = model.contest.id; 13 | this.get('store').queryRecord('problem', {problem_id, contest_id: contest_id}).then(function(fetchedProblem){ 14 | this.set('model.problem', fetchedProblem); 15 | }); 16 | } 17 | 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /app/pods/practice/problems/problem/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | session: Ember.inject.service('session'), 5 | breadCrumb: Ember.Object.create({ 6 | title: 'Problem' 7 | }), 8 | model() { 9 | let contest = this.modelFor('practice.problems').contest; 10 | let problem_id = this.modelFor('practice.problems.problem').problem_id; 11 | return Ember.RSVP.hash({ 12 | problem: this.get('store').queryRecord('problem', {problem_id, contest_id: contest.id}), 13 | contest: contest 14 | }); 15 | }, 16 | afterModel(model,transtion) { 17 | const { problem } = model; 18 | this.set('breadCrumb.title',problem.get('name')); 19 | } 20 | }); 21 | -------------------------------------------------------------------------------- /app/pods/practice/problems/problem/index/template.hbs: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

Problem

6 | Solve this problem and get ranked among your peers 7 |
8 |
9 |
10 |
11 |
12 |
13 | 14 | 20 | 21 |
22 |
23 | {{#problem-parent problem=model.problem leaderboard=model.leaderboard contestId=model.contest.id 24 | userCount=model.meta.userCount onComplete=(action 'redirectToContest' model) contest=model.contest 25 | currentAttempt=model.currentAttempt 26 | parentRoute='practice.problems.problem' 27 | refreshModel = (action 'refreshModel')}} 28 | {{/problem-parent}} 29 |
30 |
31 | {{#problem-my-submissions submissions=model.problem.submissions}}{{/problem-my-submissions}} 32 |
33 |
34 |
35 |
36 |
37 | {{#code-editor contestId=model.contest.id problem=model.problem}}{{/code-editor}} 38 |
39 |
40 |
41 |
42 |
43 |

Best Submission

44 |
45 |
46 | {{#problem-leaderboard language=true hideScore=true contestId=model.contest.id problemId=model.problem.id}}{{/problem-leaderboard}} 47 |
48 |
49 |
50 |
51 |
52 |
53 | -------------------------------------------------------------------------------- /app/pods/practice/problems/problem/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model(params) { 5 | return {problem_id: params.problem_id}; 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /app/pods/practice/problems/problem/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/practice/problems/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Env from '../../../config/environment'; 3 | 4 | const { inject: { service }, Route } = Ember; 5 | 6 | export default Ember.Route.extend({ 7 | currentContest: service('current-contest'), 8 | model (params) { 9 | this.get('currentContest').setContest(params.contest_id) 10 | let contestId = params.contest_id; 11 | return Ember.RSVP.hash({ 12 | contest: this.get('store').findRecord('contest', contestId) 13 | }); 14 | } 15 | }); 16 | 17 | -------------------------------------------------------------------------------- /app/pods/practice/problems/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/practice/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/practice/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/solution-stub/model.js: -------------------------------------------------------------------------------- 1 | import DS from 'ember-data'; 2 | 3 | export default DS.Model.extend({ 4 | language: DS.attr(), 5 | body: DS.attr(), 6 | problem: DS.belongsTo('problem') 7 | }); 8 | -------------------------------------------------------------------------------- /app/pods/submission/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | breadCrumb: { 5 | title: "Submission" 6 | }, 7 | actions: { 8 | back: function () { 9 | window.history.back(); 10 | } 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /app/pods/tracks/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend ({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/tracks/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/tracks/index/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/tracks/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /app/pods/tracks/show/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | actions: { 5 | openIfUnlocked (level, contest) { 6 | if (level.get ('unlocked')) { 7 | this.transitionToRoute ('contests.contest', contest.id) 8 | } 9 | } 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /app/pods/tracks/show/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model (params) { 5 | return this.get ('store') 6 | .findRecord ('track', params.id, { reload: true }) 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /app/pods/tracks/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} 2 | -------------------------------------------------------------------------------- /app/pods/users/index/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | model() { 5 | return this.store.findAll('user'); 6 | } 7 | }); 8 | -------------------------------------------------------------------------------- /app/pods/users/index/template.hbs: -------------------------------------------------------------------------------- 1 | {{#each model as |user|}} 2 |

{{user.name}}

3 | {{/each}} 4 | {{outlet}} 5 | -------------------------------------------------------------------------------- /app/pods/users/route.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 6/8/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | export default Ember.Route.extend({ 8 | breadCrumb: { 9 | title: "User" 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /app/pods/users/template.hbs: -------------------------------------------------------------------------------- 1 | {{outlet}} -------------------------------------------------------------------------------- /app/pods/users/user/controller.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Controller.extend({ 4 | session: Ember.inject.service('session'), 5 | toast: Ember.inject.service(), 6 | actions: { 7 | addBuser(userId){ 8 | this.get('store').createRecord('buser',{ 9 | batchCodeText:this.get('batchCode'), 10 | userId:userId, 11 | }).save().then(result=> { 12 | const toast = this.get('toast'); 13 | toast.info('Batch Code Has Been Added.'); 14 | //TODO: Fix this - New batch code does not appear until refreshed page. 15 | window.location.reload(true); 16 | }) 17 | .catch(error => { 18 | const toast = this.get('toast'); 19 | if(error.errors[0].name === 'SequelizeUniqueConstraintError') { 20 | toast.warning('Batch Code Already Exists!', 'Warning'); 21 | } else if (error.errors[0] === 'Invalid Batch Code.') { 22 | toast.error(error.errors[0], 'Error'); 23 | } else { 24 | toast.info('Unable To Add Batch Code!', 'Error'); 25 | } 26 | }); 27 | } 28 | }, 29 | }); 30 | -------------------------------------------------------------------------------- /app/pods/users/user/route.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Route.extend({ 4 | breadCrumb: { 5 | title: "Profile" 6 | }, 7 | model(params) { 8 | let contests = Ember.A([]); 9 | let fetchedSubmissions = Ember.A([]); 10 | let busers = this.store.query('buser', {u_id:params.user_id}); 11 | let submissionQuery = this.store.query('submission', { filter: { user_id: params.user_id, profile: true } }); 12 | return submissionQuery.then(submissions => { 13 | 14 | submissions.forEach(submission => { 15 | fetchedSubmissions.push(submission); 16 | let contest = contests.find((contest) => { 17 | return contest.get('id') === submission.get('contest').get('id'); 18 | }); 19 | if (!contest) { 20 | contest = submission.get('contest'); 21 | contests.push(contest); 22 | } 23 | }); 24 | 25 | fetchedSubmissions = submissions; 26 | 27 | return Ember.RSVP.hash({ 28 | user: this.store.findRecord('user', params.user_id), 29 | fetchedSubmissions, 30 | busers, 31 | contests 32 | }); 33 | }); 34 | }, 35 | setupController(controller, model) { 36 | this._super(...arguments); 37 | Ember.set(controller, 'busers', model.busers); 38 | Ember.set(controller, 'user', model.user); 39 | Ember.set(controller, 'submission', model.fetchedSubmissions); 40 | Ember.set(controller, 'contests', model.contests); 41 | } 42 | }); 43 | -------------------------------------------------------------------------------- /app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /app/services/api.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by abhishek on 30/06/17. 3 | */ 4 | 'use strict'; 5 | 6 | import Ember from 'ember'; 7 | import env from '../config/environment' 8 | import AjaxService from 'ember-ajax/services/ajax'; 9 | 10 | export default AjaxService.extend({ 11 | session: Ember.inject.service(), 12 | host: env.apiEndpoint, 13 | contentType: 'application/json; charset=utf-8', 14 | namespace: '/api', 15 | headers: Ember.computed('session.data.authenticated.auth_token', { 16 | get() { 17 | let headers = {}; 18 | const authData = this.get('session.data.authenticated'); 19 | headers['oauth-id'] = authData.oauth_id; 20 | headers['access-token'] = authData.auth_token; 21 | headers['user-id'] = authData.user_id; 22 | headers['client'] = 'hacker-blocks'; 23 | return headers; 24 | } 25 | }) 26 | }); 27 | -------------------------------------------------------------------------------- /app/services/chat.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 6/22/17. 3 | */ 4 | 5 | 6 | import Ember from 'ember'; 7 | import config from '../config/environment'; 8 | 9 | export default Ember.Service.extend({ 10 | socket: null, 11 | init(userId) { 12 | this.socket = io(config.chatEndpoint); 13 | this.socket.on('connect', () => { 14 | this.socket.emit('join', {user_id: userId}); 15 | }) 16 | }, 17 | publishMessage(data) { 18 | this.socket.emit('new message', {data:data}); 19 | }, 20 | addChatListener(listener) { 21 | this.socket.on('message', (data) => { 22 | listener(data); 23 | }); 24 | }, 25 | addPresenceListener(listener) { 26 | this.socket.on('join', (data) => { 27 | listener.join(data); 28 | }); 29 | this.socket.on('leave', (data) => { 30 | listener.leave(data); 31 | }); 32 | } 33 | }); 34 | -------------------------------------------------------------------------------- /app/services/current-attempt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 5/3/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | import Moment from 'npm:moment'; 7 | 8 | const { inject: { service } } = Ember; 9 | 10 | export default Ember.Service.extend({ 11 | store: service(), 12 | serverTime: service('server-time'), 13 | 14 | async getCurrentAttempts(contestId) { 15 | const contestAttempt = this 16 | .get('store') 17 | .peekAll('ContestAttempt') 18 | .find(attempt => attempt.get('contestId') == contestId && attempt.get('endTime') > this.get('serverTime').getUnixTime()) 19 | if (!contestAttempt) { 20 | return this.get('store').queryRecord('ContestAttempt', { contestId: contestId }) 21 | } 22 | return Promise.resolve(contestAttempt) 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /app/services/current-contest.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.Service.extend({ 4 | setContest(contest){ 5 | this.set('contest', contest) 6 | }, 7 | getContest(){ 8 | return this.get('contest') 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /app/services/current-user.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 12/01/17. 3 | */ 4 | 5 | import Ember from 'ember'; 6 | 7 | const { inject: { service }, isEmpty, RSVP } = Ember; 8 | 9 | export default Ember.Service.extend({ 10 | data: null, 11 | session: service('session'), 12 | store: service(), 13 | 14 | load () { 15 | if (this.get('session.isAuthenticated')) { 16 | let token = this.get('session.data.authenticated.jwt'); 17 | return this.get('store').queryRecord('user', { custom : {ext : 'url' , url : 'me' } , token: token}); 18 | } 19 | }, 20 | 21 | // Returns a hash of authentication headers suitable for injection into $.ajax 22 | // requests, provided the user is logged in. 23 | getAuthHeaders () { 24 | if (this.get('session.isAuthenticated')) { 25 | const sessionData = this.get('session.data.authenticated'); 26 | 27 | return { 28 | 'oauth-id': sessionData.oauth_id, 29 | 'Authorization': `JWT ${sessionData.jwt}`, 30 | 'user-id': sessionData.user_id 31 | } 32 | } 33 | 34 | return { } 35 | } 36 | }); 37 | -------------------------------------------------------------------------------- /app/services/pn.js: -------------------------------------------------------------------------------- 1 | 2 | import Ember from 'ember'; 3 | 4 | export default Ember.Service.extend({ 5 | pubnub: null, 6 | init(user_id) { 7 | this.pubnub = new PubNub({ 8 | publishKey: 'pub-c-025e09ff-15ab-4e1f-ba9c-339e51eacc4d', 9 | subscribeKey: 'sub-c-669496ec-2e5b-11e7-97de-0619f8945a4f', 10 | uuid: user_id, 11 | ssl:true 12 | }); 13 | }, 14 | publishMessage(channel, message) { 15 | var publishConfig = { 16 | channel, 17 | message 18 | }; 19 | this.pubnub.publish(publishConfig, function (status, response) { 20 | }); 21 | }, 22 | addListener(callbackMessage,callbackPresence) { 23 | this.pubnub.addListener({ 24 | status: function (statusEvent) { 25 | if (statusEvent.category === "PNConnectedCategory") { 26 | } 27 | }, 28 | message: function (message) { 29 | callbackMessage(message); 30 | } , 31 | presence: function (p) { 32 | callbackPresence(p); 33 | } 34 | }); 35 | }, 36 | subscribe(channels) { 37 | this.pubnub.subscribe({ 38 | channels, 39 | withPresence: true 40 | }); 41 | }, 42 | history(channel, callback) { 43 | this.pubnub.history( 44 | { 45 | channel, 46 | reverse: true, 47 | stringifiedTimeToken: true, 48 | }, 49 | function (status, response) { 50 | callback(response); 51 | }); 52 | 53 | }, 54 | presence(channels, callback) { 55 | this.pubnub.hereNow( 56 | { 57 | channels, 58 | includeUUIDs: true, 59 | includeState: true 60 | }, 61 | function (status, response) { 62 | callback(response); 63 | } 64 | ); 65 | }, 66 | unsubscribe(channels) { 67 | this.pubnub.unsubscribe({ 68 | channels, 69 | withPresence: true 70 | }); 71 | }, 72 | removeListener(){ 73 | var existingListener = { 74 | message: function() { 75 | } 76 | } 77 | 78 | this.pubnub.removeListener(existingListener); 79 | } 80 | }); 81 | -------------------------------------------------------------------------------- /app/services/server-time.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import ENV from '../config/environment'; 3 | import { task, timeout } from 'ember-concurrency'; 4 | 5 | export default Ember.Service.extend ({ 6 | now: null, 7 | 8 | init () { 9 | this._super (...arguments) 10 | 11 | this.set ('now', Date.now ()) 12 | 13 | this.get ('refreshCurrentTime').perform () 14 | 15 | setInterval (() => { 16 | this.get ('tick').perform () 17 | }, 1000) 18 | 19 | setInterval (() => { 20 | this.get ('refreshCurrentTime').perform () 21 | }, 60000) 22 | }, 23 | 24 | refreshCurrentTime: task (function * () { 25 | yield Ember.$.getJSON (ENV.apiEndpoint + '/time') 26 | .done ((data, status, xhr) => { 27 | this.set ('now', data.now) 28 | }) 29 | }), 30 | 31 | tick: task (function * () { 32 | yield this.set ('now', this.get ('now') + 1000) 33 | }), 34 | 35 | getUnixTime () { 36 | return Math.floor (this.get ('now') / 1000) 37 | }, 38 | 39 | getTime () { 40 | return this.get ('now') 41 | } 42 | }) 43 | -------------------------------------------------------------------------------- /app/session-stores/application.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 12/01/17. 3 | */ 4 | 5 | import AdaptiveStore from 'ember-simple-auth/session-stores/adaptive'; 6 | 7 | export default AdaptiveStore.extend(); 8 | -------------------------------------------------------------------------------- /app/styles/app.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/app/styles/app.css -------------------------------------------------------------------------------- /app/templates/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/app/templates/components/.gitkeep -------------------------------------------------------------------------------- /app/utils/get-course-description.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | var getCourseDescription = function(code) { 4 | let desc = { 5 | LP:'Launchpad', 6 | CRX:'Crux', 7 | ELX:'Elixir', 8 | ML:'Machine Learning' 9 | }; 10 | return desc[code]; 11 | }; 12 | 13 | export default getCourseDescription; 14 | -------------------------------------------------------------------------------- /app/utils/get-error-details.js: -------------------------------------------------------------------------------- 1 | var getErrorDescription = function(code) { 2 | let desc = { 3 | "402":`This is a private contest. Please contact support@codingblocks.com or enroll now to get full access to Hackerblocks. Click here to check out the courses which we have. `, 4 | "405":`Your email is not verified. 5 | To verify your email or to add your college details, you can visit here`, 6 | }; 7 | return desc[code]; 8 | }; 9 | 10 | export default getErrorDescription; 11 | -------------------------------------------------------------------------------- /app/utils/get-snippet.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by umair on 01/02/17. 3 | */ 4 | 5 | var getSnippet = function(lang) { 6 | let snippets = {}; 7 | snippets['c'] = 8 | '#include \n' + 9 | 'int main() {\n' + 10 | ' \n' + 11 | '}\n'; 12 | 13 | snippets['cpp'] = 14 | '#include \n' + 15 | 'using namespace std;\n' + 16 | 'int main() {\n' + 17 | ' \n' + 18 | '}\n'; 19 | 20 | snippets['java'] = 21 | 'import java.util.*;\n' + 22 | '\n' + 23 | 'public class Main {\n' + 24 | ' public static void main(String args[]) {\n' + 25 | ' \n' + 26 | ' }\n' + 27 | '}'; 28 | snippets['js'] = "console.log('we use node 10 lts');"; 29 | snippets['py2'] = 30 | 'import sys'; 31 | snippets['py3'] = 32 | 'print ("Hello, World")'; 33 | snippets['csharp'] = `using System; 34 | public class Test 35 | { 36 | public static void Main() 37 | { 38 | 39 | } 40 | }`; 41 | return snippets[lang]; 42 | }; 43 | 44 | export default getSnippet; 45 | -------------------------------------------------------------------------------- /app/utils/http-validator.js: -------------------------------------------------------------------------------- 1 | // validator 2 | 3 | const httpValidator = function(link){ 4 | return /^http:\/\/.*/gi.test(link) || link.length === 0; 5 | }; 6 | 7 | export default httpValidator; -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hack", 3 | "dependencies": { 4 | "ember": "2.13.0", 5 | "ember-cli-shims": "0.1.3", 6 | "hammer.js": "^2.0.8", 7 | "matchMedia": "0.2.0", 8 | "showdown": "^1.5.5", 9 | "ace-builds": "^1.2.6", 10 | "spin.js": "^2.3.2" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /deployToProduction.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf dist/ 4 | ember build --environment=production 5 | chmod 600 key.pem 6 | 7 | scp -o StrictHostKeyChecking=no -i key.pem -r dist/* $USER@$SERVER:~/hack-frontend-new/ 8 | ssh -o StrictHostKeyChecking=no -i key.pem $USER@$SERVER "rm -rf ~/hack-frontend-old/*;" 9 | ssh -o StrictHostKeyChecking=no -i key.pem $USER@$SERVER "cp -r ~/hack-frontend/* ~/hack-frontend-old/;" 10 | ssh -o StrictHostKeyChecking=no -i key.pem $USER@$SERVER "rm -rf ~/hack-frontend/*;" 11 | ssh -o StrictHostKeyChecking=no -i key.pem $USER@$SERVER "cp -r ~/hack-frontend-new/* ~/hack-frontend/;" 12 | ssh -o StrictHostKeyChecking=no -i key.pem $USER@$SERVER "rm -rf ~/hack-frontend-new/*;" 13 | -------------------------------------------------------------------------------- /deployToStaging.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf dist/ 4 | ember build --environment=staging 5 | chmod 600 key.pem 6 | 7 | USER='codingblocks' 8 | SERVER='srv6.cb.lk' 9 | 10 | ssh -o StrictHostKeyChecking=no -i key.pem $USER@$SERVER "rm -rf ~/frontends/hacker-blocks/*;" 11 | scp -o StrictHostKeyChecking=no -i key.pem -r dist/* $USER@$SERVER:~/frontends/hacker-blocks/ 12 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | /* global require, module */ 3 | var EmberApp = require('ember-cli/lib/broccoli/ember-app'); 4 | 5 | var Funnel = require('broccoli-funnel'); 6 | 7 | module.exports = function(defaults) { 8 | var app = new EmberApp(defaults, { 9 | SRI: { 10 | crossorigin: 'anonymous' 11 | }, 12 | fingerprint: { 13 | enabled: true, 14 | exclude: ['assets/ace/**/*.*'] 15 | } 16 | }); 17 | 18 | app.import('vendor/css/all-themes.css'); 19 | app.import('vendor/css/main.css'); 20 | app.import('vendor/css/morris.css'); 21 | app.import('vendor/css/bootstrap.min.css'); 22 | app.import('vendor/css/login-popup.css'); 23 | 24 | app.import('vendor/js/jquery.min.js'); 25 | app.import('vendor/js/libscripts.bundle.js'); 26 | app.import('vendor/js/mainscripts.bundle.js'); 27 | app.import('vendor/js/vendorscripts.bundle.js'); 28 | app.import('vendor/js/bootstrap.min.js'); 29 | 30 | 31 | var extraAssets = new Funnel('bower_components/ace-builds/src-min-noconflict', { 32 | srcDir: '/', 33 | include: ['ace.js', 'ext-language_tools.js', 'snippets/c_cpp.js', 'snippets/java.js','snippets/csharp.js', 'theme-solarized_light.js', 34 | 'snippets/python.js', 'snippets/text.js','snippets/javascript.js', 'worker-javascript.js', 'theme-monokai.js', 35 | 'mode-c_cpp.js', 'mode-java.js', 'mode-python.js','mode-javascript.js','mode-csharp.js'], 36 | destDir: '/assets/ace' 37 | }); 38 | 39 | return app.toTree(extraAssets); 40 | }; 41 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | {"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]} -------------------------------------------------------------------------------- /key.pem.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/key.pem.enc -------------------------------------------------------------------------------- /mirage/scenarios/default.js: -------------------------------------------------------------------------------- 1 | export default function(/* server */) { 2 | 3 | /* 4 | Seed your development database using your factories. 5 | This data will not be loaded in your tests. 6 | 7 | Make sure to define a factory for each model you want to create. 8 | */ 9 | 10 | // server.createList('post', 10); 11 | } 12 | -------------------------------------------------------------------------------- /mirage/serializers/application.js: -------------------------------------------------------------------------------- 1 | import { JSONAPISerializer } from 'ember-cli-mirage'; 2 | 3 | export default JSONAPISerializer.extend({ 4 | }); 5 | -------------------------------------------------------------------------------- /public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/favicon.ico -------------------------------------------------------------------------------- /public/fonts/Material-Design-Iconic-Font.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/fonts/Material-Design-Iconic-Font.woff2 -------------------------------------------------------------------------------- /public/images/about.svg: -------------------------------------------------------------------------------- 1 | 3 | Priority Warning 4 | A line styled icon from Orion Icon Library. 5 | 8 | 10 | 12 | -------------------------------------------------------------------------------- /public/images/badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/badge.png -------------------------------------------------------------------------------- /public/images/clockface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/clockface.png -------------------------------------------------------------------------------- /public/images/competitive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/competitive.png -------------------------------------------------------------------------------- /public/images/correct-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/correct-icon.png -------------------------------------------------------------------------------- /public/images/course-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/course-3.jpg -------------------------------------------------------------------------------- /public/images/desc.svg: -------------------------------------------------------------------------------- 1 | 3 | Document 4 | A line styled icon from Orion Icon Library. 5 | 8 | 10 | 13 | -------------------------------------------------------------------------------- /public/images/disable-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/disable-icon.png -------------------------------------------------------------------------------- /public/images/docs.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /public/images/error-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/error-icon.png -------------------------------------------------------------------------------- /public/images/generic-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/generic-1.jpg -------------------------------------------------------------------------------- /public/images/hourhand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/hourhand.png -------------------------------------------------------------------------------- /public/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/logo.png -------------------------------------------------------------------------------- /public/images/minhand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/minhand.png -------------------------------------------------------------------------------- /public/images/ngnc.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/ngnc.jpg -------------------------------------------------------------------------------- /public/images/partially-correct.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/partially-correct.jpg -------------------------------------------------------------------------------- /public/images/placeholder-avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/placeholder-avatar.png -------------------------------------------------------------------------------- /public/images/prize.svg: -------------------------------------------------------------------------------- 1 | 3 | Diploma 4 | A line styled icon from Orion Icon Library. 5 | 8 | 11 | 14 | -------------------------------------------------------------------------------- /public/images/profile-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/profile-bg.jpg -------------------------------------------------------------------------------- /public/images/question.svg: -------------------------------------------------------------------------------- 1 | 3 | Question 4 | A line styled icon from Orion Icon Library. 5 | 9 | 11 | -------------------------------------------------------------------------------- /public/images/sechand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/sechand.png -------------------------------------------------------------------------------- /public/images/student/random-avatar1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/student/random-avatar1.jpg -------------------------------------------------------------------------------- /public/images/student/random-avatar2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/student/random-avatar2.jpg -------------------------------------------------------------------------------- /public/images/student/random-avatar3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/student/random-avatar3.jpg -------------------------------------------------------------------------------- /public/images/student/random-avatar4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/student/random-avatar4.jpg -------------------------------------------------------------------------------- /public/images/student/random-avatar5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/student/random-avatar5.jpg -------------------------------------------------------------------------------- /public/images/student/random-avatar6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/student/random-avatar6.jpg -------------------------------------------------------------------------------- /public/images/tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/tag.png -------------------------------------------------------------------------------- /public/images/wrong-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/images/wrong-icon.png -------------------------------------------------------------------------------- /public/media/notification-tone.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/public/media/notification-tone.mp3 -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /start-development-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "/app" && 4 | yarn add global ember-cli && 5 | ember s 6 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | module.exports = { 3 | "framework": "qunit", 4 | "test_page": "tests/index.html?hidepassed", 5 | "disable_watching": true, 6 | "launch_in_ci": [ 7 | "PhantomJS" 8 | ], 9 | "launch_in_dev": [ 10 | "PhantomJS", 11 | "Chrome" 12 | ] 13 | }; 14 | -------------------------------------------------------------------------------- /tests/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "location", 6 | "setTimeout", 7 | "$", 8 | "-Promise", 9 | "define", 10 | "console", 11 | "visit", 12 | "exists", 13 | "fillIn", 14 | "click", 15 | "keyEvent", 16 | "triggerEvent", 17 | "find", 18 | "findWithAssert", 19 | "wait", 20 | "DS", 21 | "andThen", 22 | "currentURL", 23 | "currentPath", 24 | "currentRouteName" 25 | ], 26 | "node": false, 27 | "browser": false, 28 | "boss": true, 29 | "curly": true, 30 | "debug": false, 31 | "devel": false, 32 | "eqeqeq": true, 33 | "evil": true, 34 | "forin": false, 35 | "immed": false, 36 | "laxbreak": false, 37 | "newcap": true, 38 | "noarg": true, 39 | "noempty": false, 40 | "nonew": false, 41 | "nomen": false, 42 | "onevar": false, 43 | "plusplus": false, 44 | "regexp": false, 45 | "undef": true, 46 | "sub": true, 47 | "strict": false, 48 | "white": false, 49 | "eqnull": true, 50 | "esversion": 6, 51 | "unused": true 52 | } 53 | -------------------------------------------------------------------------------- /tests/helpers/destroy-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default function destroyApp(application) { 4 | Ember.run(application, 'destroy'); 5 | } 6 | -------------------------------------------------------------------------------- /tests/helpers/module-for-acceptance.js: -------------------------------------------------------------------------------- 1 | import { module } from 'qunit'; 2 | import Ember from 'ember'; 3 | import startApp from '../helpers/start-app'; 4 | import destroyApp from '../helpers/destroy-app'; 5 | 6 | const { RSVP: { Promise } } = Ember; 7 | 8 | export default function(name, options = {}) { 9 | module(name, { 10 | beforeEach() { 11 | this.application = startApp(); 12 | 13 | if (options.beforeEach) { 14 | return options.beforeEach.apply(this, arguments); 15 | } 16 | }, 17 | 18 | afterEach() { 19 | let afterEach = options.afterEach && options.afterEach.apply(this, arguments); 20 | return Promise.resolve(afterEach).then(() => destroyApp(this.application)); 21 | } 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from '../../resolver'; 2 | import config from '../../config/environment'; 3 | 4 | const resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Application from '../../app'; 3 | import config from '../../config/environment'; 4 | 5 | export default function startApp(attrs) { 6 | let application; 7 | 8 | // use defaults, but you can override 9 | let attributes = Ember.assign({}, config.APP, attrs); 10 | 11 | Ember.run(() => { 12 | application = Application.create(attributes); 13 | application.setupForTesting(); 14 | application.injectTestHelpers(); 15 | }); 16 | 17 | return application; 18 | } 19 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Hack Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {{content-for "body-footer"}} 31 | {{content-for "test-body-footer"}} 32 | 33 | 34 | -------------------------------------------------------------------------------- /tests/integration/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/tests/integration/.gitkeep -------------------------------------------------------------------------------- /tests/integration/pods/components/college-leaderboard/component-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForComponent, test } from 'ember-qunit'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | moduleForComponent('college-leaderboard', 'Integration | Component | college leaderboard', { 5 | integration: true 6 | }); 7 | 8 | test('it renders', function(assert) { 9 | 10 | // Set any properties with this.set('myProperty', 'value'); 11 | // Handle any actions with this.on('myAction', function(val) { ... }); 12 | 13 | this.render(hbs`{{college-leaderboard}}`); 14 | 15 | assert.equal(this.$().text().trim(), ''); 16 | 17 | // Template block usage: 18 | this.render(hbs` 19 | {{#college-leaderboard}} 20 | template block text 21 | {{/college-leaderboard}} 22 | `); 23 | 24 | assert.equal(this.$().text().trim(), 'template block text'); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/integration/pods/components/question-container/component-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForComponent, test } from 'ember-qunit'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | moduleForComponent('question-container', 'Integration | Component | question container', { 5 | integration: true 6 | }); 7 | 8 | test('it renders', function(assert) { 9 | 10 | // Set any properties with this.set('myProperty', 'value'); 11 | // Handle any actions with this.on('myAction', function(val) { ... }); 12 | 13 | this.render(hbs`{{question-container}}`); 14 | 15 | assert.equal(this.$().text().trim(), ''); 16 | 17 | // Template block usage: 18 | this.render(hbs` 19 | {{#question-container}} 20 | template block text 21 | {{/question-container}} 22 | `); 23 | 24 | assert.equal(this.$().text().trim(), 'template block text'); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/integration/pods/components/quiz-result/component-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForComponent, test } from 'ember-qunit'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | moduleForComponent('quiz-result', 'Integration | Component | quiz result', { 5 | integration: true 6 | }); 7 | 8 | test('it renders', function(assert) { 9 | 10 | // Set any properties with this.set('myProperty', 'value'); 11 | // Handle any actions with this.on('myAction', function(val) { ... }); 12 | 13 | this.render(hbs`{{quiz-result}}`); 14 | 15 | assert.equal(this.$().text().trim(), ''); 16 | 17 | // Template block usage: 18 | this.render(hbs` 19 | {{#quiz-result}} 20 | template block text 21 | {{/quiz-result}} 22 | `); 23 | 24 | assert.equal(this.$().text().trim(), 'template block text'); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/integration/pods/components/submission-explanation/component-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForComponent, test } from 'ember-qunit'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | moduleForComponent('submission-explanation', 'Integration | Component | submission explanation', { 5 | integration: true 6 | }); 7 | 8 | test('it renders', function(assert) { 9 | 10 | // Set any properties with this.set('myProperty', 'value'); 11 | // Handle any actions with this.on('myAction', function(val) { ... }); 12 | 13 | this.render(hbs`{{submission-explanation}}`); 14 | 15 | assert.equal(this.$().text().trim(), ''); 16 | 17 | // Template block usage: 18 | this.render(hbs` 19 | {{#submission-explanation}} 20 | template block text 21 | {{/submission-explanation}} 22 | `); 23 | 24 | assert.equal(this.$().text().trim(), 'template block text'); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/integration/pods/components/tutorials-container/component-test.js: -------------------------------------------------------------------------------- 1 | import { moduleForComponent, test } from 'ember-qunit'; 2 | import hbs from 'htmlbars-inline-precompile'; 3 | 4 | moduleForComponent('tutorials-container', 'Integration | Component | tutorials container', { 5 | integration: true 6 | }); 7 | 8 | test('it renders', function(assert) { 9 | 10 | // Set any properties with this.set('myProperty', 'value'); 11 | // Handle any actions with this.on('myAction', function(val) { ... }); 12 | 13 | this.render(hbs`{{tutorials-container}}`); 14 | 15 | assert.equal(this.$().text().trim(), ''); 16 | 17 | // Template block usage: 18 | this.render(hbs` 19 | {{#tutorials-container}} 20 | template block text 21 | {{/tutorials-container}} 22 | `); 23 | 24 | assert.equal(this.$().text().trim(), 'template block text'); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import resolver from './helpers/resolver'; 2 | import { 3 | setResolver 4 | } from 'ember-qunit'; 5 | 6 | setResolver(resolver); 7 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/tests/unit/.gitkeep -------------------------------------------------------------------------------- /tests/unit/adapters/contest-attempt-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('adapter:contest-attempt', 'Unit | Adapter | contest attempt', { 4 | // Specify the other units that are required for this test. 5 | // needs: ['serializer:foo'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it exists', function(assert) { 10 | let adapter = this.subject(); 11 | assert.ok(adapter); 12 | }); 13 | -------------------------------------------------------------------------------- /tests/unit/helpers/ago-time-test.js: -------------------------------------------------------------------------------- 1 | 2 | import { agoTime } from 'hack/helpers/ago-time'; 3 | import { module, test } from 'qunit'; 4 | 5 | module('Unit | Helper | ago time'); 6 | 7 | // Replace this with your real tests. 8 | test('it works', function(assert) { 9 | let result = agoTime([42]); 10 | assert.ok(result); 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /tests/unit/helpers/first-name-test.js: -------------------------------------------------------------------------------- 1 | 2 | import { firstName } from 'hack/helpers/first-name'; 3 | import { module, test } from 'qunit'; 4 | 5 | module('Unit | Helper | first name'); 6 | 7 | // Replace this with your real tests. 8 | test('it works', function(assert) { 9 | let result = firstName([42]); 10 | assert.ok(result); 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /tests/unit/helpers/get-element-at-test.js: -------------------------------------------------------------------------------- 1 | 2 | import { getElementAt } from 'hack/helpers/get-element-at'; 3 | import { module, test } from 'qunit'; 4 | 5 | module('Unit | Helper | get element at'); 6 | 7 | // Replace this with your real tests. 8 | test('it works', function(assert) { 9 | let result = getElementAt([42]); 10 | assert.ok(result); 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /tests/unit/instance-initializers/embed-test.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import { initialize } from 'hack/instance-initializers/embed'; 3 | import { module, test } from 'qunit'; 4 | import destroyApp from '../../helpers/destroy-app'; 5 | 6 | module('Unit | Instance Initializer | embed', { 7 | beforeEach() { 8 | Ember.run(() => { 9 | this.application = Ember.Application.create(); 10 | this.appInstance = this.application.buildInstance(); 11 | }); 12 | }, 13 | afterEach() { 14 | Ember.run(this.appInstance, 'destroy'); 15 | destroyApp(this.application); 16 | } 17 | }); 18 | 19 | // Replace this with your real tests. 20 | test('it works', function(assert) { 21 | initialize(this.appInstance); 22 | 23 | // you would normally confirm the results of the initializer here 24 | assert.ok(true); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/unit/pods/current-contest/service-test.js: -------------------------------------------------------------------------------- 1 | import { moduleFor, test } from 'ember-qunit'; 2 | 3 | moduleFor('service:current-contest', 'Unit | Service | current contest', { 4 | // Specify the other units that are required for this test. 5 | // needs: ['service:foo'] 6 | }); 7 | 8 | // Replace this with your real tests. 9 | test('it exists', function(assert) { 10 | let service = this.subject(); 11 | assert.ok(service); 12 | }); 13 | -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coding-blocks/hacker-blocks/20587bcd2a4ff4b2876b466871a978a8222065c4/vendor/.gitkeep -------------------------------------------------------------------------------- /vendor/css/login-popup.css: -------------------------------------------------------------------------------- 1 | /* Card */ 2 | .modal-dialog .card { 3 | position: relative; 4 | background: #ffffff; 5 | border-radius: 5px; 6 | padding: 50px 0 40px 0; 7 | box-sizing: border-box; 8 | box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24); 9 | -webkit-transition: .3s ease; 10 | transition: .3s ease;/* Title *//* Inputs */ 11 | /* Button */ 12 | /* Footer */ 13 | /* Alt Card */ 14 | } 15 | .modal-dialog .card .title { 16 | position: relative; 17 | z-index: 1; 18 | border-left: 5px solid #dd5e89; 19 | margin: 0 0 25px; 20 | padding: 10px 0 10px 42px; 21 | color: #dd5e89; 22 | font-size: 22px; 23 | font-weight: 600; 24 | text-transform: uppercase; 25 | } 26 | .modal-dialog .card .title span { 27 | font-size: 13px; 28 | display: block; 29 | margin: 0; 30 | line-height: 18px; 31 | font-weight: 400; 32 | color: #444; 33 | } 34 | .modal-dialog .card .title .msg { 35 | font-size: 13px; 36 | color: #666; 37 | display: block; 38 | margin: 0; 39 | padding: 0; 40 | font-weight: normal; 41 | line-height: 18px; 42 | margin-top: 10px; 43 | text-transform: none; 44 | } 45 | .modal-dialog .form-line .search-btn { 46 | display: inline-block; 47 | position: absolute; 48 | right: 50px; 49 | top: 0; 50 | } 51 | .modal-dialog .form-line .search-btn button { 52 | box-shadow: none; 53 | margin: 0; 54 | } 55 | .modal-header .close { 56 | float: right !important; 57 | margin-right: -30px !important; 58 | margin-top: -30px !important; 59 | background-color:#000 !important; 60 | color:#fff !important; 61 | font-size:20px; 62 | border-radius: 15px !important; 63 | width: 35px !important; 64 | height: 35px !important; 65 | opacity: 1 !important; 66 | } -------------------------------------------------------------------------------- /vendor/css/morris.css: -------------------------------------------------------------------------------- 1 | .morris-hover { 2 | position: absolute; 3 | z-index: 1000 4 | } 5 | .morris-hover.morris-default-style { 6 | border-radius: 10px; 7 | padding: 6px; 8 | color: #666; 9 | background: rgba(255,255,255,0.8); 10 | border: solid 2px rgba(230,230,230,0.8); 11 | font-family: sans-serif; 12 | font-size: 12px; 13 | text-align: center 14 | } 15 | .morris-hover.morris-default-style .morris-hover-row-label { 16 | font-weight: bold; 17 | margin: 0.25em 0 18 | } 19 | .morris-hover.morris-default-style .morris-hover-point { 20 | white-space: nowrap; 21 | margin: 0.1em 0 22 | } 23 | --------------------------------------------------------------------------------