diff --git a/README.md b/README.md index 5f8c0e3..c4a2eb6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# botEdukadu - +# Szefowe Zadanka - Database of Canvas Quizzes answers and Auto Quiz Filler for my Classmates and me diff --git a/ramen/__pycache__/api.cpython-310.pyc b/ramen/__pycache__/api.cpython-310.pyc new file mode 100644 index 0000000..cb776ce Binary files /dev/null and b/ramen/__pycache__/api.cpython-310.pyc differ diff --git a/ramen/api.py b/ramen/api.py new file mode 100644 index 0000000..91f3fe6 --- /dev/null +++ b/ramen/api.py @@ -0,0 +1,194 @@ +#Szefowe Zadanka Restful API +#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 datetime +import os +import uuid +import configparser +from functools import wraps +import jwt # PYJWT +from flask import Flask, request, jsonify, make_response +from flask_marshmallow import Marshmallow +from flask_sqlalchemy import SQLAlchemy +global rankid + +app = Flask(__name__) +basedir = os.path.abspath(os.path.dirname(__file__)) +app.config['SECRET_KEY'] = 'This is secret' +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'db.sqlite') +app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False +secret_key = app.config['SECRET_KEY'] +db = SQLAlchemy(app) +ma = Marshmallow(app) + +class QuizAnswer(db.Model): + id = db.Column(db.Integer, primary_key=True) + public_id = db.Column(db.String(50), unique=True) + name = db.Column(db.String(50)) + author = db.Column(db.String(50)) + subject = db.Column(db.String(50)) + question = db.Column(db.String(500)) + week = db.Column(db.Integer()) + answer = db.Column(db.String(3000)) + + def __init__(self, public_id, name, author, subject, question, week, answer): + self.public_id = public_id + self.name = name + self.author = author + self.subject = subject + self.question = question + self.week = week + self.answer = answer + +class QuizAnswerSchema(ma.Schema): + class Meta: + fields = ('public_id', 'name', 'author', 'subject', 'question', 'week', 'answer') + +class ExcersiseAnswer(db.Model): + id = db.Column(db.Integer, primary_key=True) + public_id = db.Column(db.String(50), unique=True) + name = db.Column(db.String(50)) + author = db.Column(db.String(50)) + subject = db.Column(db.String(50)) + week = db.Column(db.Integer()) + answer = db.Column(db.String(3000)) + + def __init__(self, public_id, name, author, subject, question, week, answer): + self.public_id = public_id + self.name = name + self.author = author + self.subject = subject + self.week = week + self.answer = answer + +class Test(db.Model): + id = db.Column(db.Integer, primary_key=True) + public_id = db.Column(db.String(50), unique=True) + name = db.Column(db.String(50)) + subject = db.Column(db.String(50)) + date = db.Column(db.String(50)) + topic = db.Column(db.String(50)) + + def __init__(self, public_id, name, subject, date, topic): + self.public_id = public_id + self.name = name + self.subject = subject + self.date = date + self.topic = topic + +class TestSchema(ma.Schema): + class Meta: + fields = ('public_id', 'name', 'subject', 'date', 'topic') + +# Schema + +quiz_answer_schema = QuizAnswerSchema() +quiz_answers_schema = QuizAnswerSchema(many=True) + +test_schema = TestSchema() +tests_schema = TestSchema(many=True) + +excersise_answer_schema = QuizAnswerSchema() +excersise_answers_schema = QuizAnswerSchema(many=True) + +# make a request for creating a new test +@app.route('/newtest', methods=['POST']) +def create_test(): + public_id = str(uuid.uuid4()) + name = request.json['name'] + subject = request.json['subject'] + date = request.json['date'] + topic = request.json['topic'] + + new_test = Test(public_id, name, subject, date, topic) + + db.session.add(new_test) + db.session.commit() + + return test_schema.jsonify(new_test) + +# make a request for creating a new quiz answer +@app.route('/newquizanswer', methods=['POST']) +def create_quiz_answer(): + public_id = str(uuid.uuid4()) + name = request.json['name'] + author = request.json['author'] + subject = request.json['subject'] + question = request.json['question'] + week = request.json['week'] + answer = request.json['answer'] + + new_quiz_answer = QuizAnswer(public_id, name, author, subject, question, week, answer) + + db.session.add(new_quiz_answer) + db.session.commit() + + return quiz_answer_schema.jsonify(new_quiz_answer) + +# make a request for creating a new excersise answer +@app.route('/newexcersiseanswer', methods=['POST']) +def create_excersise_answer(): + public_id = str(uuid.uuid4()) + name = request.json['name'] + author = request.json['author'] + subject = request.json['subject'] + week = request.json['week'] + answer = request.json['answer'] + + new_excersise_answer = ExcersiseAnswer(public_id, name, author, subject, week, answer) + + db.session.add(new_excersise_answer) + db.session.commit() + + return excersise_answer_schema.jsonify(new_excersise_answer) + +# make a request for getting last 6 tests +@app.route('/last6tests', methods=['GET']) +def get_last_6_tests(): + last_6_tests = Test.query.order_by(Test.id.desc()).limit(6).all() + result = tests_schema.dump(last_6_tests) + return jsonify(result) + +# make a request for getting all tests +@app.route('/alltests', methods=['GET']) +def get_all_tests(): + all_tests = Test.query.all() + result = tests_schema.dump(all_tests) + return jsonify(result) + +# make a request for getting all quiz answers +@app.route('/allquizanswers', methods=['GET']) +def get_all_quiz_answers(): + all_quiz_answers = QuizAnswer.query.all() + result = quiz_answers_schema.dump(all_quiz_answers) + return jsonify(result) + +# make a request for getting all quiz answers with specific week +@app.route('/allquizanswers/', methods=['GET']) +def get_all_quiz_answers_with_week(week): + all_quiz_answers = QuizAnswer.query.filter_by(week=week).all() + result = quiz_answers_schema.dump(all_quiz_answers) + return jsonify(result) + +# make a request for getting all excersise answers +@app.route('/allexcersiseanswers', methods=['GET']) +def get_all_excersise_answers(): + all_excersise_answers = ExcersiseAnswer.query.all() + result = excersise_answers_schema.dump(all_excersise_answers) + return jsonify(result) + +# make a request for getting all excersise answers with specific week and subject +@app.route('/allexcersiseanswers//', methods=['GET']) +def get_all_excersise_answers_with_week_and_subject(week, subject): + all_excersise_answers = ExcersiseAnswer.query.filter_by(week=week, subject=subject).all() + result = excersise_answers_schema.dump(all_excersise_answers) + return jsonify(result) + +# Run the app +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/ramen/db.sqlite b/ramen/db.sqlite new file mode 100644 index 0000000..2119f5b Binary files /dev/null and b/ramen/db.sqlite differ diff --git a/syrenka/__pycache__/apihelper.cpython-310.pyc b/syrenka/__pycache__/apihelper.cpython-310.pyc new file mode 100644 index 0000000..b07d8fb Binary files /dev/null and b/syrenka/__pycache__/apihelper.cpython-310.pyc differ diff --git a/syrenka/apihelper.py b/syrenka/apihelper.py new file mode 100644 index 0000000..6bd37b9 --- /dev/null +++ b/syrenka/apihelper.py @@ -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 diff --git a/syrenka/index.py b/syrenka/index.py new file mode 100644 index 0000000..941ba92 --- /dev/null +++ b/syrenka/index.py @@ -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//') +def quiz(week): + return render_template('quiz.htm', answers=apihelper.get_all_quiz_answers_with_week_in_html(week), week=week) + +@app.route('/newquiz///////') +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) \ No newline at end of file diff --git a/syrenka/static/dc.png b/syrenka/static/dc.png new file mode 100644 index 0000000..9eaa900 Binary files /dev/null and b/syrenka/static/dc.png differ diff --git a/syrenka/static/logo.png b/syrenka/static/logo.png new file mode 100644 index 0000000..6e5772b Binary files /dev/null and b/syrenka/static/logo.png differ diff --git a/syrenka/static/main.css b/syrenka/static/main.css new file mode 100644 index 0000000..fe3f8ff --- /dev/null +++ b/syrenka/static/main.css @@ -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; +} \ No newline at end of file diff --git a/syrenka/static/mess.png b/syrenka/static/mess.png new file mode 100644 index 0000000..33d7661 Binary files /dev/null and b/syrenka/static/mess.png differ diff --git a/syrenka/static/src.png b/syrenka/static/src.png new file mode 100644 index 0000000..a918b87 Binary files /dev/null and b/syrenka/static/src.png differ diff --git a/syrenka/templates/about.htm b/syrenka/templates/about.htm new file mode 100644 index 0000000..5f26bc8 --- /dev/null +++ b/syrenka/templates/about.htm @@ -0,0 +1,37 @@ + + + + + Szefowe Zadanka + + + + +
+ ........... + + .....................................

