Skip to content

Commit ef2cd36

Browse files
committedDec 26, 2019
added random question feature
1 parent 1efa273 commit ef2cd36

19 files changed

+150
-4
lines changed
 

‎README.md

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
11
# Codeara
2-
An Online Code Execution Platform using SPOJ API
2+
An Online Code Execution Platform using API
3+
4+
> This app is used to compile and execute the program with login feature. It also has sample problems and
5+
user's progress record.
6+
7+
## Starting the Project
8+
9+
* Fork and Clone the repository
10+
11+
12+
* Create a virtualenv with python and activate it
13+
```
14+
virtualenv env
15+
16+
source env/bin/activate
17+
```
18+
19+
* Move into the folder and install required dependencies
20+
```
21+
pip install -r requirements.txt
22+
```
23+
24+
* Run the Migrations
25+
```
26+
python manage.py makemigrations
27+
28+
python manage.py migrate
29+
30+
```
31+
* Run the development server
32+
```
33+
python manage.py runserver
34+
35+
```
36+
* Head to server http://localhost:8000
37+
38+
* Add Few Questions in Question model to display random questions
39+
40+
## For Contribution
41+
42+
* Solve an issue or add any feature.
43+
* Open any issue or request some nice features.
44+
74 Bytes
Binary file not shown.
614 Bytes
Binary file not shown.

‎compiler/admin.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from django.contrib import admin
2+
from .models import Question
23

3-
# Register your models here.
4+
admin.site.register(Question)

‎compiler/migrations/0001_initial.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 3.0.1 on 2019-12-26 03:26
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Question',
16+
fields=[
17+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('qno', models.IntegerField(default=0)),
19+
('text', models.CharField(max_length=45000)),
20+
('testcaseno', models.IntegerField(default=0)),
21+
('samplein', models.CharField(default='', max_length=45000)),
22+
('sampleout', models.CharField(default='', max_length=45000)),
23+
('tc1', models.CharField(max_length=1000)),
24+
('tc2', models.CharField(max_length=1000)),
25+
('tc3', models.CharField(max_length=1000)),
26+
('tc1_sol', models.CharField(max_length=1000)),
27+
('tc2_sol', models.CharField(max_length=1000)),
28+
('tc3_sol', models.CharField(max_length=1000)),
29+
],
30+
),
31+
]
Binary file not shown.

‎compiler/models.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
from django.db import models
22

3-
# Create your models here.
3+
class Question(models.Model):
4+
qno = models.IntegerField(default=0)
5+
text = models.CharField(max_length=45000)
6+
testcaseno = models.IntegerField(default=0)
7+
samplein = models.CharField(max_length=45000,default='')
8+
sampleout = models.CharField(max_length=45000,default='')
9+
tc1 = models.CharField(max_length=1000)
10+
tc2 = models.CharField(max_length=1000)
11+
tc3 = models.CharField(max_length=1000)
12+
tc1_sol = models.CharField(max_length=1000)
13+
tc2_sol = models.CharField(max_length=1000)
14+
tc3_sol = models.CharField(max_length=1000)
415

16+
def __str__(self):
17+
return str(self.pk)

‎compiler/static/compiler/css/theme.css

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ body {
1717
body * {
1818
font-family: 'Quicksand', sans-serif;
1919
}
20+
#q_id{
21+
text-decoration-color:#00c853;
22+
background-color: #E8EAF6;
23+
font-size: 14px !important;
24+
}
2025
#spacing {
2126
padding-top: 40%;
2227
}

‎db.sqlite3

4 KB
Binary file not shown.

‎user/__pycache__/admin.cpython-37.pyc

70 Bytes
Binary file not shown.
309 Bytes
Binary file not shown.

‎user/__pycache__/urls.cpython-37.pyc

0 Bytes
Binary file not shown.

‎user/__pycache__/views.cpython-37.pyc

135 Bytes
Binary file not shown.

‎user/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
from django.contrib import admin
2+
from .models import User
3+
4+
admin.site.register(User)

‎user/migrations/0003_user.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 3.0.1 on 2019-12-26 03:26
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
('user', '0002_auto_20191225_1031'),
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='User',
17+
fields=[
18+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19+
('name', models.CharField(max_length=250)),
20+
('ques', models.IntegerField(default=0)),
21+
('points', models.IntegerField(default=0)),
22+
],
23+
),
24+
]
Binary file not shown.

‎user/models.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
from django.db import models
22
from django.contrib.auth.models import User
33

4+
class User(models.Model):
5+
name = models.CharField(max_length=250)
6+
ques = models.IntegerField(default=0)
7+
points = models.IntegerField(default=0)
8+
source_code = models.CharField(max_length=4500)
9+

‎user/templates/home.html

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
{% extends 'base.html' %}
22

3+
{% block content %}
4+
<head>
5+
{% load static %}
6+
<link href="{% static 'compiler/css/theme.css' %}" rel="stylesheet" type="text/css"/>
7+
</head>
8+
<div class="w3-container w3-teal" id="q_id">
9+
<h1> Question of the Day!!</h1>
10+
<ol>
11+
Question No. {{q_num.qno}} :
12+
{{q_num.text}}<br><br>
13+
SAMPLE INPUT : <br>
14+
{{q_num.samplein}}<br><br>
15+
SAMPLE OUTPUT : <br>
16+
{{q_num.sampleout}} <br><br>
317

18+
</ol>
19+
</div>
20+
{% endblock content %}

‎user/views.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
from django.contrib.auth.models import User
66
from django.http import HttpResponse, JsonResponse
77
import os
8+
from compiler.models import Question
89
from decouple import config
910

1011
def home(request):
11-
return render(request,"home.html")
12+
ques = Question.objects.order_by('?').first()
13+
#ques = Question.objects.all()
14+
question = {"q_num":ques}
15+
return render(request,"home.html", question)
1216

1317
def signup(request):
1418
if request.method == 'POST':

0 commit comments

Comments
 (0)
Please sign in to comment.