项目作者: messa

项目描述 :
Homework/task submit and review web app · based on React and Python aiohttp
高级语言: CSS
项目地址: git://github.com/messa/pyladies-courseware.git
创建时间: 2018-01-23T06:00:34Z
项目社区:https://github.com/messa/pyladies-courseware

开源协议:MIT License

下载


Pyladies Courseware

Nástroj pro odevzdávání a review domácích úkolů z programování.

CircleCI

Production deployment: https://projekty.pyladies.cz/

Demo (reseted on every deploy): https://projekty-demo.messa.cz/

Todo

Next steps:

  • dokončit workflow pro review úkolů
  • ~rozběhat FB a Google login~
  • přidat Github login
  • ~někam to nasadit :)~
  • udělat notifikace
    • uvnitř aplikace
    • do Slacku
    • e-mail
    • debouncing (neposílat každou zvlášť, ale agregovat)
  • dodělat admin uživatelů, ať se dají přiřazovat studenti a koučové do jednotlivých kurzů

Dlouhodoběji:

  • odevzdávání přes Github

Viz také issues.

Pokud máte dotaz nebo chcete spustit diskuzi nad některým todo, založte issue (pokud už takové neexistuje).

Architecture

Uses React frontend based on Next.js and Python backend based on aiohttp.server.

  1. browser --> nginx
  2. - /* ------------> node.js frontend
  3. - /api, /auth ---> Python aiohttp backend ---> MongoDB

Why React:

  • the site will be very dynamic, with complex forms, no-reload page updates, notifications etc. React enables to do this on client-side easily
  • so far we keep the code as simple as possible - no redux, no graphql etc., just “classic” React component state

Why Next.js:

  • handles all the boring stuff: webpack, routing, code splitting…
  • we just write the React components, nothing else, no server-side code (except getInitialProps)
  • we don’t even use “nice” dynamic URLs to keep things as simple as possible
    • URL /lesson?courseId=abc is served from pages/lesson.js with props: { query: { courseId: 'abc' }}

Why Python backend:

  • the language we all love :)
  • libraries for everything
  • more mature language for business logic and advanced I/O, process management etc.
  • API backend is more responsive when the HTML server-rendering is outsourced to client process (or to static files)

Why aiohttp:

  • supports websockets natively
  • enables the server to be single-process, single-thread, so things like notification broadcasting become much easier
  • powerful enough (just serves JSON API, no template rendering)
  • the MongoDB asyncio client motor is a “first-class” MongoDB client library

Why MongoDB:

  • provides all we need
  • “operations friendly” - replication, migration etc. much easier than with *SQL
  • MongoDB and its Python client motor provide nice asyncio API

Requirements

  • Node.js >= 10.0
  • Python >= 3.6
    • Ubuntu: install also python3-venv
  • MongoDB
    • via Docker: docker run --rm -it -p 27017:27017 mongo:4

Local Development

Ve 3 samostatných konzolích spusť:

  1. $ make run-mongod
  2. $ make run-backend
  3. $ make run-frontend

Otevři http://localhost:3000/

Port Služba
3000 Node.js – frontend
5000 aiohttp – backend
27017 MongoDB

Při změně kódu Python backendu je potřeba restartovat proces (tj. znovu spustit make run-backend).
Pro automatizaci tohoto lze použít nějaký watchdog, např. watch_files.py.

Developer login

Pro usnadnění vývoje na localhostu, je možné (v defaultu automaticky) zapnout tlačítka přihlášení různých rolí.

local dev login

Usage:

  1. # in the backend directory
  2. $ export ALLOW_DEV_LOGIN=1
  3. $ make run-backend

Project structure

  1. pyladies-courseware
  2. ├── Dockerfile
  3. ├── Makefile
  4. ├── backend
  5. ├── Makefile
  6. ├── cw_backend
  7. ├── __init__.py
  8. ├── __main__.py
  9. ├── configuration.py
  10. ├── courses.py
  11. ├── main.py
  12. ├── model
  13. ├── util
  14. └── views
  15. ├── requirements-tests.txt
  16. ├── requirements.txt
  17. ├── setup.py
  18. └── tests
  19. ├── conftest.py
  20. ├── data
  21. ├── model
  22. ├── test_users.py
  23. └── ...
  24. ├── ...
  25. ├── data - course, session and task data
  26. ├── frontend
  27. ├── components
  28. ├── ALink.js
  29. ├── CodeEditor.js
  30. ├── Header.js
  31. ├── HomeworkComments.js
  32. ├── ...
  33. ├── admin
  34. └── forms
  35. ├── package-lock.json
  36. ├── package.json
  37. ├── pages
  38. ├── admin
  39. └── users.js
  40. ├── course.js
  41. ├── index.js
  42. ├── lesson.js
  43. ├── login.js
  44. └── profile.js
  45. ├── static
  46. └── util
  47. └── resources - images for README etc.
  48. └── local_dev_login.png

Poznámky

Nějaký pokus o přepsání domácích úkolů proběhl zde: https://github.com/pyvec/naucse.python.cz/pull/153