From dcb136ead25badc5ef9a0a0e284cbec83bfae251 Mon Sep 17 00:00:00 2001 From: Himanshu Pandey <42613146+coderjedi@users.noreply.github.com> Date: Fri, 3 Jan 2020 23:20:58 +0530 Subject: [PATCH 01/13] Updated models for score logic --- blind_coding/main_app/models.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/blind_coding/main_app/models.py b/blind_coding/main_app/models.py index f58d542..ca64704 100644 --- a/blind_coding/main_app/models.py +++ b/blind_coding/main_app/models.py @@ -8,13 +8,15 @@ class Userdata(models.Model): score = models.IntegerField(default = 0) answerGiven = models.CharField(max_length = 10, default="00000") timeElapsed = models.IntegerField(default = 0) - + def __str__(self): return str(self.user_id.username) class Question(models.Model): qno=models.IntegerField(default=0) + weight = models.IntegerField() text = models.CharField(max_length=45000) + time_penalty = models.ManyToManyField(Userdata, through="Time_Penalty",blank=True,null=True) testcaseno=models.IntegerField(default=0) samplein = models.CharField(max_length=45000,default='') sampleout = models.CharField(max_length=45000,default='') @@ -27,3 +29,15 @@ class Question(models.Model): def __str__(self): return str(self.pk) + +class Time_Penalty(models.Model): + player = models.ForeignKey(Userdata, on_delete=models.CASCADE) + question = models.ForeignKey(Question, on_delete=models.CASCADE,related_name='questions') + time_penalty = models.IntegerField(default=0) + no_wa = models.IntegerField(default=0) + + class Meta: + unique_together = ("player", "question") + + def __str__(self): + return "{} : {}".format(self.player.name, self.question.qno) From 7c622ec22bca6b1c89a93cff5aa226630d52b13d Mon Sep 17 00:00:00 2001 From: Himanshu Pandey <42613146+coderjedi@users.noreply.github.com> Date: Fri, 3 Jan 2020 23:22:40 +0530 Subject: [PATCH 02/13] Updated views --- blind_coding/main_app/views.py | 86 ++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/blind_coding/main_app/views.py b/blind_coding/main_app/views.py index ad11283..d74dfa0 100644 --- a/blind_coding/main_app/views.py +++ b/blind_coding/main_app/views.py @@ -12,7 +12,7 @@ def index(request): # pass from django.shortcuts import render from django.http import JsonResponse,HttpResponseRedirect,HttpResponse -from .models import Userdata,Question +from .models import Userdata,Question,Time_Penalty from django.contrib.auth import logout import json @@ -47,49 +47,53 @@ def question(request): print('hi') print(res['userScore']) return HttpResponse(json.dumps(res)) - + def runCode(request): - postData = json.loads( request.body.decode('utf-8') ) - url = 'https://api.jdoodle.com/execute/' - print(postData) - que = Question.objects.get(qno=postData['qNo']) - postData['stdin'] = '3'+'\n'+que.test_case1+'\n'+que.test_case2+'\n'+que.test_case3 - response = requests.post(url,json=postData) - resp = response.json() + postData = json.loads( request.body.decode('utf-8') ) + url = 'https://api.jdoodle.com/execute/' + print(postData) + que = Question.objects.get(qno=postData['qNo']) + postData['stdin'] = '3'+'\n'+que.test_case1+'\n'+que.test_case2+'\n'+que.test_case3 + response = requests.post(url,json=postData) + resp = response.json() # resp = json.loads(resp) - print('qNo',postData['qNo']) - print('jdoodle response json object: ',resp) - print('jdoodle output response: ',resp['output']) - res = {} + print('qNo',postData['qNo']) + print('jdoodle response json object: ',resp) + print('jdoodle output response: ',resp['output']) + res = {} #Get current user - currUser = Userdata.objects.get(user_id = request.user) - - if resp['output'].find('error') != -1: - res['output'] = resp['output'] - else: - quesNo = postData['qNo'] - quesData = Question.objects.get(qno= quesNo) - answer = quesData.test_case1_sol+'\n'+quesData.test_case2_sol+'\n'+quesData.test_case3_sol+'\n' - print(answer) - currUser.timeElapsed += int(postData['timeElapsed']) - if answer == resp['output']: - print('hurray') - res['output'] = 'Correct Answer' - print(currUser.answerGiven) - lst = list(currUser.answerGiven) - print(lst) - if(lst[quesNo] == '0'): # if the question is being answered first time - print('Updating score for question no', ) - lst[quesNo] = '1' - currUser.answerGiven="".join(lst) - currUser.score+=10 - currUser.save() - else: - res['output'] = 'Wrong answer..' - - currUser.save() - res['score'] = currUser.score - return HttpResponse(json.dumps(res)) + currUser = Userdata.objects.get(user_id = request.user) + if resp['output'].find('error') != -1: + res['output'] = resp['output'] + else: + quesNo = postData['qNo'] + quesData = Question.objects.get(qno= quesNo) + answer = quesData.test_case1_sol+'\n'+quesData.test_case2_sol+'\n'+quesData.test_case3_sol+'\n' + print(answer) + currUser.timeElapsed += int(postData['timeElapsed']) + if answer == resp['output']: + print('hurray') + res['output'] = 'Correct Answer' + print(currUser.answerGiven) + lst = list(currUser.answerGiven) + print(lst) + if(lst[quesNo] == '0'): # if the question is being answered first time + print('Updating score for question no', ) + lst[quesNo] = '1' + currUser.answerGiven="".join(lst) + timepenalty=Time_Penalty.objects.get_or_create(player=currUser,question=que) + timepenalty.time_penalty=int(postData['timeElapsed'])+20/100*timepenalty.no_wa*que.weight + currUser.score=que.weight-timepenalty.time_penalty + timepenalty.save() + currUser.save() + else: + timepenalty=Time_Penalty.objects.get_or_create(player=currUser,question=que) + timepenalty.no_wa+=1 + res['output'] = 'Wrong answer..' + timepenalty.save() + currUser.save() + res['score'] = currUser.score + return HttpResponse(json.dumps(res)) def l_out(request): logout(request) From ab7e726cc5298714fe191f4da8cf49d9cc744a51 Mon Sep 17 00:00:00 2001 From: HarpinderJotSingh Date: Sat, 4 Jan 2020 11:34:48 +0530 Subject: [PATCH 03/13] Replaced : by = in blind_coding/settings.py for clientId and clientSecret --- blind_coding/blind_coding/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blind_coding/blind_coding/settings.py b/blind_coding/blind_coding/settings.py index 7cf4434..d4e7522 100644 --- a/blind_coding/blind_coding/settings.py +++ b/blind_coding/blind_coding/settings.py @@ -137,5 +137,5 @@ MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(REPOSITORY_ROOT, 'media/') -clientId: "222a2ef84f6881409d32ae21369d1a32" -clientSecret:"67872757630a355db890ee74b6b20926cb9e025dbb444182df2bd2700fc64af1" +clientId = "222a2ef84f6881409d32ae21369d1a32" +clientSecret = "67872757630a355db890ee74b6b20926cb9e025dbb444182df2bd2700fc64af1" From 890151ba9d86559dd1c6b5bc7913848cad037e8a Mon Sep 17 00:00:00 2001 From: Himanshu Pandey <42613146+coderjedi@users.noreply.github.com> Date: Sat, 4 Jan 2020 13:01:38 +0530 Subject: [PATCH 04/13] Changes made in leaderboard and runCode --- blind_coding/main_app/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blind_coding/main_app/views.py b/blind_coding/main_app/views.py index d74dfa0..b6a7b1e 100644 --- a/blind_coding/main_app/views.py +++ b/blind_coding/main_app/views.py @@ -83,7 +83,8 @@ def runCode(request): currUser.answerGiven="".join(lst) timepenalty=Time_Penalty.objects.get_or_create(player=currUser,question=que) timepenalty.time_penalty=int(postData['timeElapsed'])+20/100*timepenalty.no_wa*que.weight - currUser.score=que.weight-timepenalty.time_penalty + currUser.score+=que.weight + currUser.total_penalty+=timepenalty.time_penalty timepenalty.save() currUser.save() else: @@ -100,7 +101,7 @@ def l_out(request): return render(request,'index.html') def leaderboard(request): - leaderboard = Userdata.objects.order_by('-score') + leaderboard = Userdata.objects.order_by('-score','total_penalty') print(leaderboard) username = [] score = [] From 1856c0338fa08a7d3de26c4f10320613cf310b1f Mon Sep 17 00:00:00 2001 From: Himanshu Pandey <42613146+coderjedi@users.noreply.github.com> Date: Sat, 4 Jan 2020 13:02:25 +0530 Subject: [PATCH 05/13] Updated models --- blind_coding/main_app/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/blind_coding/main_app/models.py b/blind_coding/main_app/models.py index ca64704..1ca74ca 100644 --- a/blind_coding/main_app/models.py +++ b/blind_coding/main_app/models.py @@ -8,6 +8,7 @@ class Userdata(models.Model): score = models.IntegerField(default = 0) answerGiven = models.CharField(max_length = 10, default="00000") timeElapsed = models.IntegerField(default = 0) + total_penalty=models.IntegerField(default = 0) def __str__(self): return str(self.user_id.username) From d63de7d0b1cd1037afc7b8e5af3212b6ae134639 Mon Sep 17 00:00:00 2001 From: HarpinderJotSingh Date: Sat, 4 Jan 2020 13:47:45 +0530 Subject: [PATCH 06/13] Tested leaderboard logic, fixed minor bugs --- blind_coding/db.sqlite3 | Bin 87040 -> 96256 bytes blind_coding/main_app/admin.py | 3 +- .../migrations/0002_auto_20200104_1324.py | 43 +++++++++ .../migrations/0003_auto_20200104_1332.py | 18 ++++ blind_coding/main_app/models.py | 2 +- blind_coding/main_app/views.py | 85 +++++++++--------- 6 files changed, 108 insertions(+), 43 deletions(-) create mode 100644 blind_coding/main_app/migrations/0002_auto_20200104_1324.py create mode 100644 blind_coding/main_app/migrations/0003_auto_20200104_1332.py diff --git a/blind_coding/db.sqlite3 b/blind_coding/db.sqlite3 index b5ab1008fb941247c606ace48d6c2b657030f830..a7cb9a8f8e8154a84dd9f64758a890c3d7b91e2f 100644 GIT binary patch delta 6966 zcmd5>3ve69dA{8R1b{D)lK6lmiVz>NC<)L#aCZPjDFq1-;sXc1Nx+dYN8m`j0fHbw z!nJ8oQq!3xPULff&NRuyW2;TtM3zL?oXJcRyQw>F;&$XtoEf{B+Hq1pW!H`qH&dmL zJy4`bk+R|$wUZm(Vt4=jcK`psfB*ge2(muSrAAAW`VN!2ii_7l33YYAn{C(60UH2|uM>!Y`&$ z{^?n1CKFC3495@;)_XJIxa3bs2{D#gP&L$`PEe@Y3-(s4%gay$5N9(X|LlyEt}xai zmrj21m-X^YI4=m*lsPIu`S-73D;})vjwP zZ`JAS<*A8iaFX`VghZO5&=9lun3o zX#qF>K*G9tJ#^F>C=zEg6gPetz3pq~(UH@t;jM?b~7`cL#LtgC0xenr^w`eM1SSne&Bdy1uD z`B#gTWvf_>xQV}sttetEir9)GwxWowz}PQV?yFFv*9m2{RV>C`MLU$aD@vE&dUBs? zrv^Mnpl_mn?2@j)0Nf3p!=L3zaF4rQN7(iHF)ZpWX2Z2v7&FIMEmnqQ<@;CmuvsZQ z70NW8e&B)AWoL`kpcDQ#dvQGj({87TZ)N9ZJniX0p*p1RH!{k_+*CB*0sysQH8~Rojf*AVEv1 zXj)28wk$n2kw{o($WS(J4N5cVx#`Wp~1#Fxp zP0dW!D5DDB9R$YZ@ZbL#Xs&=B0^9Bn&=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PiU;3>Hc|pPr&Eu z&GhjdF1yRb8*JG=P0(wPy2g85)8@E87Vq%d%^AZ;+Q|<_Z3&%UYm0V!Q|^%zpD|77 zjs0`k=*UnmG~|fH+!?E0snu&WS{;L~O3SaI#oTPx8x1^v{MPH-fk(MK;qFi7 z9Lw}4FPiJ`4H(C}%>K~0#~n81vQ}-vznnwS!dAV>DwhuaEaaB zo`M4okGwMAf&)RZo&%+LtQzEEv>KXfyxwGNs;zU#-acYib@$usV=8qz=?}9sxs~5m zfmL2aiAdmc#wriC3#C_T#b>Kvleo7E`U(z?<<`J-*ei~zVJo=A{c4yM2O40vct;Jp z3%4CE^nML)qr%~zs>PHA)`@Zp{6*Ze9je4-GdugTnXSIEfNX`^4FAL$76Sz@!M%(v zlX{{gIKX6#z`>x?0n%6R0_6_WenT#5tKf%FZ~_{+5t`qjooW<{B4tuejen^*SmiEv`DS_+E z@Xui7IuF~aLPk#!d<(yY2KpI2#R7kYuAFLvG03CjOF};&U$Sm~T7GC!rXb%QsM}Fr zQc?n2O7h3WnGUF0soMkJ0de_h*rMWmzRAf+{}iJ@VCrB!ryz$sl@+yYfKqw?fXEIU z6$LM}iGK`&T8ZgYC@>pfBa}+7Mo!6_NQcOq%cu^F*0)`Ds1sAYP$6Em!``BJvLzKt&Lx{8sh~Jx2dg@k^!s7~b*oApNT{1s>S Date: Sat, 4 Jan 2020 18:37:15 +0530 Subject: [PATCH 07/13] Changed compiler api from jdoodle to judge0 --- blind_coding/db.sqlite3 | Bin 96256 -> 96256 bytes blind_coding/main_app/templates/loggedIn.html | 6 +- blind_coding/main_app/views.py | 70 +++++++++++------- blind_coding/static/js/app.js | 35 +++++++-- 4 files changed, 74 insertions(+), 37 deletions(-) diff --git a/blind_coding/db.sqlite3 b/blind_coding/db.sqlite3 index a7cb9a8f8e8154a84dd9f64758a890c3d7b91e2f..4aeb2e1949c2d6ca290694a4babad3bd9a28d90d 100644 GIT binary patch delta 565 zcmZqpz}oPEb%HeGg^4oGj2AX09M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1 through C. Each cake has an integer height; initially, the height of each cake is 0. There are N operations. In each operation, you are given two integers L and R, and you should increase by 1 the height of each of the cakes L,L+1,…,R. One of these N operations should be removed and the remaining N−1 operations are then performed. Chef wants to remove one operation in such a way that after the remaining N−1 operations are performed, the number of cakes with height exactly K is maximum possible. Since Chef is a bit busy these days, he has asked for your help. You need to find the maximum number of cakes with height exactly K that can be achieved by removing one operation. + Loading.....
@@ -90,12 +90,12 @@
Question 1
diff --git a/blind_coding/main_app/views.py b/blind_coding/main_app/views.py index abbdde8..26cfe1a 100644 --- a/blind_coding/main_app/views.py +++ b/blind_coding/main_app/views.py @@ -1,24 +1,21 @@ from django.shortcuts import render,redirect -import requests - -# Create your views here. -def default(request): - return render(request,'loggedIn.html') - -def index(request): - return render(request,'index.html') -# -#def login(request): -# pass from django.shortcuts import render from django.http import JsonResponse,HttpResponseRedirect,HttpResponse from .models import Userdata,Question,Time_Penalty from django.contrib.auth import logout +from django.contrib.auth.decorators import login_required + import json +import requests +import base64 +import time import blind_coding.settings as settings -from django.contrib.auth.decorators import login_required +def default(request): + return render(request,'loggedIn.html') +def index(request): + return render(request,'index.html') def login(request): # if request.POST: @@ -51,32 +48,53 @@ def question(request): def runCode(request): postData = json.loads( request.body.decode('utf-8') ) - url = 'https://api.jdoodle.com/execute/' - print(postData) + url = 'https://api.judge0.com/submissions?base64_encoded=false&wait=false' que = Question.objects.get(qno=postData['qNo']) - postData['stdin'] = '3'+'\n'+que.test_case1+'\n'+que.test_case2+'\n'+que.test_case3 - postData['clientId'] = settings.clientId - postData['clientSecret'] = settings.clientSecret + stdin = '3'+'\n'+que.test_case1+'\n'+que.test_case2+'\n'+que.test_case3 + # postData['stdin'] = str(base64.b64encode(stdin.encode("utf-8"))) + postData['stdin'] = stdin + # postData['source_code'] = str(base64.b64encode(postData['source_code'].encode('utf-8'))) + print(postData) + response = requests.post(url,json=postData) resp = response.json() -# resp = json.loads(resp) + # resp = json.loads(resp) print('qNo',postData['qNo']) - print('jdoodle response json object: ',resp) - print('jdoodle output response: ',resp['output']) + print('response token: ',resp['token']) + + url2 = 'https://api.judge0.com/submissions/'+resp['token']+'?base64_encoded=false' + time.sleep(1) + resp = requests.get(url2).json() + if 'status' in resp: + if resp['status']['description'] == "Processing": + while resp['status']['description'] == "Processing": + resp = requests.get(url2).json() + print(resp) + # print('exit_code ',resp['exit_code']) + # print('exit_signal ',resp['exit_signal']) + # print( str(base64.b64decode(resp['stderr'].encode('utf-8').strip()), "utf-8") ) + # print('output response: ',resp['stdout']) res = {} #Get current user currUser = Userdata.objects.get(user_id = request.user) - if resp['output'].find('error') != -1: - res['output'] = resp['output'] + if 'error' in resp: + res['stdout'] = 'error' + elif resp['status']['description'] != "Accepted": + if resp['stderr'] is not None: + res['stdout'] = resp['stderr'] + elif resp['compile_output'] is not None: + res['stdout'] = resp['compile_output'] + else: + res['stdout'] = 'error' else: quesNo = postData['qNo'] quesData = Question.objects.get(qno= quesNo) answer = quesData.test_case1_sol+'\n'+quesData.test_case2_sol+'\n'+quesData.test_case3_sol+'\n' print(answer) currUser.timeElapsed += int(postData['timeElapsed']) - if answer == resp['output']: + if answer == resp['stdout']: print('hurray') - res['output'] = 'Correct Answer' + res['stdout'] = 'Correct Answer' print(currUser.answerGiven) lst = list(currUser.answerGiven) print(lst) @@ -96,9 +114,9 @@ def runCode(request): print('hola: ',timepenalty) print('timepenalty_player',timepenalty.player) timepenalty.no_wa+=1 - res['output'] = 'Wrong answer..' + res['stdout'] = 'Wrong answer..' timepenalty.save() - currUser.save() + currUser.save() res['score'] = currUser.score return HttpResponse(json.dumps(res)) diff --git a/blind_coding/static/js/app.js b/blind_coding/static/js/app.js index 7f31c56..8adb818 100644 --- a/blind_coding/static/js/app.js +++ b/blind_coding/static/js/app.js @@ -1,11 +1,12 @@ // var request = require('request'); $(document).ready(function() { + populateLangs(); var inp = document.getElementsByClassName('noselect')[0]; -getQuestion(0); -inp.addEventListener('select', function() { - this.selectionStart = this.selectionEnd; -}, false); + getQuestion(0); + inp.addEventListener('select', function() { + this.selectionStart = this.selectionEnd; + }, false); document.addEventListener('contextmenu', event => event.preventDefault()); var ctrlDown = false, @@ -70,6 +71,23 @@ let qNo = 0; let tc1 = ''; let tc2 = ''; let tc3 = ''; +let languageIDs = JSON.parse("[{\"id\":45,\"name\":\"Assembly (NASM 2.14.02)\"},{\"id\":46,\"name\":\"Bash (5.0.0)\"},{\"id\":47,\"name\":\"Basic (FBC 1.07.1)\"},{\"id\":48,\"name\":\"C (GCC 7.4.0)\"},{\"id\":52,\"name\":\"C++ (GCC 7.4.0)\"},{\"id\":49,\"name\":\"C (GCC 8.3.0)\"},{\"id\":53,\"name\":\"C++ (GCC 8.3.0)\"},{\"id\":50,\"name\":\"C (GCC 9.2.0)\"},{\"id\":54,\"name\":\"C++ (GCC 9.2.0)\"},{\"id\":51,\"name\":\"C# (Mono 6.6.0.161)\"},{\"id\":55,\"name\":\"Common Lisp (SBCL 2.0.0)\"},{\"id\":56,\"name\":\"D (DMD 2.089.1)\"},{\"id\":57,\"name\":\"Elixir (1.9.4)\"},{\"id\":58,\"name\":\"Erlang (OTP 22.2)\"},{\"id\":44,\"name\":\"Executable\"},{\"id\":59,\"name\":\"Fortran (GFortran 9.2.0)\"},{\"id\":60,\"name\":\"Go (1.13.5)\"},{\"id\":61,\"name\":\"Haskell (GHC 8.8.1)\"},{\"id\":62,\"name\":\"Java (OpenJDK 13.0.1)\"},{\"id\":63,\"name\":\"JavaScript (Node.js 12.14.0)\"},{\"id\":64,\"name\":\"Lua (5.3.5)\"},{\"id\":65,\"name\":\"OCaml (4.09.0)\"},{\"id\":66,\"name\":\"Octave (5.1.0)\"},{\"id\":67,\"name\":\"Pascal (FPC 3.0.4)\"},{\"id\":68,\"name\":\"PHP (7.4.1)\"},{\"id\":43,\"name\":\"Plain Text\"},{\"id\":69,\"name\":\"Prolog (GNU Prolog 1.4.5)\"},{\"id\":70,\"name\":\"Python (2.7.17)\"},{\"id\":71,\"name\":\"Python (3.8.1)\"},{\"id\":72,\"name\":\"Ruby (2.7.0)\"},{\"id\":73,\"name\":\"Rust (1.40.0)\"},{\"id\":74,\"name\":\"TypeScript (3.7.4)\"}]"); + +function populateLangs() +{ + console.log('populating languages...'); + let selectField = document.getElementById('langSelect'); + for(element of languageIDs) + { + console.log('adding.. ',element); + var opt = document.createElement("option"); + opt.value= element['id']; + opt.innerHTML = element['name']; // whatever property it has + + // then append it to the select element + selectField.appendChild(opt); + } +} function setCode(prog){ code = prog; @@ -104,7 +122,7 @@ function getCustomInput(){ } function setOutput(outp) { - output = outp['output']; + output = outp['stdout']; } function getOutput(){ return output @@ -128,6 +146,7 @@ function runCode(){ // Get language chosen by the user and store it let lang = document.getElementById("langSelect").value; + console.log('langCode: ', lang); // setLanguage(lang); // console.log('Language: ', getLanguage(), '\nCode: ', getCode()); @@ -139,9 +158,9 @@ function runCode(){ // Code equals script // script : getCode(), // language: getLanguage(), - script : prog, - language: lang, - versionIndex: versions[versionNo], + source_code : prog, + language_id: lang, + // versionIndex: versions[versionNo], stdin: getCustomInput(), //to give custom input qNo: getQNum(), timeElapsed: time From d3046aa82634f57f3c9e91b5654ca4967f987430 Mon Sep 17 00:00:00 2001 From: Paritosh29 Date: Mon, 6 Jan 2020 06:14:17 +0530 Subject: [PATCH 08/13] Leaderboard Animation --- blind_coding/static/css/style-1.css | 7 +------ blind_coding/static/js/app.js | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/blind_coding/static/css/style-1.css b/blind_coding/static/css/style-1.css index 66a7783..525648e 100644 --- a/blind_coding/static/css/style-1.css +++ b/blind_coding/static/css/style-1.css @@ -501,12 +501,7 @@ tr td, tr th { transition-delay: 0s; } -* { - -webkit-transition: 0.25s all ease; - -moz-transition: 0.25s all ease; - -o-transition: 0.25s all ease; - transition: 0.25s all ease; -} + /* Sidenav body */ diff --git a/blind_coding/static/js/app.js b/blind_coding/static/js/app.js index 8adb818..72c519a 100644 --- a/blind_coding/static/js/app.js +++ b/blind_coding/static/js/app.js @@ -41,7 +41,7 @@ $(document).ready(function() { // Display/hide leaderboard let i = 0; $('.leaderboard-icon').click(function() { - $('.leaderboard').fadeToggle(); + $('.leaderboard').fadeToggle(1000, "swing"); if (i === 0) { $('.li').html('cancel'); i = 1 From cc592a9cf7d7b6f500d61ff2f07b9a88ccdc4cf3 Mon Sep 17 00:00:00 2001 From: dmahajan980 Date: Tue, 7 Jan 2020 07:34:07 +0530 Subject: [PATCH 09/13] Saving changes. --- blind_coding/db.sqlite3 | Bin 86016 -> 87040 bytes .../main_app/__pycache__/urls.cpython-36.pyc | Bin 544 -> 632 bytes .../main_app/__pycache__/views.cpython-36.pyc | Bin 2832 -> 3228 bytes blind_coding/static/css/style-1.css | 7 +++++++ 4 files changed, 7 insertions(+) diff --git a/blind_coding/db.sqlite3 b/blind_coding/db.sqlite3 index 6bf83be7d32f9a637170a3d98bad73110976664e..6295ec57db01c7c667ab5af9d0a44b24abdb7974 100644 GIT binary patch delta 658 zcmZozz}m2ab%Hc+I0FMiC=@eJ)G%iZ-BN zHw#)kV%A{=DrfK#01|v0TufUSxS3oTnEIKOnX;H}GT&ixWzJ>Z&OC|PgXtgBzs-gm zml!91IvT90!tBeKZ(3whl$M)nT3%k9R#lZ*W|UE7QJ7p{P?(%voK%=70#Y>1mr-GI z-!Zkx|Bh)+zI#j&th3UjtRTZUzpARlAg?ODEY~8pvbZ?i!l1ayB&EC{u|NoVLxtXD< zv6;x^)2DJFVg|-~MkbaP21Y`g-A|vFt2Zr8&kXbS3^XxzNzE?u&hab=a0*T>@+~kj z)3vOMtPCx-^folk_A&~Nh&L@Vjw+7~^9;|@O-ePWu<-S9jtbB4G0%^1$+9dlwTQRy zE%9^Ciu85~NlUW~3(U{=49^J<^9eO9@=44JO)>S(&vErC37?_0^j{vF2$%Y)>+wb}?W-@L+qRJ?s z3XewBZb%Hdn3IhW}2oQt8L=AIBm5m8|b@_~~49%?!4D~DxEzOJ!H*4!Xow!+0 z<0Z4I7cWpH9|srHKL#$QEC!~2W@V-zJ3S3bQX`rg=(*rMY3TVRmAcnUR4}dPRA1VvcF4MY=(WMPZ>O-{hOeR9S$= zt4=oLP-FpVnQURAFxmb1UI{Ly(+tdym=7~AVQyu1XHH{!#mvd9!E}1NfDPkhrpXgd z=}f+TDwZGUY*Q;^BRx|Sb2Cd*zRm8Z&&$`uOMiMVUoZd8Zd71vpyh zI+}z#XLuLp`sA0J$NLq!Wd(*iWgFzAC0BZ<7P^;4xD^@}xP?pRi@+`WfwVB zL}mIF7x;&kni(g#85f1+1bCLlX9R`E=L8m+S$br9q(&y|rkPvnX6G8Yx}`g&8yQF# zTIw1a=^7g<7@B}X)j-b(=sFXV&1+wUTkVm!j=&JYRoxA*jD6-MdF4!{7c z1#&C5A5mo#P=&{bxq+Fbnd$aNUW{stY)ozpKNxNURh{1s)Rf7n(QMAg>f2iDNGPPY OEBG?DFoFz43M~M5lbnzM diff --git a/blind_coding/main_app/__pycache__/urls.cpython-36.pyc b/blind_coding/main_app/__pycache__/urls.cpython-36.pyc index 303fe7ba3cbd4937b145771c044b24fc98975e2b..9cd36d9f6aa91ffb9e230a302fff010222bade9f 100644 GIT binary patch delta 421 zcmYk2u};G<5QgI>!ENHCEtH78Q>I8|WIxDY^jeFz@VieQV6>(?IHDHWN1#O1K2;e;^@m%kBN3Ux6)4Q+5qDl)q z(*3hdVD3s(El&y%iKeYF}MDB7=8hL5U*l8ZM>MP?&fzmtoD5n4t@gmoM{B>(dlO~rFJ delta 264 zcmeytvVcX|n3tC;Q;#bykCB1lF#{6d06v-@RqQ}I zzqCZZinFjZwYVfRKTrP_2aKu7c#9=3F*kK`Afp7cpQga%c19ycj>)?irA=?KX6B`& zR@`C*n-j&F6Av_{h!g16B5ojYi@UTary#MUB(*57cqK!TFi1jpGB;DGm=KW3!zjYY N!_30W#R!3Xi~w;qKn?%^ diff --git a/blind_coding/main_app/__pycache__/views.cpython-36.pyc b/blind_coding/main_app/__pycache__/views.cpython-36.pyc index 22d1c8144b515da7a7b8e9a077d537328280f760..93c5df8e25d307943c23f4bec9308dab047c4e74 100644 GIT binary patch delta 467 zcmYjNJxc>Y5Z&4P@VppFA;u^qg%Y_!1O;0~#YPas!VmD{%r25c@6NduOxTbjwt|w@ z%EnHxQ2&EJz~Wkef&ai+k>C#R&Ai>W!!UQ_50&Y~V$pwkEF8TS82e)Xjz#qfA$z-@ zelAwT@#g+;FMX=|W|jNWCJbzmm;soEp#GR?Imy4C~lILcGQk*}Q|2wOO} zW;%DP?apP51SKxeFagiKt4v}XUP!FdMY|NH>3Opes%8?;M_CdFkdHKySjku&t5zz5 z0v5@LHKN>0P)IyJZDG|&2gCSG=5E+cQyGig9`r?8Aj3&RvqXW5w)s#vmmxJcO+pm7 zXs}iHpM7#D8U%G;B%kcS delta 70 zcmbOuIYCU>n3tC;Q;#doiHm{ZF#{4{2C^N1xOm+}<#nt~!3>&`8}He3GHHrWp2NL; Oas-bOqs-)L9(e$(rVZZ! diff --git a/blind_coding/static/css/style-1.css b/blind_coding/static/css/style-1.css index 66a7783..2eb930a 100644 --- a/blind_coding/static/css/style-1.css +++ b/blind_coding/static/css/style-1.css @@ -363,6 +363,7 @@ textarea:focus { color: white; font-size: 20px; padding: 10px 25px; + z-index: 50; } .scoreboard > span { @@ -382,6 +383,12 @@ textarea:focus { table { color: white; + border-radius: 20px; + border: 1px solid white; +} + +tbody { + z-index: 20; } tr { From 6e48b467c2c4c20c1a518c663edae053db08baf6 Mon Sep 17 00:00:00 2001 From: dmahajan980 Date: Tue, 7 Jan 2020 13:15:01 +0530 Subject: [PATCH 10/13] Added functionality to show code. --- blind_coding/db.sqlite3 | Bin 96256 -> 96256 bytes .../main_app/__pycache__/urls.cpython-36.pyc | Bin 632 -> 632 bytes .../main_app/__pycache__/views.cpython-36.pyc | Bin 3228 -> 4097 bytes blind_coding/main_app/templates/loggedIn.html | 4 +- blind_coding/static/css/style-1.css | 15 +- blind_coding/static/js/app.js | 134 +++++++++++------- blind_coding/static/main/loggedIn.html | 4 +- 7 files changed, 102 insertions(+), 55 deletions(-) diff --git a/blind_coding/db.sqlite3 b/blind_coding/db.sqlite3 index 4aeb2e1949c2d6ca290694a4babad3bd9a28d90d..6b7e412eadd0d985352277c520bf642d7f382f78 100644 GIT binary patch delta 476 zcmZqpz}oPEb%HeG!-+D^tPdIVWHxL}S+6T$WT0zcsB2)ZU|?irXl`X>p=V-bXl`M$ zSzGVgR6)jT4E&568JPN+m6@`bTp2e`7C0id*^r}?QB#H4moe2a-`vQ=tSZB>yr9g) z*dQ^nxVWews~|TuJuN#gElq-ffkAcRL`4>m;^_$ij0&6Ok3D5%=4Ue4%zlE8X`-XF zoE)+&Mflz9`An(97A|*uccd&Br9DG9<*w-_#?; zFwr#L%&Z)E62&AFd{!9(n2?+C@&&HHzm9@Imt4;Tngqs zP%s&TgUMXa!qmvn*l6?GSF#CM0@2Xi+{n^m`y($#C0QP3hHeHXSEfTi>ej@G)f&y_ m60E+hwT^^>Z+o5}V*{fYW~fw)vieSs4PdO?ekhC4ju!xa-iZ1D delta 571 zcmZqpz}oPEb%HeGg^4oGtQQ#cOcXYztk;z=wA3{;(ls_zFf_I@G`BJ^)U!0SG&3^X ztgUx#syYJ$10UmW2Bv;yWu`19SEheVTbOP#-(mdCq`;iZyq$Rxvj?*Wm1ZUBDW;i5iMdr~xfUr^g=VG61=*%1c@jY5R4dX`lgx?@%(Ie8a|&}) zQ%!P{lMD^aQj-mmiV6!1^Tkz|eHo`G1TZRWmOu8Ck(rOle>3|DJ|;^e10w@n14CUy z3k5?XD+2>76JtGdOG9&GW01M>n9?SCCgzq##wMHnP92l4H+HJXa4!k2@~-go@z3>( zGK;A4PA^CbaJ0~MGzoXk@Gi{t$uBpL_bYVE3JiD3Hpod!uJleVbT5r?D>N*~3yaU! z4L9|wOvyFME^?}f%JeHP@DD9DGfr|dE(*&D@GOnb2nvtS2`nu z&NXs%OLt6{GBQ8}wFx+=4fKr6%`8n!Hm`jpn}8)E%ni&e%}lpH@?unyN`C)fU$D> Jp)5u_UI5)jrIP>v diff --git a/blind_coding/main_app/__pycache__/urls.cpython-36.pyc b/blind_coding/main_app/__pycache__/urls.cpython-36.pyc index 9cd36d9f6aa91ffb9e230a302fff010222bade9f..c686f044646f9a89c8d8c5bed6c9c5206e116a68 100644 GIT binary patch delta 16 Xcmeyt@`Huln3tC;;f3%<_Ch8AErTiqm{IhEX!78$AqY;Xk(j7C}Rk*LxEG2Fiwoa6l57~x1|}) z&a8WSZA;9;LAi>`6^buF6(52toH_M@3l~h~6XZbgdp#>f3Z{UWn(o)#uitz9`u&@m z?RN0yJ6S#^WnVd7s3V8FDAXP z#~VEO#0r;qlef?>^EU6GUlAQX$GgXj&+~;(tRog);ETM6l~umPm(gG3EBpfbHNMI( zqQAub53J3#7dV-rKDR?Z!P;D}4(~_fG?-zOYKosLVD}?TSU#aoQ=)nwG zx6aPKVAV$dVId@sRHXeMO+=yMJkzZYY##^PDAH9pXFE*?jd zR1v{~)MGK(Mf<*+&N}br*sm3 z>Y{B-YiNV1hqgJb$JW#@-O}goZL74=*U;C{d+0s%b@X-g{%uRO3`Hwx^TshtI+zVG z>++`IM^u7UI30M;LB4M3lVrG!*7jj-q8`8TjnIQFZcj$AbLUBxYu}hAIfV0MI}aO0 zG#Y<+7YLz8;Jr+nsZ{*X_(pvKPa4ELY!L9lFqcBxd-3MHb`v?l83maB0l8{pOj=++9i& zRB;WB#TJ;4x5K>I>zXmm`D__qikp}P-De{?YO{&HK?G(t>TWGNedRkxPNTJrfP|GWKBI4aHpbqgyeux zqx6hbP^xHFFzB{Gv98)lhqq_6yt018DjK{~di$RI4A>pWHixgfZ_Ce~U;Wa|KOn=I zeNX=Uh@|s~BH6W?Gbe;4@_C%E!54_`r%bK`^7-Oz>rLp7;%Fb!r}4vdDIWiy#K+HEEaGwn8$#R{6XAbX2sFB`6v z^wbh)tdKvwZQ0hKSGK@yan;(lKegqrq1g+B%U3Jz*xN{!jV@OzXxhe{(Qer;;g|fP z+4)!OTr)c_(fn+1uNQSjj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&?Jm*CS$BW zDPtwnFX*quA5YXzX>uDN>V43DkFO%vWw_>$dwBcY0Teco7&=bJv0TGlGY~0kDfg?h zQfb7A%3h)^d(`)_+*XH*>Lt@%uu`B=RAeZ+uO`6-IS`pu&6aKY+*okanW*GsKc4Bc z1|_t;=-z97?^705u`X4m1|*v5DMhu7Ot47S4nyz1Eb{Kk diff --git a/blind_coding/main_app/templates/loggedIn.html b/blind_coding/main_app/templates/loggedIn.html index b50cfd8..93a6273 100644 --- a/blind_coding/main_app/templates/loggedIn.html +++ b/blind_coding/main_app/templates/loggedIn.html @@ -109,7 +109,9 @@
Question 1
- + + +
diff --git a/blind_coding/static/css/style-1.css b/blind_coding/static/css/style-1.css index 66a7783..e095cd9 100644 --- a/blind_coding/static/css/style-1.css +++ b/blind_coding/static/css/style-1.css @@ -178,8 +178,8 @@ nav#header ul a { .options { display: flex; - margin: 8px 0 0 0; - justify-content: space-around; + margin: 15px 0 0 0; + justify-content: center; } button { @@ -287,8 +287,14 @@ textarea:focus { background: black; } -.run,.submit{ +.bttn,.submit, #showCode{ width: 10vw; + background-color: rgba(57, 255, 216, 0.8); + transition: all 100ms ease-in 50ms; +} + +.bttn:nth-child(1) { + margin-right: 3.5vw; } #footer p { @@ -588,7 +594,8 @@ a { #codeInput{ color: black; - caret-color: white; + caret-color: white; + transition: color 100ms ease-out; } ::selection{ diff --git a/blind_coding/static/js/app.js b/blind_coding/static/js/app.js index 8adb818..8fdd4f1 100644 --- a/blind_coding/static/js/app.js +++ b/blind_coding/static/js/app.js @@ -79,7 +79,7 @@ function populateLangs() let selectField = document.getElementById('langSelect'); for(element of languageIDs) { - console.log('adding.. ',element); + // console.log('adding.. ',element); var opt = document.createElement("option"); opt.value= element['id']; opt.innerHTML = element['name']; // whatever property it has @@ -189,53 +189,53 @@ const sendRequest = (method, url, data) => { ourRequest.onload = function() { if (ourRequest.status >= 200 && ourRequest.status < 400) { // console.log('output: '); - console.log('success 200'); - if(url == 'runCode/'){ - console.log('1'); - let recievedData = JSON.parse(ourRequest.responseText); - console.log('receivedData: ', recievedData); - setOutput(recievedData); - document.getElementById("compilerOutput").value = getOutput(); - document.getElementById('score').innerHTML = recievedData['score']; - console.log(recievedData['score']); - if(getOutput() == 'Correct Answer') - { - s = 0; - m = 0; - qNo = (getQNum() + 1) % 5; - console.log(qNo); - document.getElementsByClassName('left')[0].getElementsByTagName('h5')[0] = "Question "+qNo; - document.getElementsByClassName('left')[0].innerHTML = getQuestion(qNo); - console.log("OO"); + // console.log('success 200'); + if(url == 'runCode/'){ + console.log('1'); + let recievedData = JSON.parse(ourRequest.responseText); + console.log('receivedData: ', recievedData); + setOutput(recievedData); + document.getElementById("compilerOutput").value = getOutput(); + document.getElementById('score').innerHTML = recievedData['score']; + console.log(recievedData['score']); + if(getOutput() == 'Correct Answer') + { + s = 0; + m = 0; + qNo = (getQNum() + 1) % 5; + console.log(qNo); + document.getElementsByClassName('left')[0].getElementsByTagName('h5')[0] = "Question "+qNo; + document.getElementsByClassName('left')[0].innerHTML = getQuestion(qNo); + console.log("OO"); + } + increaseTime(); + return recievedData; + } + else{ + console.log('2'); + let recievedData = JSON.parse(ourRequest.responseText); + let inpt = recievedData['sampIn'].split(' '); + let inStr = ''; + for(let i = 0; i < inpt.length;i++) + { + inStr += inpt[i]; + inStr += '\n'; + } + let que = recievedData['question'] + '

