Git Product home page Git Product logo

pythonfreecourse / lms Goto Github PK

View Code? Open in Web Editor NEW
102.0 102.0 28.0 5.71 MB

LMS allows teachers and educators to easily provide feedback on student programming work - both manually and automatically.

License: BSD 3-Clause "New" or "Revised" License

Python 70.91% HTML 10.87% CSS 6.46% JavaScript 7.88% Shell 1.57% Dockerfile 0.38% Jupyter Notebook 1.93%
classroom education hacktoberfest lms teaching

lms's People

Contributors

dependabot[bot] avatar gal432 avatar idoelk avatar itamargran avatar itraviv avatar lenagrech avatar liad-n avatar nogaos avatar officialpm avatar orronai avatar puredreamer avatar ron-huberfeld avatar talsk avatar yammesicka avatar yaronneuman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lms's Issues

"Share" function

The user should be able to create a shareable link.

  • The administrator should be able to turn this feature off through the site's configuration
  • The user should be able to get a shareable, private link to the exercise (not the regular view page). You can use URI fragment identifier as the key. All the logged-in users should be able to watch the exercise in this case.
  • The user should also be able to select a specific user(s) to share the exercise with. In this case, they'll have access to the regular view page.

Notifications

Create a new notification for the student when the mentor has clicked the "I'm done checking" button.

  1. May need us to build a DB migration
  2. There should be an API to get all the notification for a specific user
  3. Notification should have the feature "New" (so we can show the users only new events)

Change the functionality of the grader sidenav

Currently, we share the most popular sidenav comments.

After using the system for a while, I think the best behavior should be:

  1. Allow adding custom comments.
  2. Remove the automatic feature of showing the popular ones automatically.
  3. Check how to save page real-estate and organize the comments properly.
  4. Have a small expansion button for the popular comments (yours, and that the rest of the group submitted). Show numbers near each one. Allow the user to add these comments to his favorite ones with a click.

Add localization

  • Create configuration entry for the chosen language in our configuration file.
  • Extract strings from Backend.
  • Extract strings from Frontend.
  • Create proper CSS alignments.

Extra points:

  • Translate the extracted strings to English.

'str' object has no attribute 'hex' on full setup

Following the Full Setup instructions from the repo's main README, and after running:

echo "SECRET_KEY = \"$(python -c 'import os;print(os.urandom(32).hex())')\"" >> lms/lmsweb/config.py

I'm getting:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'str' object has no attribute 'hex'

Not a Pythonista, please excuse if this is kid-level stuff, I'm just debugging by writing this down.

I'm told Python versions matter, and so I'm running (on an AWS EC2 instance):

Python 2.7.17 [GCC 7.5.0] on linux2

