WEBSITE AND API ADDED

This commit is contained in:
2022-10-24 15:05:26 +02:00
parent dc83b77210
commit 31726836d0
18 changed files with 598 additions and 2 deletions

Binary file not shown.

57
syrenka/apihelper.py Normal file
View File

@@ -0,0 +1,57 @@
#Szefowe Zadanka
#Created by Kacper Kostka from CubeSoftware
#-------------------------------
#Copyright (c) 2021-2022 CubeSoftware
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the #Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the #Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A #PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION #OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import requests
import json
url = "http://localhost:5000"
def create_test(name, subject, date, topic):
data = {"name": name, "subject": subject, "date": date, "topic": topic}
response = requests.post(url + "/newtest", json=data)
return response.json()
def create_quiz_answer(name, author, subject, question, week, answer):
data = {"name": name, "author": author, "subject": subject, "question": question, "week": week, "answer": answer}
response = requests.post(url + "/newquizanswer", json=data)
return response.json()
def create_excersise_answer(name, author, subject, week, answer):
data = {"name": name, "author": author, "subject": subject, "week": week, "answer": answer}
response = requests.post(url + "/newexcersiseanswer", json=data)
return response.json()
def get_last_6_tests():
response = requests.get(url + "/last6tests")
return response.json()
def get_all_tests():
response = requests.get(url + "/alltests")
return response.json()
def get_all_quiz_answers():
response = requests.get(url + "/allquizanswers")
return response.json()
def get_all_quiz_answers_with_week(week):
response = requests.get(url + "/allquizanswers/" + week)
return response.json()
def get_all_excersise_answers():
response = requests.get(url + "/allexcersiseanswers")
return response.json()
def get_all_excersise_answers_with_week_and_subject(week, subject):
response = requests.get(url + "/allexcersiseanswers/" + week + "/" + subject)
return response.json()
def get_all_quiz_answers_with_week_in_html(week):
html = ""
for quizanswer in get_all_quiz_answers_with_week(week):
html += "______________ Przedmiot: " + quizanswer["subject"] + "| Polecenie: " + quizanswer["question"] + "| Odpowiedź: " + quizanswer["answer"] + "_______________" + '\n'
return html

58
syrenka/index.py Normal file
View File

@@ -0,0 +1,58 @@
#Sovnat GBF -
#Created by CubeSoftware
#-------------------------------
#Copyright (c) 2021-2022 CubeSoftware
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the #Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the #Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A #PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION #OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from flask import Flask, render_template
import requests
import json
import os
import apihelper
app = Flask(__name__)
PORT = int(os.environ.get('PORT', 4567))
@app.route("/")
@app.route("/index")
def index():
return render_template('home.htm', zurl1="/soon")
@app.route("/info")
def info():
return render_template('about.htm')
@app.route("/soon")
def soon():
return render_template('soon.htm')
@app.route("/tests")
def tests():
last = apihelper.get_last_6_tests()
test1 = last[0]
test2 = last[1]
test3 = last[1]
test4 = last[1]
return render_template('tests.htm', name1=test1["name"], subject1=test1["subject"], date1=test1["date"], topic1=test1["topic"], name2=test2["name"], subject2=test2["subject"], date2=test2["date"], topic2=test2["topic"]) #name3=test3["name"], subject3=test3["subject"], date3=test3["date"], topic3=test3["topic"], name4=test4["name"], subject4=test4["subject"], date4=test4["date"], topic4=test4["topic"])
@app.route("/new")
def new():
return render_template('public.htm')
@app.route('/quiz/<week>/')
def quiz(week):
return render_template('quiz.htm', answers=apihelper.get_all_quiz_answers_with_week_in_html(week), week=week)
@app.route('/newquiz/<week>/<name>/<subject>/<author>/<question>/<answer>/')
def newquiz(week, name, subject, author, question, answer):
apihelper.create_quiz_answer(name, author, subject, question, week, answer)
return render_template('public.htm')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=PORT, debug=True)

BIN
syrenka/static/dc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
syrenka/static/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

94
syrenka/static/main.css Normal file
View File