'+'Sample Input'+'
'+recievedData['sampTCNum']+'
'+inStr+'

'+'Sample Output'+'
'+recievedData['sampleOut']; + console.log('hi ',recievedData); + document.getElementsByClassName('left')[0].innerHTML=que; + qNo = recievedData['qNo']; + // console.log(qNo); + // console.log(recievedData['userScore']); + document.getElementById('score').innerHTML = recievedData['userScore']; + console.log(recievedData); + return recievedData; } - increaseTime(); - return recievedData; - } - else{ - console.log('2'); - let recievedData = JSON.parse(ourRequest.responseText); - let inpt = recievedData['sampIn'].split(' '); - let inStr = ''; - for(let i = 0; i < inpt.length;i++) - { - inStr += inpt[i]; - inStr += '\n'; - } - let que = recievedData['question'] + '

'+'Sample Input'+'
'+recievedData['sampTCNum']+'
'+inStr+'

'+'Sample Output'+'
'+recievedData['sampleOut']; - console.log('hi ',recievedData); - document.getElementsByClassName('left')[0].innerHTML=que; - qNo = recievedData['qNo']; - console.log(qNo); - console.log(recievedData['userScore']); - document.getElementById('score').innerHTML = recievedData['userScore']; - console.log(recievedData); - return recievedData; - } } else { // Nothing // startClock(); - console.log("OO") + // console.log("OO") increaseTime() } } @@ -243,11 +243,11 @@ const sendRequest = (method, url, data) => { ourRequest.onerror = function() { // Nothing // startClock(); - console.log("OO") + // console.log("OO") increaseTime() } - console.log(JSON.stringify(data)); + // console.log(JSON.stringify(data)); ourRequest.send(JSON.stringify(data)); }; @@ -262,6 +262,8 @@ const getQuestion = queNum => { // let data = { queNum }; // sendRequest('POST', '/question/', data); sendRequest('POST', '/question/', { queNum }); + // console.log(queNum) + // clicks = 0; }; window.onresize = function() { @@ -305,8 +307,8 @@ function closeAbout() { document.addEventListener('DOMContentLoaded', function() { var elems = document.querySelectorAll('select'); - console.log('hikljhg'); -// var instances = M.FormSelect.init(elems, options); + // console.log('hikljhg'); + // var instances = M.FormSelect.init(elems, options); }); // Or with jQuery @@ -421,8 +423,44 @@ function pauseTime() { clearInterval(timerId); } +// Won't allow user to cheat by changing text-color +let codeIntervalId; +let clicks = 0; +const hideCode = () => { + codeIntervalId = setInterval(() => document.getElementById('codeInput').style.color = 'black', 200) +} + +const showCode = () => { + const box = document.getElementById('codeInput') + + if (box.disabled === false) { + // Functionality won't be achieved after two clicks + if (clicks === 2) { + box.disabled = true; + alert('You have used up your time!') + return; + } + else { + // Disable button and show code for 5 seconds + box.disabled = true; + clearInterval(codeIntervalId); + box.style.color = 'white'; + setTimeout(() => { + hideCode() + box.disabled = false; + }, 5000) + } + clicks++; + console.log(clicks) + } +} + +document.getElementById('showCode').addEventListener('click', () => { + showCode() +}) + window.onload = () => { // startClock(); - console.log("OO") increaseTime() + hideCode(); } diff --git a/blind_coding/static/main/loggedIn.html b/blind_coding/static/main/loggedIn.html index 2ce878c..ee48f07 100644 --- a/blind_coding/static/main/loggedIn.html +++ b/blind_coding/static/main/loggedIn.html @@ -32,8 +32,8 @@
- - + +
From 04de859315f9a65dcd0fc91248a5834a7bd91e1b Mon Sep 17 00:00:00 2001 From: HarpinderJotSingh Date: Tue, 7 Jan 2020 19:22:44 +0530 Subject: [PATCH 11/13] Code editor was disabled after two attempts of show code, enabled it back --- blind_coding/static/js/app.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/blind_coding/static/js/app.js b/blind_coding/static/js/app.js index 8fdd4f1..657c40a 100644 --- a/blind_coding/static/js/app.js +++ b/blind_coding/static/js/app.js @@ -431,13 +431,13 @@ const hideCode = () => { } const showCode = () => { - const box = document.getElementById('codeInput') + const box = document.getElementById('codeInput'); if (box.disabled === false) { // Functionality won't be achieved after two clicks - if (clicks === 2) { - box.disabled = true; - alert('You have used up your time!') + if (clicks >= 2) { + // box.disabled = false; + alert('You have used up your time!'); return; } else { @@ -448,10 +448,13 @@ const showCode = () => { setTimeout(() => { hideCode() box.disabled = false; - }, 5000) + }, 5000); } clicks++; - console.log(clicks) + console.log(clicks); + } + else{ + alert('You have used up your time!'); } } From fdb6ceaeb36c5778e92ffce5f9ac89b9a21b5850 Mon Sep 17 00:00:00 2001 From: HarpinderJotSingh Date: Tue, 7 Jan 2020 19:53:16 +0530 Subject: [PATCH 12/13] Changed alerts to sweet alerts - alert msgs with css applied --- blind_coding/main_app/templates/loggedIn.html | 1 + blind_coding/static/js/app.js | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/blind_coding/main_app/templates/loggedIn.html b/blind_coding/main_app/templates/loggedIn.html index 93a6273..8652c7a 100644 --- a/blind_coding/main_app/templates/loggedIn.html +++ b/blind_coding/main_app/templates/loggedIn.html @@ -11,6 +11,7 @@ + diff --git a/blind_coding/static/js/app.js b/blind_coding/static/js/app.js index 657c40a..1c44a48 100644 --- a/blind_coding/static/js/app.js +++ b/blind_coding/static/js/app.js @@ -269,7 +269,12 @@ const getQuestion = queNum => { window.onresize = function() { if ((window.outerHeight - window.innerHeight) > 100) { // console was opened (or screen was resized) - alert("Sorry! You will be logged out since you didn't follow the instructions."); + // alert("Sorry! You will be logged out since you didn't follow the instructions."); + Swal.fire( + 'Sorry', + "You will be logged out since you didn't follow the instructions", + 'warning' + ) window.location.href = "/logout" } } @@ -437,7 +442,12 @@ const showCode = () => { // Functionality won't be achieved after two clicks if (clicks >= 2) { // box.disabled = false; - alert('You have used up your time!'); + // alert('You have used up your time!'); + Swal.fire( + 'Sorry..', + 'You have used up your time!', + 'error' + ); return; } else { @@ -454,7 +464,12 @@ const showCode = () => { console.log(clicks); } else{ - alert('You have used up your time!'); + // alert('You have used up your time!'); + Swal.fire( + 'Sorry..', + 'You have used up your time!', + 'warning' + ); } } From a2b928141e47e1d63a757fbac3c4960afb32f892 Mon Sep 17 00:00:00 2001 From: HarpinderJotSingh Date: Tue, 7 Jan 2020 20:49:28 +0530 Subject: [PATCH 13/13] Added instructions, cleared editor after correct answer and logged user out after all correct responses --- README.md | 10 ++++----- blind_coding/main_app/templates/loggedIn.html | 21 ++++++++++-------- blind_coding/main_app/views.py | 4 ++++ blind_coding/static/css/style-1.css | 2 +- blind_coding/static/css/style.css | 2 +- blind_coding/static/js/app.js | 22 ++++++++++++++----- 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index bd66bd0..90be3d0 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ - [X] Timer is not working properly, fix it - [X] When user gets a question correct, automatically redirect to next question - [X] Add a live leaderboard -- [ ] Change frontend -- [ ] Add details in about section -- [ ] Cursor does not goes up in the editor, fix it +- [X] Change frontend - Leaderboard opening animation is inserted, might require to change other background colors and stuff later. +- [X] Add details in about section +- [X] Cursor does not goes up in the editor, fix it - [ ] Do Backend stuff - do not put keys as it is within the files -- [ ] Add feature to show code for sometime, say 5-10 seconds once per question +- [X] Add feature to show code for sometime, say 5-10 seconds once per question - [ ] Disable run button for the time compiler runs the code and returns the result to prevent multiple compiler runs -- [ ] Limit number of runs per question per user +- [X] Limit number of runs per question per user - feature not needed anymore diff --git a/blind_coding/main_app/templates/loggedIn.html b/blind_coding/main_app/templates/loggedIn.html index b50cfd8..4329814 100644 --- a/blind_coding/main_app/templates/loggedIn.html +++ b/blind_coding/main_app/templates/loggedIn.html @@ -60,20 +60,23 @@
-
-
+
+
-

About

-
1. What is Lorem Ipsum?
-

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

-
2. Where does it come from?
-

Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested.

-
+

Instructions

+
- There are five questions of varying difficulties and points associated with them.
Score associated are 20, 30, 40, 50, 60 points respectively.
+
- For every question, the first time you submit the correct answer, you are awarded points corresponding to that question and the time penalty is + also calculated which takes into consideration the time taken until last successful solve together with the number of wrong attempts
+
- Standings will be based on the points scored and in cases of clashes, time penalties are compared and one with lesser time penalty is better ranker
+
- Every time you give a correct answer, the question is automatically changed and code editor is reset.
+
- You have only two attempts throughout the event to see the code you have written. To see the code, press Show Code button near Run button.
+
- Don't try to open up the console or changing the window/tab. You'll be logged out immediately
+