Szefowe zadanka v0.5| + Strona Główna | Opublikuj | Sprawdziany | Jak używać / Informacje | + +


+
+

Jak Używać?

+

Jak Szukać Zadań?

+
  • Wejdź na edukadu i skopiuj polecenie (Najszybciej zrobisz to skrótem Crtl+C).
  • +
  • Otwórz stronę Szefowe Zadanka wybierz tydzień na stronie głównej bądź przejdź do wszystkich quizów/zadań
  • +
  • Kliknij skrót Crtl+F aby szukać na stronie i wklej polecenie(Najszybciej zrobisz to skrótem Crtl+V)
  • +

    Jak Dodawać Odpowiedzi?

    +
  • Wejdź na zakładkę Opublikuj
  • +
  • Wybierz czy jest to Pytanie w Quizie czy Zadanie
  • +
  • Wpisz Odpowiedź w tym autora aby inni mogli wiedzieć komu mają dziękować.
  • +
  • Kliknij OK
  • + +

    Rzeczy techniczne o stronie

    +
  • Strona(dynamic Syrenka) jest napisana w HTML CSS i Pythonie z użyciem frameworka Flask jak również Restful API(RamenBolka API)
  • +
  • Cały kod źródłowy jest dostępny w tym repozytorium na mojej instancji Gitea. Kod jest na wolnej licencji MIT. (Więcej LICENSE.txt)
  • +

    + Copyright (c) 2022 Cube Software && Kacper Kostka +
    + + \ No newline at end of file diff --git a/syrenka/templates/home.htm b/syrenka/templates/home.htm new file mode 100644 index 0000000..9d294c4 --- /dev/null +++ b/syrenka/templates/home.htm @@ -0,0 +1,32 @@ + + + + + Szefowe Zadanka + + + + +
    + ........... + + .....................................

    Szefowe zadanka v0.5| + Strona Główna | Opublikuj | Sprawdziany | Jak używać / Informacje | + +


    + + + \ No newline at end of file diff --git a/syrenka/templates/public.htm b/syrenka/templates/public.htm new file mode 100644 index 0000000..03fe309 --- /dev/null +++ b/syrenka/templates/public.htm @@ -0,0 +1,46 @@ + + + + + Szefowe Zadanka + + + + +
    + ........... + + .....................................

    Szefowe zadanka v0.5| + Strona Główna | Opublikuj | Sprawdziany | Jak używać / Informacje | + +


    +
    +

    Opublikuj Odpowiedź na Quiz

    +
    + + + + + + Prześlij(Najpierw Zatwierdź) +
    +

    Opublikuj Odpowiedź na Zadanie *COMMING SOON*

    +

    + Copyright (c) 2022 Cube Software && Kacper Kostka +
    + + + + diff --git a/syrenka/templates/quiz.htm b/syrenka/templates/quiz.htm new file mode 100644 index 0000000..32d0370 --- /dev/null +++ b/syrenka/templates/quiz.htm @@ -0,0 +1,25 @@ + + + + + Szefowe Zadanka + + + + +
    + ........... + + .....................................

    Szefowe zadanka v0.5| + Strona Główna | Opublikuj | Sprawdziany | Jak używać / Informacje | + +


    +
    +

    Odpowiedzi na Quizy Tydzień {{week}}

    +
  • {{answers}}
  • +

    + Copyright (c) 2022 Cube Software && Kacper Kostka +
    + + diff --git a/syrenka/templates/soon.htm b/syrenka/templates/soon.htm new file mode 100644 index 0000000..7e9e02a --- /dev/null +++ b/syrenka/templates/soon.htm @@ -0,0 +1,24 @@ + + + + + Szefowe Zadanka + + + + +
    + ........... + + .....................................

    Szefowe zadanka v0.5| + Strona Główna | Opublikuj | Sprawdziany | Jak używać / Informacje | + +


    +
    +

    Ta część strony jest w budowie!

    +

    + Copyright (c) 2022 Cube Software && Kacper Kostka +
    + + \ No newline at end of file diff --git a/syrenka/templates/tests.htm b/syrenka/templates/tests.htm new file mode 100644 index 0000000..ec4d6be --- /dev/null +++ b/syrenka/templates/tests.htm @@ -0,0 +1,30 @@ + + + + + Szefowe Zadanka + + + + +
    + ........... + + .....................................

    Szefowe zadanka v0.5| + Strona Główna | Opublikuj | Sprawdziany | Jak używać / Informacje | + +


    +
    +

    Świeże Sprawdziany

    +
  • {{name1}} || Data Sprawdzianu : {{date1}} | Przedmiot: {{subject1}} | Temat Sprawdzianu : {{topic1}}
  • +
  • {{name2}} || Data Sprawdzianu : {{date2}} | Przedmiot: {{subject2}} | Temat Sprawdzianu : {{topic2}}
  • +
  • {{name3}} || Data Sprawdzianu : {{date3}} | Przedmiot: {{subject3}} | Temat Sprawdzianu : {{topic3}}
  • +
  • {{name4}} || Data Sprawdzianu : {{date4}} | Przedmiot: {{subject4}} | Temat Sprawdzianu : {{topic4}}
  • + +

    + Copyright (c) 2022 Cube Software && Kacper Kostka +
    + + +