@@ -0,0 +1,94 @@
.articlebutton {
margin: 0 auto;
display:inline-block;
padding-left:0.5cm;
padding-right:0.5cm;
transition: transform 0.1s;
align: center;
background-color: rgba(255, 255, 255, 0.2);
padding: 1rem 6rem;
display: block;
font-weight: bold;
color: #FFFFFF;
border: none;
margin: 1rem;
border-radius: 8px;
outline: none;
cursor: pointer;
}
.articlebutton:hover {
transform:scale(1.04);
}
BODY
{
/*background-color: #434388; */
font-family: 'Roboto Mono', monospace;
color: rgb(113, 223, 119);
}
P
{
text-shadow: 4px 4px #3d3d3d;
line-height: 180%;
width: 70%;
margin-top: 2em;
margin-bottom: 3em;
font-size: 1.3em;
}
HR
{
height: 1px;
border: none;
background-color: #92dbe0;
}
TABLE
{
/*background-image: linear-gradient(rgba(28, 28, 89, 1) 0%, rgba(28, 29, 120, 1) 50%, rgba(5, 28, 105, 1) 100%);*/
border: 2px solid #92dbe0;
width: 80%;
padding: 2px;
}
B
{
font-size: 1.2em;
border: 2px solid #92dbe0;
}
I
{
text-shadow: 8px 8px #111111;
font-size: 1.6em;
}
A
{
/*text-shadow: 4px 4px #201c1c;*/
color: #180736;
}
CENTER
{
margin-top: 24em;
}
UL
{
float: left;
align-content: right;
display: table;
}
LI
{
list-style: none;
}
A:HOVER
{
color: #180736;
}

BIN
syrenka/static/mess.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

