Skip to content

Commit

Permalink
Merge pull request #42 from H-Huang/develop
Browse files Browse the repository at this point in the history
Merging develop with master
  • Loading branch information
H-Huang authored May 21, 2017
2 parents 6e02f59 + ef99c00 commit cdf96bc
Show file tree
Hide file tree
Showing 38 changed files with 1,468 additions and 219 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*pycache*
*.pyc
*.DS_Store
.vscode
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: python
python:
- "3.6"
services:
- postgresql
env:
- DJANGO=1.11.1
install:
- pip install -r requirements.txt
before_script:
- psql -c "CREATE DATABASE travisci;" -U postgres
script:
- python manage.py hello_world
notifications:
email:
recipients:
- howardhuang96@gmail.com
on_success: never
on_failure: change
5 changes: 3 additions & 2 deletions LL1_Academy/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin
from .models import Grammar, Question
from .models import Grammar, Question, UserHistory

# Register your models here.
admin.site.register(Grammar)
admin.site.register(Question)
admin.site.register(Question)
admin.site.register(UserHistory)
8 changes: 8 additions & 0 deletions LL1_Academy/management/commands/clearhistory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.core.management.base import BaseCommand, CommandError
from LL1_Academy.models import UserHistory

class Command(BaseCommand):
help = 'This will delete all grammars in the database be careful'

def handle(self, *args, **options):
UserHistory.objects.all().delete()
71 changes: 71 additions & 0 deletions LL1_Academy/migrations/0007_auto_20170516_0741.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-05-16 07:41
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('LL1_Academy', '0006_auto_20170511_0441'),
]

operations = [
migrations.CreateModel(
name='UserHistory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('complete', models.BooleanField(default=False)),
('score', models.IntegerField(blank=True)),
('updateTime', models.DateTimeField(auto_now=True)),
],
),
migrations.AddField(
model_name='grammar',
name='nComplete',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='grammar',
name='nSkip',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='grammar',
name='nStart',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='question',
name='nCorrect',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='question',
name='nGiveUp',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='question',
name='nWrong',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='userhistory',
name='grammar',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='LL1_Academy.Grammar'),
),
migrations.AddField(
model_name='userhistory',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
migrations.AlterUniqueTogether(
name='userhistory',
unique_together=set([('user', 'grammar')]),
),
]
20 changes: 20 additions & 0 deletions LL1_Academy/migrations/0008_auto_20170518_0742.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-05-18 07:42
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('LL1_Academy', '0007_auto_20170516_0741'),
]

operations = [
migrations.AlterField(
model_name='userhistory',
name='score',
field=models.IntegerField(blank=True, null=True),
),
]
20 changes: 20 additions & 0 deletions LL1_Academy/migrations/0009_auto_20170518_0803.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-05-18 08:03
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('LL1_Academy', '0008_auto_20170518_0742'),
]

operations = [
migrations.AlterField(
model_name='userhistory',
name='updateTime',
field=models.DateTimeField(),
),
]
20 changes: 20 additions & 0 deletions LL1_Academy/migrations/0010_auto_20170520_2226.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-05-20 22:26
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('LL1_Academy', '0009_auto_20170518_0803'),
]

operations = [
migrations.AlterField(
model_name='userhistory',
name='score',
field=models.IntegerField(default=-1),
),
]
31 changes: 28 additions & 3 deletions LL1_Academy/models.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User

# Create your models here.
class Grammar(models.Model):

gid = models.AutoField(primary_key = True)
prods = models.CharField(max_length=200)
nonTerminals = models.CharField(max_length=4)
terminals = models.CharField(max_length=4)
startSymbol = models.CharField(max_length=1)
nStart = models.IntegerField(default=0)
nComplete = models.IntegerField(default=0)
nSkip = models.IntegerField(default=0)


def __str__(self):
return str(self.gid) + ' ' + self.prods

Expand All @@ -27,9 +30,31 @@ class Question(models.Model):
category = models.CharField(max_length = 2, choices = QUESTION_TYPES)
symbol = models.CharField(max_length = 1, blank = True)
answer = models.CharField(max_length = 300)
nCorrect = models.IntegerField(default=0)
nWrong = models.IntegerField(default=0)
nGiveUp = models.IntegerField(default=0)

def __str__(self):
return str(self.gid.gid) + ' ' + str(self.qnum) + ' ' + self.category

class Meta:
unique_together = (("gid","qnum"))
unique_together = (("gid","qnum"))

class UserHistory(models.Model):
user = models.ForeignKey(User, on_delete = models.CASCADE)
grammar = models.ForeignKey(Grammar, on_delete = models.CASCADE)
complete = models.BooleanField(default=False)
score = models.IntegerField(default=-1)
updateTime = models.DateTimeField()

def __str__(self):
return str(self.user) + ' ' + str(self.grammar.gid)

def save(self, *args, **kwargs):
if self.complete and self.score < 0:
raise Exception("Score cannot be blank for a completed question")
self.updateTime = timezone.now()
super(UserHistory, self).save(*args, **kwargs)

