Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Documentation #90

Open
MarvinKweyu opened this issue Sep 29, 2019 · 19 comments
Open

Project Documentation #90

MarvinKweyu opened this issue Sep 29, 2019 · 19 comments

Comments

@MarvinKweyu
Copy link

So I know this is meant to be a library. However, can we get documentation on this? There is nothing but a brief readme. Can some of those who've set up the project successfully come chip in? It's 2019 by the way so can we as well move to latest versions of the dependencies with reference to Django and Python.

@KevinNathan97
Copy link

I agree to this. How to use this library in my Django app? Anyone that has successfully integrated this app please post the steps on how to do it. Thank you

@B-T-D
Copy link

B-T-D commented Dec 13, 2019

I've successfully integrated it. I have a lot going on at the moment but might be able to put together a list of steps this weekend. Are there any specific questions you have right now?

@KevinNathan97
Copy link

I'm glad that you have responded. At the moment I don't have any questions, if you can put up the steps during the weekend that would be really helpful. Thanks in advance.

@MarvinKweyu
Copy link
Author

Nicely done @B-T-D , did you stick to the used version of python and django as in the repo or did you have and upgrade?

@B-T-D
Copy link

B-T-D commented Dec 13, 2019

@MarvinKweyu I used the latest python and django versions that I had at the time I did it (about 2 months ago)--it was Python 3.7 and Django 2.2.

I don't remember having very many backwards compatibility problems, even though there's Python 2.7 type stuff in the django_quiz code. I haven't yet gotten it to pass the unittests included in the django_quiz repo, but haven't tried very hard yet, since in my particular project I've gotten it to do everything I've needed it to, so far.

The 'quiz' Django-app is the heart of how it works, from what I remember ('quiz' as opposed to 'essay', 'multichoice', or 'true_false'). Most of the logic is in quiz/models.py and quiz/views.py.

@MarvinKweyu
Copy link
Author

@B-T-D , great.I look foward to your set up guide.

@KevinNathan97
Copy link

hey man, any updates on the guide that you wanted to provide to us?

@MarvinKweyu
Copy link
Author

MarvinKweyu commented Dec 27, 2019

@KevinNathan97 , take a look at AssessMe Project.
I based it on the same principle. Walkthrough it and let me know what you think can be added as we wait.

PS: Feel free to contribute 😃

@jameskomo
Copy link

Did anyone ever know how to integrate this in a Django project? I have followed the steps but i am stuck

@B-T-D
Copy link

B-T-D commented Jan 30, 2020

Here are steps I just confirmed worked to make a dummy Django project with the django_quiz (as in I set this up as its own mockup project starting from a blank slate, no other apps and no other packages installed in its virtual environment).

For reference, I was working with:

  • Windows 10
  • Pipenv for dependencies control.
    $ pip install pipenv
  • Python 3.8.0
  • Django 2.2.9. A few weeks back, I found this to be the latest Django release that the unmodified django_quiz code worked with.

Steps:

  1. Create empty directory to house the dummy project.

  2. Create pipenv virtual environment there:
    $ pipenv shell

  3. Clone the django_quiz repo there:
    $ git clone https://github.com/tomwalker/django_quiz.git

  4. At the parent directory (rather than inside the new directory created by the git clone command), install Django 2.2.9 (make sure the pipenv virtual environment is still active, you should see the name of the virtual environment in parenthesis before the working-directory part of the command line):
    $ pipenv install django==2.2.9

  5. Start a Django project (again in the parent directory, not in django_quiz directory). Remember the dot at the end so Django will create a manage.py in the right directory:
    django-admin startproject testenv_django_quiz .

  6. Start the Django test server and go to localhost:8000 in a web browser to confirm it shows the normal Django welcome page:
    python manage.py runserver

  7. Manually install the dependencies with pipenv. I chose this route because there are only three dependencies, and I didn't want to risk the headache of conflicts with my pipfile.lock.
    $ pipenv install django-model-utils $ pipenv install pillow $ pipenv install tox

Pipenv installed the following versions of the dependencies:

  • django-model-utils 4.0.0
  • Pillow 7.0.0
  • tox 3.14.3
  1. Add the django_quiz apps to the test project's INSTALLED_APPS in settings.py, as directed in the "Installation" section of the readme:
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # django_quiz apps
    'quiz',
    'multichoice',
    'true_false',
    'essay',
]
  1. Add the django_quiz url to the project-level urls.py (for my mockup project, testenv_django_quiz/urls.py). I added them using the path() function rather than the url() function mentioned in the readme, since the official Django 3.0 docs say url() will likely be deprecated in a future release https://docs.djangoproject.com/en/3.0/ref/urls/. I also added them as the root url of the project, since there's nothing else in this project (in a separate project, I added them at the url pattern 'quiz/' with zero problems). The final project-level urls.py code:
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('quiz.urls')),
    
]
  1. Make the initial Django migrations file, and migrate it:
    $ python manage.py makemigrations
    $ python manage.py migrate