BIN
syrenka/static/src.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Szefowe Zadanka</title>
</head>
<link rel = "icon" href = "/static/logo.png" type = "image/x-icon">
<body style="background-color: rgb(85, 85, 85); background-position: center;
background-size: cover;">
<LINK REL = "STYLESHEET" HREF = "/static/main.css">
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<img src="/static/logo.png"> ........... <a href=""><img src="/static/dc.png"></a>
<a href=""><img src="/static/mess.png"></a>
<a href=""><img src="/static/src.png"></a> .....................................<br></br>Szefowe zadanka v0.5|
<a href="/index">Strona Główna</a> | <a href="/new">Opublikuj</a> | <a href="/tests">Sprawdziany</a> | <a href="/info"> Jak używać / Informacje</a> |
</div> <br></br>
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<h1>Jak Używać?</h1>
<h2>Jak Szukać Zadań?</h2>
<li>Wejdź na edukadu i skopiuj polecenie (Najszybciej zrobisz to skrótem <a>Crtl+C</a>).</li>
<li>Otwórz stronę <a>Szefowe Zadanka</a> wybierz tydzień na stronie głównej bądź przejdź do wszystkich quizów/zadań</li>
<li>Kliknij skrót <a>Crtl+F</a> aby szukać na stronie i wklej polecenie(Najszybciej zrobisz to skrótem <a>Crtl+V</a>)</li>
<h2>Jak Dodawać Odpowiedzi?</h2>
<li>Wejdź na zakładkę <a>Opublikuj</a></li>
<li>Wybierz czy jest to Pytanie w Quizie czy Zadanie</li>
<li>Wpisz Odpowiedź w tym autora aby inni mogli wiedzieć komu mają dziękować.</li>
<li>Kliknij <a>OK</a></li>
<h1>Rzeczy techniczne o stronie</h1>
<li>Strona(dynamic Syrenka) jest napisana w HTML CSS i Pythonie z użyciem frameworka Flask jak również Restful API(RamenBolka API)</li>
<li>Cały kod źródłowy jest dostępny w <a href="">tym</a> repozytorium na mojej instancji Gitea. Kod jest na wolnej licencji MIT. (Więcej LICENSE.txt)</li>
<br></br>
Copyright (c) 2022 <a href="https://cubesoftware.xyz">Cube Software && Kacper Kostka</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Szefowe Zadanka</title>
</head>
<link rel = "icon" href = "/static/logo.png" type = "image/x-icon">
<body style="background-color: rgb(85, 85, 85); background-position: center;
background-size: cover;">
<LINK REL = "STYLESHEET" HREF = "/static/main.css">
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<img src="/static/logo.png"> ........... <a href=""><img src="/static/dc.png"></a>
<a href=""><img src="/static/mess.png"></a>
<a href=""><img src="/static/src.png"></a> .....................................<br></br>Szefowe zadanka v0.5|
<a href="/index">Strona Główna</a> | <a href="/new">Opublikuj</a> | <a href="/tests">Sprawdziany</a> | <a href="/info"> Jak używać / Informacje</a> |
</div> <br></br>
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<h2>Ostatnie tygodnie:</h2>
<div class="articlebutton"><li><a>TD03</a> || <a href="/quiz/3">Wszystkie Quizy</a> | <a href="{{zurl1}}">Zadania</a></li></div>
<div class="articlebutton"><li><a>TD04</a> || <a href="/quiz/4">Wszystkie Quizy</a> | <a href="{{zurl1}}">Zadania</a></li></div>
<div class="articlebutton"><li><a>TD05</a> || <a href="/quiz/5">Wszystkie Quizy</a> | <a href="{{zurl1}}">Zadania</a></li></div>
<div class="articlebutton"><li><a>TD06</a> || <a href="/quiz/6">Wszystkie Quizy</a> | <a href="{{zurl1}}">Zadania</a></li></div>
<div class="articlebutton"><li><a>TD07</a> || <a href="/quiz/7">Wszystkie Quizy</a> | <a href="{{zurl1}}">Zadania</a></li></div>
<div class="articlebutton"><li><a>TD08</a> || <a href="/quiz/8">Wszystkie Quizy</a> | <a href="{{zurl1}}">Zadania</a></li></div>
<div class="articlebutton"><li><a>TD09</a> || <a href="/quiz/9">Wszystkie Quizy</a> | <a href="{{zurl1}}">Zadania</a></li></div>
<br></br>
Copyright (c) 2022 <a href="https://cubesoftware.xyz">Cube Software && Kacper Kostka</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Szefowe Zadanka</title>
</head>
<link rel = "icon" href = "/static/logo.png" type = "image/x-icon">
<body style="background-color: rgb(85, 85, 85); background-position: center;
background-size: cover;">
<LINK REL = "STYLESHEET" HREF = "/static/main.css">
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<img src="/static/logo.png"> ........... <a href=""><img src="/static/dc.png"></a>
<a href=""><img src="/static/mess.png"></a>
<a href=""><img src="/static/src.png"></a> .....................................<br></br>Szefowe zadanka v0.5|
<a href="/index">Strona Główna</a> | <a href="/new">Opublikuj</a> | <a href="/tests">Sprawdziany</a> | <a href="/info"> Jak używać / Informacje</a> |
</div> <br></br>
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<h2>Opublikuj Odpowiedź na Quiz</h2>
<form action="localhost:5000/newquizanswer" method="post">
<input type="text" name="question" placeholder="Polecenie" required>
<input type="text" name="week" placeholder="Tydzień(tylko liczby)" required>
<input type="text" name="answer" placeholder="Odpowiedź" required>
<input type="text" name="subject" placeholder="Przedmiot" required>
<button onclick="send()">Zatwierdź</button>
<a id="test">Prześlij(Najpierw Zatwierdź)</a>
</form>
<h2>Opublikuj Odpowiedź na Zadanie *COMMING SOON*</h2>
<br></br>
Copyright (c) 2022 <a href="https://cubesoftware.xyz">Cube Software && Kacper Kostka</a>
</div>
</body>
<script>
function send(){
var name = document.getElementsByName("name")[0].value;
var author = document.getElementsByName("author")[0].value;
var question = document.getElementsByName("question")[0].value;
var week = document.getElementsByName("week")[0].value;
var answer = document.getElementsByName("answer")[0].value;
var subject = document.getElementsByName("subject")[0].value;
document.getElementById("test").href = '/newquiz/'+week+'/Zadanie/'+subject+'/Autor/'+question+'/'+answer;
}
</script>
</html>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Szefowe Zadanka</title>
</head>
<link rel = "icon" href = "/static/logo.png" type = "image/x-icon">
<body style="background-color: rgb(85, 85, 85); background-position: center;
background-size: cover;">
<LINK REL = "STYLESHEET" HREF = "/static/main.css">
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<img src="/static/logo.png"> ........... <a href=""><img src="/static/dc.png"></a>
<a href=""><img src="/static/mess.png"></a>
<a href=""><img src="/static/src.png"></a> .....................................<br></br>Szefowe zadanka v0.5|
<a href="/index">Strona Główna</a> | <a href="/new">Opublikuj</a> | <a href="/tests">Sprawdziany</a> | <a href="/info"> Jak używać / Informacje</a> |
</div> <br></br>
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<h1>Odpowiedzi na Quizy Tydzień {{week}}</h2>
<li style="color: rgba(255,255,255,255)"">{{answers}}</li>
<br></br>
Copyright (c) 2022 <a href="https://cubesoftware.xyz">Cube Software && Kacper Kostka</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Szefowe Zadanka</title>
</head>
<link rel = "icon" href = "/static/logo.png" type = "image/x-icon">
<body style="background-color: rgb(85, 85, 85); background-position: center;
background-size: cover;">
<LINK REL = "STYLESHEET" HREF = "/static/main.css">
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<img src="/static/logo.png"> ........... <a href=""><img src="/static/dc.png"></a>
<a href=""><img src="/static/mess.png"></a>
<a href=""><img src="/static/src.png"></a> .....................................<br></br>Szefowe zadanka v0.5|
<a href="/index">Strona Główna</a> | <a href="/new">Opublikuj</a> | <a href="/tests">Sprawdziany</a> | <a href="/info"> Jak używać / Informacje</a> |
</div> <br></br>
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<h1>Ta część strony jest w budowie!</h1>
<br></br>
Copyright (c) 2022 <a href="https://cubesoftware.xyz">Cube Software && Kacper Kostka</a>
</div>
</body>
</html>

