summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2016-03-23 11:14:47 +0530
committeradityacp2016-04-15 13:57:44 +0530
commit234cf831861045796a7bcf4e08a46b0c38016f75 (patch)
tree4af3e5a066b3aee420d60eef4fcc5e7a67fdc037
parent97bdb23fbacc3e625beb96efdf58431f42604a81 (diff)
downloadonline_test-234cf831861045796a7bcf4e08a46b0c38016f75.tar.gz
online_test-234cf831861045796a7bcf4e08a46b0c38016f75.tar.bz2
online_test-234cf831861045796a7bcf4e08a46b0c38016f75.zip
EditProfile, ChangePassword, StudentsEnrollment facility
-rw-r--r--yaksh/forms.py24
-rw-r--r--yaksh/templates/manage.html2
-rw-r--r--yaksh/templates/registration/password_change_done.html16
-rw-r--r--yaksh/templates/registration/password_change_form.html18
-rw-r--r--yaksh/templates/user.html2
-rw-r--r--yaksh/templates/yaksh/course_detail.html31
-rw-r--r--yaksh/templates/yaksh/editprofile.html21
-rw-r--r--yaksh/templates/yaksh/password_changed.html15
-rw-r--r--yaksh/templates/yaksh/profile_updated.html15
-rw-r--r--yaksh/templates/yaksh/view_profile.html48
-rw-r--r--yaksh/urls.py10
-rw-r--r--yaksh/views.py67
12 files changed, 259 insertions, 10 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 84cf1c4..f4d1b02 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -187,3 +187,27 @@ class CourseForm(forms.ModelForm):
class Meta:
model = Course
fields = ['name', 'active', 'enrollment']
+
+class EditProfile(forms.Form):
+ """ edit profile form for students and moderators """
+
+ first_name = forms.CharField(max_length=30)
+ last_name = forms.CharField(max_length=30)
+ institute = forms.CharField\
+ (max_length=128)
+ department = forms.CharField\
+ (max_length=64)
+ roll_number = forms.CharField\
+ (max_length=30)
+ position = forms.CharField\
+ (max_length=64)
+
+ def save(self, user):
+ user.first_name = self.cleaned_data['first_name']
+ user.last_name = self.cleaned_data['last_name']
+ user.profile.department = self.cleaned_data['department']
+ user.profile.institute = self.cleaned_data['institute']
+ user.profile.roll_number = self.cleaned_data['roll_number']
+ user.profile.position = self.cleaned_data['position']
+ user.save()
+ user.profile.save()
diff --git a/yaksh/templates/manage.html b/yaksh/templates/manage.html
index 11e2187..a10291b 100644
--- a/yaksh/templates/manage.html
+++ b/yaksh/templates/manage.html
@@ -30,6 +30,8 @@
<li><a href="{{ URL_ROOT }}/exam/manage/gradeuser">Grade User</a></li>
<li><a href="{{ URL_ROOT }}/exam/manage/monitor">Monitor</a></li>
<li><a href="{{ URL_ROOT }}/exam/manage/courses">Courses</a></li>
+<li><a href="{{ URL_ROOT }}/exam/manage/viewprofile">My Profile</a></li>
+<li><a href="{{ URL_ROOT }}/exam/changepassword">Change Password</a></li>
</ul>
<ul style="float:right;">
<li><strong><a style='cursor:pointer' onClick='location.replace("{{URL_ROOT}}/exam/complete/");'>Log out</a></strong></li>
diff --git a/yaksh/templates/registration/password_change_done.html b/yaksh/templates/registration/password_change_done.html
new file mode 100644
index 0000000..fef07d1
--- /dev/null
+++ b/yaksh/templates/registration/password_change_done.html
@@ -0,0 +1,16 @@
+{% extends "base.html" %}
+
+{% block title %}Password change successful{% endblock %}
+{% block pagetitle %}Online Test {% endblock %}
+{% block script %}
+<script type="text/javascript">
+ window.setTimeout(function()
+ {
+ location.href="{{ URL_ROOT }}/exam/"
+ }, 2000);
+</script>
+{% endblock %}
+{% block content %}
+<h3>Your password has been changed successfully.</h3>
+<h4>Redirecting ...</h4>
+{% endblock %} \ No newline at end of file
diff --git a/yaksh/templates/registration/password_change_form.html b/yaksh/templates/registration/password_change_form.html
new file mode 100644
index 0000000..48292f8
--- /dev/null
+++ b/yaksh/templates/registration/password_change_form.html
@@ -0,0 +1,18 @@
+{% extends "base.html" %}
+<!DOCTYPE html>
+{% block title %} Change Password {% endblock %}
+
+{% block pagetitle %} Online Test {% endblock %}
+
+{% block content %}
+<form action="" method="post" >
+ {% csrf_token %}
+ <center>
+ <table class=span1>
+ {{ form }}
+ </table>
+ </center>
+ <center><button class="btn" type="submit">Change Password</button>
+ <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/");'>Cancel</button></center>
+</form>
+{% endblock content %}
diff --git a/yaksh/templates/user.html b/yaksh/templates/user.html
index 00151d2..b3931cf 100644
--- a/yaksh/templates/user.html
+++ b/yaksh/templates/user.html
@@ -30,6 +30,8 @@
<ul>
<li><a href="{{ URL_ROOT }}/exam/quizzes">Quizzes</a></li>
<li><a href="{{ URL_ROOT }}/exam/results">Results</a></li>
+ <li><a href="{{ URL_ROOT }}/exam/viewprofile">My Profile</a></li>
+ <li><a href="{{ URL_ROOT }}/exam/changepassword">Change Password</a></li>
</ul>
<ul style="float:right;">
<li><strong><a style='cursor:pointer' onClick='location.replace("{{URL_ROOT}}/exam/complete/");'>Log out</a></strong></li>
diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html
index ed56585..2e17035 100644
--- a/yaksh/templates/yaksh/course_detail.html
+++ b/yaksh/templates/yaksh/course_detail.html
@@ -7,21 +7,44 @@
{% block css %}
<link rel="stylesheet" media="all" type="text/css" href="{{ URL_ROOT }}/static/yaksh/css/course.css" />
{% endblock %}
-
+{% block script %}
+<script language="JavaScript" type="text/javascript" src="{{ URL_ROOT }}/static/yaksh/js/jquery-1.4.2.min.js"></script>
+<script>
+$(document).ready(function(){
+$(".checkall").click( function(){
+ if($(this).attr("checked")) {
+ $("#enroll-all input:checkbox").each(function(index, element) {
+ $(this).attr('checked', true);
+ });
+ }
+ else {
+ $("#enroll-all input:checkbox").each(function(index, element) {
+ $(this).attr('checked', false);
+ });
+ }
+ });
+});
+</script>
+{% endblock %}
{% block manage %}
<div class="row">
<div class="span6 wrap">
<center><b><u>Requests</u></b></center><br>
+ <form action="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}" method="post">
+ {% csrf_token %}
+ <input type="checkbox" class="checkall"/><font size="2">Enroll all</font>
+ <div id="enroll-all">
{% for request in course.get_requests %}
<div class="well">
<div class="row">
- <div class="span3" style="padding-top:10px">
- {{ request.username }}
+ <div class="span3" style="padding-top:10px">
+ <input type="checkbox" name="check" value="{{ request.id }}"></input>&nbsp;&nbsp;<a href="#" data-toggle="tooltip" title=" Institute: {{ request.profile.institute }}&#013;Department: {{ request.profile.department}}&#013;Roll Number: {{ request.profile.roll_number }}">{{ request.username }}</a><br>
</div>
<a class="btn success" href="{{URL_ROOT}}/exam/manage/enroll/{{ course.id }}/{{ request.id }}/"> Enroll </a> <a class="btn danger" href="{{URL_ROOT}}/exam/manage/reject/{{ course.id }}/{{ request.id }}/"> Reject </a>
</div>
</div>
{% endfor %}
+ </div>
</div>
<div class="span6 wrap">
<center><b><u>Rejected</u></b></center><br>
@@ -38,6 +61,8 @@
</div>
</div>
<br>
+<button class="btn" type="submit" name='enroll' value='enroll'>Enroll</button>
+</form>
<div class="row">
<div class="span6 offset4 wrap">
<center><b><u>Enrolled</u></b></center><br>
diff --git a/yaksh/templates/yaksh/editprofile.html b/yaksh/templates/yaksh/editprofile.html
new file mode 100644
index 0000000..b4cf037
--- /dev/null
+++ b/yaksh/templates/yaksh/editprofile.html
@@ -0,0 +1,21 @@
+{% extends "base.html" %}
+
+{% block title %} Edit Profile {% endblock %}
+
+{% block pagetitle %} Online Test {% endblock %}
+{% block formtitle %} Please fill in the following details {% endblock %}
+
+{% block content %}
+
+<form action="" method="post" >
+ {% csrf_token %}
+ <center>
+ <table class=span1>
+ {{ form.as_table }}
+ </table>
+ </center>
+ <center><button class="btn" type="submit">Edit Profile</button>
+ <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/");'>Cancel</button> </center>
+</form>
+
+{% endblock content %}
diff --git a/yaksh/templates/yaksh/password_changed.html b/yaksh/templates/yaksh/password_changed.html
new file mode 100644
index 0000000..cce2d53
--- /dev/null
+++ b/yaksh/templates/yaksh/password_changed.html
@@ -0,0 +1,15 @@
+{% extends "base.html" %}
+<!DOCTYPE html>
+{% block title %} Profile {% endblock %}
+
+{% block pagetitle %} Online Test {% endblock %}
+
+{% block script %}
+<script>
+ window.setTimeout(function(){ location.href="{{ URL_ROOT }}/exam/" }, 2000);
+</script>
+{% endblock script %}
+{% block content %}
+<h3>Your Password is changed {{ user.first_name }}</h3>
+<h3>Redirecting...</h3>
+{% endblock content %}
diff --git a/yaksh/templates/yaksh/profile_updated.html b/yaksh/templates/yaksh/profile_updated.html
new file mode 100644
index 0000000..6ccf177
--- /dev/null
+++ b/yaksh/templates/yaksh/profile_updated.html
@@ -0,0 +1,15 @@
+{% extends "base.html" %}
+<!DOCTYPE html>
+{% block title %} Profile {% endblock %}
+
+{% block pagetitle %} Online Test {% endblock %}
+
+{% block script %}
+<script>
+ window.setTimeout(function(){ location.href="{{ URL_ROOT }}/exam/" }, 2000);
+</script>
+{% endblock script %}
+{% block content %}
+<h3>Your Profile is changed {{ user.first_name }}</h3>
+<h3>Redirecting...</h3>
+{% endblock content %}
diff --git a/yaksh/templates/yaksh/view_profile.html b/yaksh/templates/yaksh/view_profile.html
new file mode 100644
index 0000000..27bc5da
--- /dev/null
+++ b/yaksh/templates/yaksh/view_profile.html
@@ -0,0 +1,48 @@
+{% extends "base.html" %}
+
+{% block title %} View Profile {% endblock %}
+
+{% block pagetitle %} Online Test {% endblock %}
+{% block css %}
+<link rel="stylesheet" media="all" type="text/css" href="{{ URL_ROOT }}/static/yaksh/css/base.css" />
+{% endblock %}
+{% block content %}
+<ul>
+ <a href={{ URL_ROOT }}/exam/manage/editprofile>Edit Profile</a>
+ <a href={{ URL_ROOT }}/exam/>Back to Home</a>
+</ul>
+
+ <table width="398" border="0" align="center" cellpadding="0">
+ <tr>
+ <td height="26" colspan="2"><h2>Your Profile Information</h2> </td>
+ </tr>
+ <tr>
+ <td width="82" valign="top"><h3>Firstname:</h3></td>
+ <td width="165" valign="top"><h4>{{ user.first_name }}</h4></td>
+ </tr>
+ <tr>
+ <td valign="top"><h3>Lastname:</h3></td>
+ <td valign="top"><h4>{{ user.last_name }}</h4></td>
+ </tr>
+ <tr>
+ <td valign="top"><h3>Email:</h3><h3></td>
+ <td valign="top"><h4>{{ user.email }}</h4></td>
+ </tr>
+ <tr>
+ <td valign="top"><h3>Institute:</h3></td>
+ <td valign="top"><h4>{{ user.profile.institute }}</h4></td>
+ </tr>
+ <tr>
+ <td valign="top"><h3>Department:</h3></td>
+ <td valign="top"><h4>{{ user.profile.department }}</h4></td>
+ </tr>
+ <tr>
+ <td valign="top"><h3>Roll Number:</h3></td>
+ <td valign="top"><h4>{{ user.profile.roll_number }}</h4></td>
+ </tr>
+ <tr>
+ <td valign="top"><h3>Position:</h3></td>
+ <td valign="top"><h4>{{ user.profile.position }}</h4></td>
+ </tr>
+</table>
+{% endblock %}
diff --git a/yaksh/urls.py b/yaksh/urls.py
index b2f894f..584064d 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -1,7 +1,8 @@
from django.conf.urls import patterns, url
from yaksh import views
from django.contrib.auth.views import password_reset, password_reset_confirm,\
- password_reset_done, password_reset_complete
+ password_reset_done, password_reset_complete, password_change,\
+ password_change_done
urlpatterns = [
url(r'^forgotpassword/$', password_reset, name="password_reset"),
@@ -11,6 +12,8 @@ urlpatterns = [
name='password_reset_done'),
url(r'^password_reset/complete/$', password_reset_complete,
name='password_reset_complete'),
+ url(r'^changepassword/$', 'password_change', name='password_change'),
+ url(r'^password_change/done/$', 'password_change_done', name='password_change_done'),
]
urlpatterns += [
url(r'^$', views.index),
@@ -34,7 +37,6 @@ urlpatterns += [
views.skip),
url(r'^enroll_request/(?P<course_id>\d+)/$', views.enroll_request),
url(r'^self_enroll/(?P<course_id>\d+)/$', views.self_enroll),
-
url(r'^manage/$', views.prof_manage),
url(r'^manage/addquestion/$', views.add_question),
url(r'^manage/addquestion/(?P<question_id>\d+)/$', views.add_question),
@@ -74,4 +76,8 @@ urlpatterns += [
url(r'manage/toggle_status/(?P<course_id>\d+)/$', views.toggle_course_status),
url(r'^ajax/questionpaper/(?P<query>.+)/$', views.ajax_questionpaper),
url(r'^ajax/questions/filter/$', views.ajax_questions_filter),
+ url(r'^manage/editprofile/$', views.edit_profile),
+ url(r'^manage/viewprofile/$', views.view_profile),
+ url(r'^manage/enroll/(?P<course_id>\d+)', views.enroll)
]
+
diff --git a/yaksh/views.py b/yaksh/views.py
index 8b0a131..2738a26 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -22,7 +22,7 @@ from yaksh.models import Quiz, Question, QuestionPaper, QuestionSet, Course
from yaksh.models import Profile, Answer, AnswerPaper, User, TestCase
from yaksh.forms import UserRegisterForm, UserLoginForm, QuizForm,\
QuestionForm, RandomQuestionForm, TestCaseFormSet,\
- QuestionFilterForm, CourseForm
+ QuestionFilterForm, CourseForm, EditProfile
from yaksh.xmlrpc_clients import code_server
from settings import URL_ROOT
from yaksh.models import AssignmentUpload
@@ -603,20 +603,31 @@ def courses(request):
@login_required
def course_detail(request, course_id):
user = request.user
+ ci = RequestContext(request)
if not is_moderator(user):
raise Http404('You are not allowed to view this page')
course = get_object_or_404(Course, creator=user, pk=course_id)
- return my_render_to_response('yaksh/course_detail.html', {'course': course})
+ return my_render_to_response('yaksh/course_detail.html', {'course': course},
+ context_instance=ci)
@login_required
-def enroll(request, course_id, user_id, was_rejected=False):
+def enroll(request, course_id, user_id=None, was_rejected=False):
user = request.user
+ ci = RequestContext(request)
if not is_moderator(user):
raise Http404('You are not allowed to view this page')
course = get_object_or_404(Course, creator=user, pk=course_id)
- user = get_object_or_404(User, pk=user_id)
- course.enroll(was_rejected, user)
+ if request.method == 'POST':
+ enroll_ids = request.POST.getlist('check')
+ if enroll_ids is None:
+ return my_render_to_response('yaksh/course_detail.html', {'course': course},
+ context_instance=ci)
+ else:
+ course.enroll(was_rejected, *enroll_ids)
+ else:
+ user = get_object_or_404(User, pk=user_id)
+ course.enroll(was_rejected, user)
return course_detail(request, course_id)
@@ -954,3 +965,49 @@ def design_questionpaper(request):
context = {'form': form, 'questionpaper':True}
return my_render_to_response('yaksh/design_questionpaper.html',
context, context_instance=ci)
+
+@login_required
+def view_profile(request):
+ """ view moderators and users profile """
+
+ context = {}
+ user = request.user
+ ci = RequestContext(request)
+ if not user.is_authenticated():
+ raise Http404('You are not allowed to view this page!')
+ else:
+ return my_render_to_response('yaksh/view_profile.html',
+ context_instance=ci)
+
+@login_required
+def edit_profile(request):
+ """ edit profile details facility for moderator and students """
+
+ context = {}
+ user = request.user
+ ci = RequestContext(request)
+ data = {}
+ if not user.is_authenticated():
+ raise Http404('You are not allowed to view this page!')
+ if request.method == 'POST':
+ form = EditProfile(request.POST)
+ if form.is_valid():
+ data = form.cleaned_data
+ form.save(user)
+ return my_render_to_response('yaksh/profile_updated.html',
+ context_instance=ci)
+ else:
+ context['form'] = form
+ return my_render_to_response('yaksh/editprofile.html', context,
+ context_instance=ci)
+ else:
+ data['first_name'] = user.first_name
+ data['last_name'] = user.last_name
+ data['institute'] = user.profile.institute
+ data['department'] = user.profile.department
+ data['roll_number'] = user.profile.roll_number
+ data['position'] = user.profile.position
+ form = EditProfile(initial=data)
+ context['form'] = form
+ return my_render_to_response('yaksh/editprofile.html', context,
+ context_instance=ci)