diff options
-rw-r--r-- | exam/forms.py | 24 | ||||
-rw-r--r-- | exam/management/commands/dump_user_data.py | 3 | ||||
-rw-r--r-- | exam/management/commands/results2csv.py | 5 | ||||
-rw-r--r-- | exam/models.py | 4 | ||||
-rw-r--r-- | exam/views.py | 5 | ||||
-rw-r--r-- | templates/exam/monitor.html | 2 | ||||
-rw-r--r-- | templates/exam/user_data.html | 29 |
7 files changed, 54 insertions, 18 deletions
diff --git a/exam/forms.py b/exam/forms.py index cb2d37d..a5ca26f 100644 --- a/exam/forms.py +++ b/exam/forms.py @@ -11,13 +11,23 @@ PWD_CHARS = letters + punctuation + digits class UserRegisterForm(forms.Form): - username = forms.CharField(max_length=30) + username = forms.CharField(max_length=30, + help_text='Letters, digits, period and underscores only.') email = forms.EmailField() - password = forms.CharField(max_length=30, widget=forms.PasswordInput()) - confirm_password = forms.CharField(max_length=30, widget=forms.PasswordInput()) + password = forms.CharField(max_length=30, + widget=forms.PasswordInput()) + confirm_password = forms.CharField(max_length=30, + widget=forms.PasswordInput()) first_name = forms.CharField(max_length=30) last_name = forms.CharField(max_length=30) - roll_number = forms.CharField(max_length=30) + roll_number = forms.CharField(max_length=30, + help_text="Use a dummy if you don't have one.") + institute = forms.CharField(max_length=128, + help_text='Institute/Organization') + department = forms.CharField(max_length=64, + help_text='Department you work/study at') + position = forms.CharField(max_length=64, + help_text='Student/Faculty/Researcher/Industry/etc.') def clean_username(self): u_name = self.cleaned_data["username"] @@ -59,8 +69,12 @@ class UserRegisterForm(forms.Form): new_user.last_name = self.cleaned_data["last_name"] new_user.save() + cleaned_data = self.cleaned_data new_profile = Profile(user=new_user) - new_profile.roll_number = self.cleaned_data["roll_number"] + new_profile.roll_number = cleaned_data["roll_number"] + new_profile.institute = cleaned_data["institute"] + new_profile.department = cleaned_data["department"] + new_profile.position = cleaned_data["position"] new_profile.save() return u_name, pwd diff --git a/exam/management/commands/dump_user_data.py b/exam/management/commands/dump_user_data.py index bd8f566..f14e144 100644 --- a/exam/management/commands/dump_user_data.py +++ b/exam/management/commands/dump_user_data.py @@ -14,6 +14,9 @@ Name: {{ user_data.name.title }} Username: {{ user_data.username }} Roll number: {{ user_data.rollno }} Email: {{ user_data.email }} +Position: {{ user_data.position }} +Department: {{ user_data.department }} +Institute: {{ user_data.institute }} Date joined: {{ user_data.date_joined }} Last login: {{ user_data.last_login }} {% for paper in user_data.papers %} diff --git a/exam/management/commands/results2csv.py b/exam/management/commands/results2csv.py index 1adf442..f1da1a8 100644 --- a/exam/management/commands/results2csv.py +++ b/exam/management/commands/results2csv.py @@ -11,11 +11,12 @@ from exam.views import get_quiz_data from exam.models import Quiz result_template = Template('''\ -"name","username","rollno","email","answered","total","attempts" +"name","username","rollno","email","answered","total","attempts","position","department","institute" {% for paper in paper_list %}\ "{{ paper.name }}","{{ paper.username }}","{{ paper.rollno }}",\ "{{ paper.email }}","{{ paper.answered }}",{{ paper.total }},\ -{{ paper.attempts }} +{{ paper.attempts }},"{{ paper.position }}",\ +"{{ paper.department }}","{{ paper.institute }}" {% endfor %}\ ''') diff --git a/exam/models.py b/exam/models.py index 8be87e4..09529b9 100644 --- a/exam/models.py +++ b/exam/models.py @@ -7,6 +7,10 @@ class Profile(models.Model): """Profile for a user to store roll number and other details.""" user = models.ForeignKey(User) roll_number = models.CharField(max_length=20) + institute = models.CharField(max_length=128) + department = models.CharField(max_length=64) + position = models.CharField(max_length=64) + ################################################################################ class Question(models.Model): diff --git a/exam/views.py b/exam/views.py index a998606..729b1e6 100644 --- a/exam/views.py +++ b/exam/views.py @@ -269,6 +269,7 @@ def get_quiz_data(quiz_id): paper['name'] = user.get_full_name() paper['username'] = user.username paper['rollno'] = str(profile.roll_number) + paper['institute'] = str(profile.institute) paper['email'] = user.email qa = q_paper.questions_answered.split('|') answered = ', '.join(sorted(qa)) @@ -343,6 +344,10 @@ def get_user_data(username): data['email'] = user.email data['rollno'] = profile.roll_number if profile else '' data['name'] = user.get_full_name() + data['institute'] = profile.institute if profile else '' + data['department'] = profile.department if profile else '' + data['position'] = profile.position if profile else '' + data['name'] = user.get_full_name() data['date_joined'] = str(user.date_joined) data['last_login'] = str(user.last_login) papers = [] diff --git a/templates/exam/monitor.html b/templates/exam/monitor.html index a9eac24..1ce6c69 100644 --- a/templates/exam/monitor.html +++ b/templates/exam/monitor.html @@ -38,6 +38,7 @@ <th> Name </th> <th> Username </th> <th> Roll number </th> + <th> Institute </th> <th> Questions answered </th> <th> Total marks </th> <th> Attempts </th> @@ -47,6 +48,7 @@ <td> <a href="{{URL_ROOT}}/exam/user_data/{{paper.username}}">{{ paper.name.title }}</a> </td> <td> <a href="{{URL_ROOT}}/exam/user_data/{{paper.username}}">{{ paper.username }}</a> </td> <td> {{ paper.rollno }} </td> + <td> {{ paper.institute }} </td> <td> {{ paper.answered }} </td> <td> {{ paper.total }} </td> <td> {{ paper.attempts }} </td> diff --git a/templates/exam/user_data.html b/templates/exam/user_data.html index c180983..c2e8014 100644 --- a/templates/exam/user_data.html +++ b/templates/exam/user_data.html @@ -6,12 +6,17 @@ <h1> Data for user {{ user_data.name.title }} </h1> -<p> Name: {{ user_data.name.title }} </p> -<p> Username: {{ user_data.username }} </p> -<p> Roll number: {{ user_data.rollno }} </p> -<p> Email: {{ user_data.email }} </p> -<p> Date joined: {{ user_data.date_joined }} </p> -<p> Last login: {{ user_data.last_login }} </p> +<p> +Name: {{ user_data.name.title }} <br/> +Username: {{ user_data.username }} <br/> +Roll number: {{ user_data.rollno }} <br/> +Email: {{ user_data.email }} <br/> +Position: {{ user_data.position }} <br/> +Department: {{ user_data.department }} <br/> +Institute: {{ user_data.institute }} <br/> +Date joined: {{ user_data.date_joined }} <br/> +Last login: {{ user_data.last_login }} +</p> {% if user_data.papers %} @@ -19,11 +24,13 @@ <h2> Quiz: {{ paper.name }} </h2> -<p> Answered questions: {{ paper.answered }} </p> -<p> Total attempts at questions: {{ paper.attempts }} </p> -<p> Total marks: {{ paper.total }} </p> -<p> Start time: {{ paper.start_time }} </p> -<p> User IP address: {{ paper.user_ip }} </p> +<p> +Answered questions: {{ paper.answered }} <br/> +Total attempts at questions: {{ paper.attempts }} <br/> +Total marks: {{ paper.total }} <br/> +Start time: {{ paper.start_time }} <br/> +User IP address: {{ paper.user_ip }} +</p> {% if paper.answers %} <h3> Answers </h3> |