I got the following warning about the quiz/views.py, but nothing appeared to break when I ignored it:

django_quiz\quiz\views.py:333: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if score is 0:

You can fix it easily by making the edit the warning suggests.

  1. Start the test server to confirm everything is working so far:
    python manage.py runserver

If you go to localhost:8000/ in a browser, you should see a "List of quizzes" header followed by "There are no available quizzes". If you used a different url pattern, like the 'q/' example from the readme, then localhost:8000 will return 404 but localhost:8000/q/ should work.

  1. Confirm that the admin site works. Stop the test server with ctrl-c, create a superuser, restart the test server, and then go to localhost:8000/admin and log in. You should be able to create quizzes and questions there.
$ python manage.py create superuser
$ python manage.py runserver

@B-T-D
Copy link

B-T-D commented Jan 30, 2020

When I integrated this library into a real pre-existing project, I found I was able to just drop in the django_quiz code. So I just copied and pasted in the following folders from the as-cloned django_quiz:

  • essay
  • multichoice
  • quiz
  • true_false

And then made the appropriate updates to my project's urls.py and settings.py.

Overall, I found the most helpful thing in integrating it was to set up the library in its own mockup project, to get a sense for how it was supposed to work.

But the library won't work with Django 3, based on my experimentation. The project I integrated django_quiz into happened to be using Django 2.x, I think 2.2.6 at the time.

@MarvinKweyu
Copy link
Author

@B-T-D , 👍 great info, you should probably make this a pull.

@jameskomo
Copy link

@B-T-D This was helpful thanks alot. I was able to integrate into my existing project.

@B-T-D
Copy link

B-T-D commented Feb 4, 2020

@jameskomo that's awesome, glad it was helpful

@datamove
Copy link

datamove commented Feb 5, 2020

The above instructions do work even with pip install - r requirements from the README, provided that django version is limited to <3.0

@jameskomo
Copy link

Who has used the quiz app within the project not on the admin? Like be able to set up questions, quiz, category, sibcategory and quiz type on a standard template? I have used Django createviews but it is not just working and I have to do it on admin module

@danialshamas
Copy link

ive got error not module name essay
how can is slove this

@pgiki
Copy link

pgiki commented Feb 11, 2021

@danialshamas to solve the module not found error make sure all the modules such as essay, quiz, true_false, and multichoice are in the root directory of your project.

@GregLebreton
Copy link

Here are steps I just confirmed worked to make a dummy Django project with the django_quiz (as in I set this up as its own mockup project starting from a blank slate, no other apps and no other packages installed in its virtual environment).

For reference, I was working with:

* Windows 10

* Pipenv for dependencies control.
  `$ pip install pipenv`

* Python 3.8.0

* Django 2.2.9. A few weeks back, I found this to be the latest Django release that the unmodified django_quiz code worked with.

Steps:

1. Create empty directory to house the dummy project.

2. Create pipenv virtual environment there:
   `$ pipenv shell`

3. Clone the django_quiz repo there:
   `$ git clone https://github.com/tomwalker/django_quiz.git`

4. At the parent directory (rather than inside the new directory created by the git clone command), install Django 2.2.9 (make sure the pipenv virtual environment is still active, you should see the name of the virtual environment in parenthesis before the working-directory part of the command line):
   `$ pipenv install django==2.2.9`

5. Start a Django project (again in the parent directory, not in django_quiz directory). Remember the dot at the end so Django will create a manage.py in the right directory:
   `django-admin startproject testenv_django_quiz .`

6. Start the Django test server and go to localhost:8000 in a web browser to confirm it shows the normal Django welcome page:
   `python manage.py runserver`

7. Manually install the dependencies with pipenv. I chose this route because there are only three dependencies, and I didn't want to risk the headache of conflicts with my pipfile.lock.
   `$ pipenv install django-model-utils $ pipenv install pillow $ pipenv install tox`

Pipenv installed the following versions of the dependencies:

* django-model-utils 4.0.0

* Pillow 7.0.0

* tox 3.14.3