View File

@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Szefowe Zadanka</title>
</head>
<link rel = "icon" href = "/static/logo.png" type = "image/x-icon">
<body style="background-color: rgb(85, 85, 85); background-position: center;
background-size: cover;">
<LINK REL = "STYLESHEET" HREF = "/static/main.css">
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<img src="/static/logo.png"> ........... <a href=""><img src="/static/dc.png"></a>
<a href=""><img src="/static/mess.png"></a>
<a href=""><img src="/static/src.png"></a> .....................................<br></br>Szefowe zadanka v0.5|
<a href="/index">Strona Główna</a> | <a href="/new">Opublikuj</a> | <a href="/tests">Sprawdziany</a> | <a href="/info"> Jak używać / Informacje</a> |
</div> <br></br>
<div style="padding: 0.5cm; background-color: rgba(66, 66, 66, 0.8)">
<h2>Świeże Sprawdziany</h2>
<div class="articlebutton"><li><a>{{name1}}</a> || Data Sprawdzianu : {{date1}} | Przedmiot: {{subject1}} | Temat Sprawdzianu : {{topic1}}</li></div>
<div class="articlebutton"><li><a>{{name2}}</a> || Data Sprawdzianu : {{date2}} | Przedmiot: {{subject2}} | Temat Sprawdzianu : {{topic2}}</li></div>
<div class="articlebutton"><li><a>{{name3}}</a> || Data Sprawdzianu : {{date3}} | Przedmiot: {{subject3}} | Temat Sprawdzianu : {{topic3}}</li></div>
<div class="articlebutton"><li><a>{{name4}}</a> || Data Sprawdzianu : {{date4}} | Przedmiot: {{subject4}} | Temat Sprawdzianu : {{topic4}}</li></div>
<br></br>
Copyright (c) 2022 <a href="https://cubesoftware.xyz">Cube Software && Kacper Kostka</a>
</div>
</body>
</html>