Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed bugs after testing => #3

Merged
merged 2 commits into from Jan 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified blind_coding/db.sqlite3
Binary file not shown.
18 changes: 18 additions & 0 deletions blind_coding/main_app/migrations/0004_userdata_chancesused.py
@@ -0,0 +1,18 @@
# Generated by Django 2.2.7 on 2020-01-11 10:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main_app', '0003_auto_20200104_1332'),
]

operations = [
migrations.AddField(
model_name='userdata',
name='chancesUsed',
field=models.IntegerField(default=0),
),
]
1 change: 1 addition & 0 deletions blind_coding/main_app/models.py
Expand Up @@ -6,6 +6,7 @@ class Userdata(models.Model):
user_id=models.ForeignKey(User,on_delete=models.CASCADE)
name=models.CharField(max_length=100)
score = models.IntegerField(default = 0)
chancesUsed = models.IntegerField(default = 0)
answerGiven = models.CharField(max_length = 10, default="00000")
timeElapsed = models.IntegerField(default = 0)
total_penalty=models.IntegerField(default = 0)
Expand Down
29 changes: 17 additions & 12 deletions blind_coding/main_app/templates/index.html
Expand Up @@ -14,20 +14,24 @@
<img src="../../static/assets/apogeeLogo.png" id="apogeeLogo">
<div class="backdrop">
</div>
<div class="about">
<div id="close" onclick="closeAbout()">
<span class="horiz"></span>
<span class="verti"></span>
</div>
<h1>Instructions</h1>
<h4>1. What is Lorem Ipsum?</h4>
<h4>2. Where does it come from?</h4>

</div>
<div class="instructions">
<div id="close" onclick="closeInstructions()">
<span class="horiz"></span>
<span class="verti"></span>
</div>
<h3>Instructions</h3>
<h5>- There are five questions of varying difficulties and points associated with them. <br> Score associated are 20, 30, 40, 50, 60 points respectively.</h5>
<h5>- 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</h5>
<h5>- 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</h5>
<h5>- Every time you give a correct answer, the question is automatically changed and code editor is reset.</h5>
<h5>- 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.</h5>
<h5>- Don't try to open up the console or changing the window/tab. You'll be logged out immediately</h5>
</div>
<div class="container">
<nav id="header">
<ul>
<li onclick="showAbout()">About</li>
<li onclick="showInstructions()">Instructions</li>
<a href="/login"><li>Login</li></a>
</ul>
</nav>
Expand All @@ -51,6 +55,7 @@ <h4>2. Where does it come from?</h4>
<img src="../../static/assets/club-logo.svg" class="club-logo">
</div>
</div>
<!-- <script src="../../static/js/script.js"></script>-->
<script src="/static/js/app.js"></script>
<script src="/static/js/script.js" type="text/javascript"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion blind_coding/main_app/templates/loggedIn.html
Expand Up @@ -113,7 +113,7 @@ <h5>Question 1</h5>
</div>

<div class="options">
<button class="bttn" onclick="runCode()">Run</button>
<button class="bttn" id="runBtn" onclick="runCode()">Run</button>
<button class="bttn" id="showCode">Show Code</button>
<!-- <div class="time-left">10</div> -->
</div>
Expand Down
4 changes: 3 additions & 1 deletion blind_coding/main_app/urls.py
Expand Up @@ -11,5 +11,7 @@
path('logout/', views.l_out, name='logout'),
path('question/', views.question, name='question'),
path('main/runCode/', views.runCode, name='runCode'),
path('leaderboard/', views.leaderboard, name='leaderboard')
path('leaderboard/', views.leaderboard, name='leaderboard'),
path('getChancesUsed/', views.getChancesUsed, name='getChancesUsed'),
path('increaseClicks/', views.increaseClicks, name='increaseClicks'),
]
15 changes: 15 additions & 0 deletions blind_coding/main_app/views.py
Expand Up @@ -143,3 +143,18 @@ def leaderboard(request):
resp = {'username': username, 'score': score}

return HttpResponse(json.dumps(resp), content_type='application/json')

def getChancesUsed(request):
res={}
res['chancesUsed'] = Userdata.objects.get(user_id = request.user).chancesUsed
return HttpResponse(json.dumps(res))

def increaseClicks(request):
data = json.loads( request.body.decode('utf-8') )
clicks = data['clicks']
user = Userdata.objects.get(user_id = request.user)
user.chancesUsed = clicks
user.save()
res = {}
res['error'] = 'No Error'
return HttpResponse(json.dumps(res))