From 3821314e0913ca620cc84d08a880370979db7aa3 Mon Sep 17 00:00:00 2001 From: Prabhu Ramachandran Date: Mon, 21 Nov 2011 10:38:46 +0530 Subject: DOC: Updating readme and moving samples to docs. --- README.txt | 65 ++++++++++++++++++++++++++++++++++++++--------- docs/sample_questions.py | 31 ++++++++++++++++++++++ docs/sample_questions.xml | 37 +++++++++++++++++++++++++++ sample_questions.py | 31 ---------------------- sample_questions.xml | 37 --------------------------- 5 files changed, 121 insertions(+), 80 deletions(-) create mode 100644 docs/sample_questions.py create mode 100644 docs/sample_questions.xml delete mode 100644 sample_questions.py delete mode 100644 sample_questions.xml diff --git a/README.txt b/README.txt index f86e1fd..0162c93 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,5 @@ -Installation -============= +Installation and Deployment +============================= To install/deploy this app follow the steps below: @@ -10,12 +10,12 @@ To install/deploy this app follow the steps below: $ python manage.py syncdb [ enter password etc.] - 3. Add questions by editing the sample_questions.xml or any other xml + 3. Add questions by editing the "doc/sample_questions.py" or any other file in the same format and then run the following:: - $ python manage.py load_questions_xml sample_questions.xml + $ python manage.py load_exam doc/sample_questions.py - Note that you can supply multiple xml files as arguments and all of + Note that you can supply multiple Python files as arguments and all of those will be added to the database. 4. First run the python server provided. This ensures that the code is @@ -23,10 +23,12 @@ To install/deploy this app follow the steps below: $ sudo python python_server.py - Using sudo is necessary since the server is run as the user "nobody". This - runs on port 8001 by default and may be changed in the settings in the - variable SERVER_PORT. The SERVER_TIMEOUT also can be changed there. This - is the maximum time allowed to execute the submitted code. + Using sudo is necessary since the server is run as the user + "nobody". This runs on the ports configured in the settings.py file + in the variable "SERVER_PORTS". The "SERVER_TIMEOUT" also can be + changed there. This is the maximum time allowed to execute the + submitted code. Note that this will likely spawn multiple processes + as "nobody" depending on the number of server ports specified. 5. Now, run:: @@ -38,10 +40,12 @@ To install/deploy this app follow the steps below: 6. Go to http://deserved_host_or_ip:desired_port/admin 7. Login with your credentials and look at the questions and modify if - needed. Create a new Quiz, set the date and duration. + needed. Create a new Quiz, set the date and duration or + activate/deactivate the quiz. 8. Now ask users to login at: - http://server_ip:server_port/exam + + http://host:port/exam And you should be all set. @@ -49,13 +53,43 @@ To install/deploy this app follow the steps below: user. Users can potentially write output into these that can be used for checking later. + 10. As admin user you can visit http://host/exam/monitor to view + results and user data interactively. + + 11. You may dump the results and user data using the results2csv and + dump_user_data commands. WARNING: django is running in debug mode for this currently, CHANGE it during deployment. To do this, edit settings.py and set DEBUG to False. +Also look at other settings and change them suitably. -The file sample_questions.xml is a template that you can use for your +The file doc/sample_questions.py is a template that you can use for your own questions. +Additional commands available +============================== + +We provide several convenient commands for you to use: + + - load_exam : load questions and a quiz from a python file. See + docs/sample_questions.py + + - load_questions_xml : load questions from XML file, see + docs/sample_questions.xml use of this is deprecated in favor of + load_exam. + + - results2csv : Dump the quiz results into a CSV file for further + processing. + + - dump_user_data : Dump out relevalt user data for either all users or + specified users. + +For more information on these do this:: + + $ ./manage.py help [command] + +where [command] is one of the above. + Deploying via Apache ===================== @@ -70,3 +104,10 @@ to your apache.conf. For more details see the Django docs here: https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/ + +Sometimes you might be in the situation where you are not hosted as +"host.org/exam/" but as "host.org/foo/exam/" for whatever reason. In +this case edit "settings.py" and set the "URL_ROOT" to the root you +have to serve at. In the above example for "host.org/foo/exam" set +URL_ROOT='/foo'. + diff --git a/docs/sample_questions.py b/docs/sample_questions.py new file mode 100644 index 0000000..c77eb9d --- /dev/null +++ b/docs/sample_questions.py @@ -0,0 +1,31 @@ +from datetime import date + +questions = [ +Question( + summary='Factorial', + points=2, + description=''' +Write a function called "fact" which takes a single integer argument (say "n") +and returns the factorial of the number. +For example fact(3) -> 6''', + test=''' +assert fact(0) == 1 +assert fact(5) == 120 +'''), + +Question( + summary='Simple function', + points=1, + description='''Create a simple function called "sqr" which takes a single +argument and returns the square of the argument. For example sqr(3) -> 9.''', + test=''' +import math +assert sqr(3) == 9 +assert abs(sqr(math.sqrt(2)) - 2.0) < 1e-14 + '''), +] + +quiz = Quiz(start_date=date.today(), + duration=10, + description='Basic Python Quiz 1' + ) diff --git a/docs/sample_questions.xml b/docs/sample_questions.xml new file mode 100644 index 0000000..104ea32 --- /dev/null +++ b/docs/sample_questions.xml @@ -0,0 +1,37 @@ + + + + +Factorial + + +Write a function called "fact" which takes a single integer argument (say "n") +and returns the factorial of the number. +For example fact(3) -> 6 + +2 + +assert fact(0) == 1 +assert fact(5) == 120 + + + + + +Simple function + + +Create a simple function called "sqr" which takes a single argument and +returns the square of the argument +For example sqr(3) -> 9. + +1 + +import math +assert sqr(3) == 9 +assert abs(sqr(math.sqrt(2)) - 2.0) < 1e-14 + + + + + diff --git a/sample_questions.py b/sample_questions.py deleted file mode 100644 index c77eb9d..0000000 --- a/sample_questions.py +++ /dev/null @@ -1,31 +0,0 @@ -from datetime import date - -questions = [ -Question( - summary='Factorial', - points=2, - description=''' -Write a function called "fact" which takes a single integer argument (say "n") -and returns the factorial of the number. -For example fact(3) -> 6''', - test=''' -assert fact(0) == 1 -assert fact(5) == 120 -'''), - -Question( - summary='Simple function', - points=1, - description='''Create a simple function called "sqr" which takes a single -argument and returns the square of the argument. For example sqr(3) -> 9.''', - test=''' -import math -assert sqr(3) == 9 -assert abs(sqr(math.sqrt(2)) - 2.0) < 1e-14 - '''), -] - -quiz = Quiz(start_date=date.today(), - duration=10, - description='Basic Python Quiz 1' - ) diff --git a/sample_questions.xml b/sample_questions.xml deleted file mode 100644 index 104ea32..0000000 --- a/sample_questions.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - -Factorial - - -Write a function called "fact" which takes a single integer argument (say "n") -and returns the factorial of the number. -For example fact(3) -> 6 - -2 - -assert fact(0) == 1 -assert fact(5) == 120 - - - - - -Simple function - - -Create a simple function called "sqr" which takes a single argument and -returns the square of the argument -For example sqr(3) -> 9. - -1 - -import math -assert sqr(3) == 9 -assert abs(sqr(math.sqrt(2)) - 2.0) < 1e-14 - - - - - -- cgit