Which implies CPython, I suppose (but that's just me twiddling my thumbs in the air now).

Anywho, looking at the docs for os.urandom(32) for Python 2.7.18 here implies that i should be getting 32 bytes of random data when running that function, and indeed I do when I try to do that in the REPL:

>>> os.urandom(32)
'\x9e\xf70FV\xd3m=4!2\xad\x7f\xcaD-\\\xf5"7\xb6\x9cp8\x88\xf0\x9dx\xf6\xa1\xd0\xd6'

However, chaining hex() to the function makes Python not happy:

>>> os.urandom(32).hex()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'hex'

I assume the reason why we're using os.urandom() instead of using uuid.uuid4() or one of the other uuid variants has to do with providing a secret key that is cryptographically secure?

Didn't open a PR yet since I wasn't sure whether that's needed, and also I could be missing something basic.

@gal432 I think that's your area, correct?

BTW - actual SECRET_KEY line with uuid instead of urandom:

echo "SECRET_KEY = \"$(python -c 'import uuid;print(uuid.uuid4().hex)')\"" >> lms/lmsweb/config.py

Change the reviewer notes red color to red and green colors

Adding a suggestion that was posted on the forum.

Change the reviewer notes red color to red and green. The red one will be for "error"/"fix it" notes, and a green one for good notes. With the drop-down list of preset notes, these can already be predefined as red or green.

Fix old version preventing to reupload an exercise

Scenario:

  1. User uploads a solution to an exercise (A).
  2. User mistakenly reuploads another solution to the same exercise (B)
  3. User tries to fix his error and to re-upload solution A.
  4. LMS stops the upload because the solution is already exists in the DB.

Solution:

Check de-duplications only with the latest uploaded version.

Notifications: Counter badge

Create a badge near the notifications button in the navbar that indicates how many notifications the user have.

"Lock" solution to a mentor

To prevent race-conditions between mentors, we should assign the exercise to a mentor once he sees it.

Possible caveats:

  1. Make sure to release the lock after N=5 minutes of inactivity. (Should be configurable)
  2. Make sure not to create blocking code.

Create configuration folder

Move all the configuration-related stuff to the same place (app configuration, db configuration etc).
I think lms/lms/config would be perfect for this matter.
It would be much easier to import lms.config.log and to reconfigure the logger in one place for the whole project.

Comment "category"

  • The checker should be able to pick an optional category for the comment he or she sends.
  • The checker should be able to pick a color, which will be the background of the line (and maybe will even have a name, like a category).
  • Can be a bit tricky with Ninja mode, should think of a simple solution (maybe a key to each category)

Ninja mode improvements

  • Allow to exit from Ninja mode using ESC
  • Allow to add a new free-text comment using Ninja mode using `
  • Allow focusing on the last line using - or =

Relation user does not exist

Debugging, as well know, is always a journey. You know where you start, you never know where you'll end...

After hitting a minor setback with #148, I now have the lms.yaml file up and running with docker-compose, and a lovely forest of containers is now (noisily) crowding my machine's memory.

Aha! But no cigar for you, ol' tommy - getting a 500 when attempting to access the server's domain.
Looking closely at the running containers:

ubuntu@MY_COOL_SERVER:~/lms$ docker ps
CONTAINER ID        IMAGE                            COMMAND                  CREATED              STATUS                        PORTS                                                 NAMES
b1945b60c546        lms:latest                       "gunicorn --bind 0.0…"   About a minute ago   Up About a minute             0.0.0.0:8080->8080/tcp                                lms_http_1
725362d2ce44        lms:latest                       "celery -A lms.lmste…"   About a minute ago   Up About a minute                                                                   lms_checks-public_1
4d7dfc24ba99        lms:latest                       "celery -A lms.lmste…"   About a minute ago   Up About a minute                                                                   lms_checks-sandbox_1
252dd86e4988        docker:dind                      "dockerd-entrypoint.…"   About a minute ago   Up About a minute             2375-2376/tcp                                         lms_checks-docker-engine_1
30b9e7ade595        rabbitmq:3.7-management-alpine   "docker-entrypoint.s…"   About a minute ago   Up About a minute             4369/tcp, 5671-5672/tcp, 15671-15672/tcp, 25672/tcp   lms_rabbitmq_1
e0acd19e66b6        postgres:11-alpine               "docker-entrypoint.s…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:5432->5432/tcp                                lms_db_1

Reveals that gunicorn that is bound to 8080 is the probable culprit (there's an nginx configuration block that points all incoming traffic to / to proxy_pass 127.0.01:8080).

Going all docker logs b1945b60c546 reveals the following:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/app_dir/lms/lmsweb/views.py", line 105, in login
    user = User.get_or_none(username=username)
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 6389, in get_or_none
    return cls.get(*query, **filters)
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 6384, in get
    return sq.get()
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 6807, in get
    return clone.execute(database)[0]
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 1886, in inner
    return method(self, database, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 1957, in execute
    return self._execute(database)
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 2129, in _execute
    cursor = database.execute(self)
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 3112, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 3106, in execute_sql
    self.commit()
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 2873, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 183, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/site-packages/peewee.py", line 3099, in execute_sql
    cursor.execute(sql, params or ())
peewee.ProgrammingError: relation "user" does not exist
LINE 1: ..."."password", "t1"."role_id", "t1"."api_key" FROM "user" AS ...

Which screams database error for multiple reason (psycopg2 is a db adapter, and - well - relation does not exist), so I scroll a bit up to the installation script and what do you know, I missed an error message:

WARNING: The DB_NAME variable is not set. Defaulting to a blank string.

Scrolling a couple lines up reveals that it's coming from the ./devops/start.sh script, which looks like this:

#!/bin/bash

if [ -f secrets.env ]; then
  echo "Using prod secrets"
  source secrets.env
else
  echo "Using default dev variables"
fi


SCRIPT_FILE_PATH=$(readlink -f "${0}")
SCRIPT_FOLDER=$(dirname "${SCRIPT_FILE_PATH}")

docker network create lms
docker-compose -p lms -f "${SCRIPT_FOLDER}/lms.yaml" down
docker-compose -p lms -f "${SCRIPT_FOLDER}/lms.yaml" up -d

Ah, but of course, the error message above is actually a Docker error and not a script error, which means the manifest file needs that variable but it's nowhere to be found. Let's look at lms.yaml for a sec, just the first few lines:

version: "3"

services:
  db:
    image: postgres:11-alpine
    ports:
      - 5432:5432
    volumes:
      - db-data-volume:/pg_data
    environment:
      - PGDATA=/pg_data
      - POSTGRES_DB=${DB_NAME:-db}
      - POSTGRES_USER=${DB_USERNAME:-postgres}
      - POSTGRES_PASSWORD=${DB_PASSWORD:-postgres}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready", "-U", "$DB_NAME"]
...
...
...

So it looks like the default fallback value for DB_NAME is db, but here I discovered something that I did not notice before - the container contains stub data!

And if you follow the instructions on the README to completion and run:

docker exec -it lms_http_1 bash
python lmsdb/bootstrap.py

Then you will get access to the holy kingdom:

image

Gonna close it right after I open it so people can look it up if they get stuck. Debugging for the masses! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.