summaryrefslogtreecommitdiff
path: root/exam/views.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2011-11-26 00:16:24 +0530
committerPrabhu Ramachandran2011-11-26 00:16:24 +0530
commit672163bfb8e656e5250b8349aad14b2a550b57b5 (patch)
treeb3d8357c7d2964cfb67e437affaf3eb1bbf9a889 /exam/views.py
parent9000f58786bc21b05e59ddbe96f8be607f13a00d (diff)
downloadonline_test-672163bfb8e656e5250b8349aad14b2a550b57b5.tar.gz
online_test-672163bfb8e656e5250b8349aad14b2a550b57b5.tar.bz2
online_test-672163bfb8e656e5250b8349aad14b2a550b57b5.zip
BUG: Fix bugs.
If the user_dir was deleted, the script would fail. We now create the user_dir if it isn't there. If the bash script is not properly created you get other uncaught errors which were not reported. This is fixed and tested.
Diffstat (limited to 'exam/views.py')
-rw-r--r--exam/views.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/exam/views.py b/exam/views.py
index e8e2e73..61179de 100644
--- a/exam/views.py
+++ b/exam/views.py
@@ -42,7 +42,14 @@ def gen_key(no_of_chars):
def get_user_dir(user):
"""Return the output directory for the user."""
- return join(OUTPUT_DIR, str(user.username))
+ user_dir = join(OUTPUT_DIR, str(user.username))
+ if not exists(user_dir):
+ os.mkdir(user_dir)
+ # Make it rwx by others.
+ os.chmod(user_dir, stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH \
+ | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR \
+ | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP)
+ return user_dir
def index(request):
"""The start page.
@@ -133,12 +140,6 @@ def start(request):
# Make user directory.
user_dir = get_user_dir(user)
- if not exists(user_dir):
- os.mkdir(user_dir)
- # Make it rwx by others.
- os.chmod(user_dir, stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH \
- | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR \
- | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP)
questions = [ str(_.id) for _ in Question.objects.filter(active=True) ]
random.shuffle(questions)