class Meta:
unique_together = (("user","grammar"))
13 changes: 9 additions & 4 deletions LL1_Academy/templates/LL1_Academy/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<title>LL(1) - {% block title %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="/static/img/ll1-logo.ico" type="image/jpg" sizes="32x32">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.1/css/foundation.min.css" />
<link rel="stylesheet" href="{% static 'css/main.css' %}" />
<link rel="stylesheet" href="https://cdn.iconmonstr.com/1.2.0/css/iconmonstr-iconic-font.min.css">
Expand All @@ -12,11 +13,15 @@
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
</head>

{% block templates %}
{% endblock %}
{% block templates %}
{% endblock %}

<body style="font-family: 'Lato', sans-serif;">
{% block content %}

{% block indexcontent %}
{% endblock %}

{% block navbarpages %}
{% endblock %}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
Expand All @@ -29,6 +34,6 @@

{% block pagescripts %}
{% endblock %}

</body>

</html>
47 changes: 47 additions & 0 deletions LL1_Academy/templates/LL1_Academy/_navbarPages.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "LL1_Academy/_base.html" %}

{% load static %}

{% block navbarpages %}
<div id="page-wrap">
<div id="main">
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}

<div id="navbar">
<div id="navbarLearn">
<a href="learn"><button class="button indexButtons" id="navbarLearnButton">Learn</button></a>
</div>
<div id="navbarTitle">
<a href="/index"><h1 id="siteBanner">LL(1) Academy</h1></a>
</div>
<div id="navbarUser">
{% if user.is_authenticated %}
<p style="color:white;font-size:20px;">Welcome back <a href="/profile" style="font-weight: bold;">{{ user.username }}</a>!</p>
<!--<img src="{{user.socialaccount_set.all.0.get_avatar_url}}">-->
<a href="/accounts/logout" style="justify-content:center;"><button class="button indexButtons navbarUserButton">Logout</button></a>
{% else %}
<a href="/index"><button class="button indexButtons navbarUserButton">Login</button></a>
{% endif %}
</div>
</div>

<div class="container">
{% block content %}
{% endblock %}
</div>

</div>
</div>
<div id="footer">
<a href="/index" class="footerLinks"><img src="{% static 'img/LL1-logo.ico' %}" style="height:20px;margin-right:5px;">Home</a>
<!--<a href="/index" class="footerLinks"><img src="{% static 'img/LL1-logo-white_white.png' %}" style="height:20px;margin-right:5px;">Home</a>-->
<a href="/about" class="footerLinks">About</a>
<a href="https://github.com/vivz/LL1-Academy" class="footerLinks">Github</a>
</div>
{% endblock %}
10 changes: 10 additions & 0 deletions LL1_Academy/templates/LL1_Academy/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "LL1_Academy/_navbarPages.html" %}

{% block title %}About{% endblock %}

{% block content %}

<h2> ABOUT US </h2>


{% endblock %}
32 changes: 28 additions & 4 deletions LL1_Academy/templates/LL1_Academy/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
{% extends "LL1_Academy/_base.html" %}
{% block content %}

{% load static %}

{% block title %}Homepage{% endblock %}

{% block indexcontent %}
<div id="landingPage">
<img src="{% static 'img/LL1-logo-white_white.png' %}" style="height:125px;margin-bottom:20px;">
<h1 id="siteTitle">LL(1) Academy</h1>
<div id="startButton">
<a href="learn"><button class="button" id="startLearning">Start Learning</button></a>
<div id="loginActions">
{% if user.is_authenticated %}
<p style="color:white;font-size:30px;">Welcome back <a href="profile" style="font-weight: bold;">{{ user.username }}</a>!</p>
<a href="accounts/logout"><button class="button indexButtons">Logout</button></a>
<p style="display:inline;color: white;margin-left:10px; margin-right:10px;">or</p>
<a href="learn"><button class="button indexButtons">Start Learning</button></a>
{% else %}
<!--<a href="login"><button class="button indexButtons">Login</button></a>
<p style="display:inline;color: white;margin-left:10px; margin-right:10px;">or</p>
<a href="register"><button class="button indexButtons">Register</button></a>
<p style="color: white;font-size:20px;margin: 1rem 0 1rem 0;">Or continue without an account</p>-->
{% block login_error %}
{% endblock %}
{% load socialaccount %}
{% providers_media_js %}
<div class="loginOption"><a href="{% provider_login_url "facebook" method="js_sdk" %}"><button class="button indexButtons" style="width:225px;">Login with Facebook</button></a></div>
<div class="loginOption"><p style="display:inline;color: white;margin:1rem 10px 1rem 10px;">or</p></div>
<div class="loginOption"><a href="{% provider_login_url "google" method="oauth2" %}"><button class="button indexButtons" style="width:225px;">Login with Google</button></a></div>
{% endif %}

</div>
</div>

{% endblock %}
Loading

0 comments on commit cdf96bc

Please sign in to comment.