1. Add the django_quiz apps to the test project's INSTALLED_APPS in settings.py, as directed in the "Installation" section of the readme:
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # django_quiz apps
    'quiz',
    'multichoice',
    'true_false',
    'essay',
]
1. Add the django_quiz url to the project-level urls.py (for my mockup project, testenv_django_quiz/urls.py). I added them using the path() function rather than the url() function mentioned in the readme, since the official Django 3.0 docs say url() will likely be deprecated in a future release [https://docs.djangoproject.com/en/3.0/ref/urls/](url). I also added them as the root url of the project, since there's nothing else in this project (in a separate project, I added them at the url pattern 'quiz/' with zero problems). The final project-level urls.py code:
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('quiz.urls')),
    
]
1. Make the initial Django migrations file, and migrate it:
   `$ python manage.py makemigrations`
   `$ python manage.py migrate`

I got the following warning about the quiz/views.py, but nothing appeared to break when I ignored it:

django_quiz\quiz\views.py:333: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if score is 0:

You can fix it easily by making the edit the warning suggests.

1. Start the test server to confirm everything is working so far:
   `python manage.py runserver`

If you go to localhost:8000/ in a browser, you should see a "List of quizzes" header followed by "There are no available quizzes". If you used a different url pattern, like the 'q/' example from the readme, then localhost:8000 will return 404 but localhost:8000/q/ should work.

1. Confirm that the admin site works. Stop the test server with ctrl-c, create a superuser, restart the test server, and then go to localhost:8000/admin and log in. You should be able to create quizzes and questions there.
$ python manage.py create superuser
$ python manage.py runserver

Here are steps I just confirmed worked to make a dummy Django project with the django_quiz (as in I set this up as its own mockup project starting from a blank slate, no other apps and no other packages installed in its virtual environment).

For reference, I was working with:

* Windows 10

* Pipenv for dependencies control.
  `$ pip install pipenv`

* Python 3.8.0

* Django 2.2.9. A few weeks back, I found this to be the latest Django release that the unmodified django_quiz code worked with.

Steps:

1. Create empty directory to house the dummy project.

2. Create pipenv virtual environment there:
   `$ pipenv shell`

3. Clone the django_quiz repo there:
   `$ git clone https://github.com/tomwalker/django_quiz.git`

4. At the parent directory (rather than inside the new directory created by the git clone command), install Django 2.2.9 (make sure the pipenv virtual environment is still active, you should see the name of the virtual environment in parenthesis before the working-directory part of the command line):
   `$ pipenv install django==2.2.9`

5. Start a Django project (again in the parent directory, not in django_quiz directory). Remember the dot at the end so Django will create a manage.py in the right directory:
   `django-admin startproject testenv_django_quiz .`

6. Start the Django test server and go to localhost:8000 in a web browser to confirm it shows the normal Django welcome page:
   `python manage.py runserver`

7. Manually install the dependencies with pipenv. I chose this route because there are only three dependencies, and I didn't want to risk the headache of conflicts with my pipfile.lock.
   `$ pipenv install django-model-utils $ pipenv install pillow $ pipenv install tox`

Pipenv installed the following versions of the dependencies:

* django-model-utils 4.0.0

* Pillow 7.0.0

* tox 3.14.3


1. Add the django_quiz apps to the test project's INSTALLED_APPS in settings.py, as directed in the "Installation" section of the readme:
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # django_quiz apps
    'quiz',
    'multichoice',
    'true_false',
    'essay',
]
1. Add the django_quiz url to the project-level urls.py (for my mockup project, testenv_django_quiz/urls.py). I added them using the path() function rather than the url() function mentioned in the readme, since the official Django 3.0 docs say url() will likely be deprecated in a future release [https://docs.djangoproject.com/en/3.0/ref/urls/](url). I also added them as the root url of the project, since there's nothing else in this project (in a separate project, I added them at the url pattern 'quiz/' with zero problems). The final project-level urls.py code:
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('quiz.urls')),
    
]
1. Make the initial Django migrations file, and migrate it:
   `$ python manage.py makemigrations`
   `$ python manage.py migrate`

I got the following warning about the quiz/views.py, but nothing appeared to break when I ignored it:

django_quiz\quiz\views.py:333: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if score is 0:

You can fix it easily by making the edit the warning suggests.

1. Start the test server to confirm everything is working so far:
   `python manage.py runserver`

If you go to localhost:8000/ in a browser, you should see a "List of quizzes" header followed by "There are no available quizzes". If you used a different url pattern, like the 'q/' example from the readme, then localhost:8000 will return 404 but localhost:8000/q/ should work.

1. Confirm that the admin site works. Stop the test server with ctrl-c, create a superuser, restart the test server, and then go to localhost:8000/admin and log in. You should be able to create quizzes and questions there.
$ python manage.py create superuser
$ python manage.py runserver

Thanks man, thanks to you, I manage to understand it and make it work , even dockerize it. The problem was the python2 class encoding that wasn't compatible with Django 3.0 and above. Add six librairy and stuck Django to 2.2.9 in requirements.txt and tada!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants