Skip to content

Commit

Permalink
Merging Develop into Master, ready for alpha testing and tag v0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
vivz authored May 26, 2017
2 parents 3561c93 + 6ad3822 commit 0cdfe4b
Show file tree
Hide file tree
Showing 16 changed files with 316 additions and 180 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ install:
before_script:
- psql -c "CREATE DATABASE travisci;" -U postgres
script:
- python manage.py hello_world
- python manage.py test
notifications:
email:
recipients:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
on_success: never
on_failure: change
on_failure: always
2 changes: 1 addition & 1 deletion LL1_Academy/templates/LL1_Academy/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>LL(1) Academy - {% block title %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="LL(1) Academy" />
<meta property="og:image" content="http://i.imgur.com/cZ0wjGw.png" />
<meta property="og:image" content="https://i.imgur.com/cZ0wjGw.png" />
<meta property="og:description" content="Better your understanding of LL(1) Grammars." />
<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" />
Expand Down
13 changes: 8 additions & 5 deletions LL1_Academy/templates/LL1_Academy/_navbarPages.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
{% if user.is_authenticated %}
<p style="color:white;font-size:20px;">Welcome back <a href="/profile" style="font-weight: bold;text-transform: capitalize;">{{ user.username }}</a>! <a href="/profile"><img src="{{user.socialaccount_set.all.0.get_avatar_url}}" class="img-circle"></a></p>
{% if request.path != '/learn' %}
<a href="learn"><button class="button indexButtons navbarButton">Learn</button></a>
<a href="/learn"><button class="button indexButtons navbarButton">Learn</button></a>
{% endif %}
<a href="/accounts/logout" style="justify-content:center;"><button class="button indexButtons navbarButton">Logout</button></a>
{% else %}
<a href="learn"><button class="button indexButtons navbarButton">Learn</button></a>
{% if request.path != '/learn' %}
<a href="/learn"><button class="button indexButtons navbarButton">Learn</button></a>
{% endif %}
<a href="/index"><button class="button indexButtons navbarButton">Login</button></a>
{% endif %}
</div>
Expand All @@ -42,9 +44,10 @@
</div>
</div>
<div class="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" style="margin-right: 24px;"><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 middle">About</a>
<a href="https://github.com/vivz/LL1-Academy" class="footerLinks">Github</a>
<a href="/about" class="footerLinks" style="margin-right: 24px;">About</a>
<a href="https://github.com/vivz/LL1-Academy" class="footerLinks" style="margin-right: 24px;">Github</a>
<a href="https://tinyurl.com/ya4vlamt" class="footerLinks">Report a Bug</a>
</div>
{% endblock %}
21 changes: 21 additions & 0 deletions LL1_Academy/templates/LL1_Academy/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends "LL1_Academy/_navbarPages.html" %}

{% block title %}
Error
{% endblock %}

{% block content %}

<div id="aboutContent">
<div class="aboutSection">
<h3 style="text-align:center;font-weight:bold;">{{title}}</h3>
<p style="text-align: center;">
{{text}}
<br>
<a style="text-align: center;" href='https://goo.gl/forms/u52329KnkqWETu6b2'>
Report a bug
</a>
</p>
</div>
</div>
{% endblock %}
18 changes: 10 additions & 8 deletions LL1_Academy/templates/LL1_Academy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ <h1 id="siteTitle">LL(1) Academy</h1>
<p style="color:white;font-size:30px;">Welcome back <a href="profile" style="font-weight: bold;text-transform: capitalize;">{{ 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>
<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 %}
{% if messages %}
Expand All @@ -30,10 +26,16 @@ <h1 id="siteTitle">LL(1) Academy</h1>
{% endif %}
{% 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>
<div id="socialMediaLogin" style="margin-bottom:20px;">
<div class="loginOption" style="margin:0 15px 15px 0;"><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"><a href="{% provider_login_url "google" method="oauth2" %}"><button class="button indexButtons" style="width:225px;">Login with Google</button></a></div>
</div>
<a href="/learn" class="footerLinks index" style="font-size:20px;">or learn without an account</a>
{% endif %}
</div>
<div id="indexFooter">
<a href="/about" class="footerLinks index" style="margin-right: 24px;">About</a>
<a href="https://github.com/vivz/LL1-Academy" class="footerLinks index">Github</a>
</div>
</div>
{% endblock %}
22 changes: 13 additions & 9 deletions LL1_Academy/templates/LL1_Academy/learn.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<input type="radio" name="ll1" value="False" id="input2" style="display:inline;margin-left:10px;"> False
{{/if}}
<div class="feedback"></div>
<div id="buttons-container" style="width: 82%;">
<div id="buttons-container">
{{#if opt}}
<button class="button" type="button" id="opt-char">{{opt}}</button>
{{/if}}
Expand Down Expand Up @@ -58,11 +58,15 @@

<form id="question-input" onsubmit="return false;">
<div class="feedback"></div>
{{#if opt}}
<button class="button" type="button" id="opt-char-pt">{{opt}}</button>
{{/if}}
<button type="submit" class="button">Submit</button>
<button type="button" class="button" id="giveup">Give Up</button>
<div id="buttons-container">
{{#if opt}}
<button class="button" type="button" id="opt-char-pt">{{opt}}</button>
{{/if}}
<div id="right-buttons" style="float: right;">
<button type="button" class="button" id="giveup">Give Up</button>
<button type="submit" class="button" >Submit</button>
</div>
</div>
</form>
</div>
</script>
Expand Down Expand Up @@ -117,7 +121,7 @@ <h3>Questions</h3>
{% block pagescripts %}
<script> var csrfmiddlewaretoken = "{{ csrf_token }}"; </script>
<script src="{% static 'js/learn.js' %}"></script>
<link rel="stylesheet" type="text/css" href="http://oss.maxcdn.com/jquery.trip.js/3.3.3/trip.min.css"/>
<script src="http://oss.maxcdn.com/jquery.trip.js/3.3.3/trip.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://oss.maxcdn.com/jquery.trip.js/3.3.3/trip.min.css"/>
<script src="https://oss.maxcdn.com/jquery.trip.js/3.3.3/trip.min.js"></script>

{% endblock %}
{% endblock %}
18 changes: 9 additions & 9 deletions LL1_Academy/templates/LL1_Academy/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
<div class="small-12 medium-12 large-10 columns" id="wrapper">
<div class="row">
<div class="small-12 medium-4 columns" id="user-info-box">
<div class="row" style="margin-bottom: 0px;text-align:center;">
<div class="row" style="margin-bottom: 20px;text-align:center;">
<div class="medium-5 columns">
<img id="profileIcon" src="{{user.socialaccount_set.all.0.get_avatar_url}}" style="border-radius: 50%;">
</div>
<div class="medium-7 columns">
<h2 id="userName" style="font-family: 'Lato', sans-serif;">{{ user_info.first_name }} {{user_info.last_name}}</h2>
</div>
</div>
<h5 class="status-text">
<i class="im im-users"></i>
You beat <b>{{percentile}} % </b>of our users.
</h5>
<h5 class="status-text">
<i class="im im-check-mark-circle-o"></i>
You completed <b>{{completed_grammars|length}}</b> grammar{% if completed_grammars|length > 1 %}s{% endif %}.
</h5>
<h5 class="status-text">
<i class="im im-users"></i>
You beat <b>{{percentile}} % </b>of our users.
</h5>
<div id="accounts-manage">
{% include "socialaccount/snippets/login_extra.html" %}
{% include "socialaccount/manage_providers.html" with process="login" %}
Expand Down Expand Up @@ -64,8 +64,8 @@ <h3 class="table-header">Completed Grammars</h3>
{{grammar.prods}}
</a>
</td>
<td>{{grammar.grammar_avg}}</td>
<td>{{grammar.score}}</td>
<td>{{grammar.grammar_avg}}/{{grammar.total_score}}</td>
<td>{{grammar.score}}/{{grammar.total_score}}</td>
</tr>
{% endfor %}
</tbody>
Expand Down Expand Up @@ -103,7 +103,7 @@ <h3 class="table-header">Skipped Grammars</h3>

{% block pagescripts %}
<link href="{% static 'css/c3.css' %}" rel="stylesheet" type="text/css">
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="{% static 'js/c3.min.js' %}"></script>
<script src="{% static 'js/profile.js' %}"></script>
<script> $(window).onload = create_chart( {{chart_stats|safe}} )</script>
Expand All @@ -121,4 +121,4 @@ <h3 class="table-header">Skipped Grammars</h3>
</script>
{% endfor %}
{% endif %}
{% endblock %}
{% endblock %}
36 changes: 31 additions & 5 deletions LL1_Academy/tests/tests.py → LL1_Academy/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@
from django.urls import reverse
from LL1_Academy.models import Grammar, Question

from django.contrib.sites.models import Site

class UrlTest(TestCase):
def setup(self):
g = Grammar(prods="{'A': ['xA', 'Bz'],'B': ['yB']}", nonTerminals="AB", terminals="xyz", startsymbol="A")
class TestData(TestCase):

@classmethod
def setUpTestData(cls):
g = Grammar(prods="{'A': ['xA', 'Bz'],'B': ['yB']}", nonTerminals="AB", terminals="xyz", startSymbol="A")
g.save()
q = Question(gid=g, qnum=0, category="FI", symbol="A", answer="xy")
q.save()

cls.current_site = Site.objects.get_current()

cls.SocialApp1 = cls.current_site.socialapp_set.create(
provider="facebook",
name="facebook",
client_id="1234567890",
secret="0987654321",
)

cls.SocialApp2 = cls.current_site.socialapp_set.create(
provider="google",
name="google",
client_id="1234567890",
secret="0987654321",
)


class UrlTest(TestData):

def test_index1(self):
response = self.client.get('/')
self.assertEqual(response.status_code, 200)
Expand All @@ -23,14 +45,18 @@ def test_learn(self):
self.assertEqual(response.status_code, 200)

def test_get_question(self):
response = self.client.get('/learn')
session = self.client.session
session.save()
response = self.client.get('/get_question')
self.assertEqual(response.status_code, 200)

def test_check_answer(self):
response = self.client.get('/check_answer')
self.assertEqual(response.status_code, 404)
print(response)
self.assertEqual(response.status_code, 400)

class RenderingTest(TestCase):
class RenderingTest(TestData):
def test_index1(self):
response = self.client.get('/')
self.assertTemplateUsed(response, 'LL1_Academy/index.html')
Expand Down
Loading

0 comments on commit 0cdfe4b

Please sign in to comment.