summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrabhu Ramachandran2018-03-21 18:19:39 +0530
committerGitHub2018-03-21 18:19:39 +0530
commit3226e8f455d51967c29171d601783ea4de88306a (patch)
treeb7f5e862e9bcf34a7b07a346015c6d557e148da8
parentcb6b1aad8f77035d1bfb598d8b70c51c23c435d7 (diff)
parentd015f6e34d67ac71814f91f99d2bbdfa3458f3cc (diff)
downloadonline_test-3226e8f455d51967c29171d601783ea4de88306a.tar.gz
online_test-3226e8f455d51967c29171d601783ea4de88306a.tar.bz2
online_test-3226e8f455d51967c29171d601783ea4de88306a.zip
Merge pull request #450 from adityacp/change_student_dashboard
Student Dashboard Changes
-rw-r--r--yaksh/forms.py6
-rw-r--r--yaksh/models.py8
-rw-r--r--yaksh/templates/yaksh/course_modules.html166
-rw-r--r--yaksh/templates/yaksh/quizzes_user.html35
-rw-r--r--yaksh/templates/yaksh/view_profile.html4
-rw-r--r--yaksh/test_models.py18
6 files changed, 143 insertions, 94 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index e53eda3..97b3108 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -85,10 +85,12 @@ class UserRegisterForm(forms.Form):
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.')
+ max_length=64,
+ help_text='Student/Faculty/Researcher/Industry/Fellowship/etc.')
timezone = forms.ChoiceField(
choices=[(tz, tz) for tz in pytz.common_timezones],
- initial=pytz.utc)
+ help_text='Course timings are shown based on the selected timezone',
+ initial=pytz.country_timezones['IN'][0])
def clean_username(self):
u_name = self.cleaned_data["username"]
diff --git a/yaksh/models.py b/yaksh/models.py
index 08dac7c..d9eea57 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -772,6 +772,14 @@ class Course(models.Model):
percent = round((count / len(modules)))
return percent
+ def days_before_start(self):
+ """ Get the days remaining for the start of the course """
+ if timezone.now() < self.start_enroll_time:
+ remaining_days = (self.start_enroll_time - timezone.now()).days + 1
+ else:
+ remaining_days = 0
+ return remaining_days
+
def __str__(self):
return self.name
diff --git a/yaksh/templates/yaksh/course_modules.html b/yaksh/templates/yaksh/course_modules.html
index fad1be0..afbae75 100644
--- a/yaksh/templates/yaksh/course_modules.html
+++ b/yaksh/templates/yaksh/course_modules.html
@@ -18,102 +18,100 @@
</div>
{% endif %}
{% if learning_modules %}
- {% for module in learning_modules %}
- <div class="row well">
- <table class="table">
- <tr>
- <td>
- <a href="{{URL_ROOT}}/exam/quizzes/view_module/{{module.id}}/{{course.id}}">
- {{module.name|title}}</a>
- </td>
- <td>
- <span class="glyphicon glyphicon-chevron-down" id="learning_units{{module.id}}{{course.id}}_down">
- </span>
- <span class="glyphicon glyphicon-chevron-up" id="learning_units{{module.id}}{{course.id}}_up" style="display: none;"></span>
- <a data-toggle="collapse" data-target="#learning_units{{module.id}}{{course.id}}" onclick="view_unit('learning_units{{module.id}}{{course.id}}');">
- View Lessons/Quizzes/Exercises</a>
- </td>
- <td>
- {% get_module_status user module course as module_status %}
- Status:
- {% if module_status == "completed" %}
- <span class="label label-success">
- {{module_status|title}}
- </span>
- {% elif module_status == "inprogress" %}
- <span class="label label-info">
- {{module_status|title}}
- </span>
- {% else %}
- <span class="label label-warning">
- {{module_status|title}}
- </span>
- {% endif %}
- </td>
- </tr>
- </table>
- </div>
- <div id="learning_units{{module.id}}{{course.id}}" class="collapse">
- <table class="table">
- <tr>
- <th>Lesson/Quiz/Exercise</th>
- <th>Status</th>
- <th>Type</th>
- <th>View AnswerPaper</th>
- </tr>
- {% for unit in module.get_learning_units %}
+ <table class="table">
+ {% for module in learning_modules %}
<tr>
- <ul class="inputs-list">
<td>
- {% if unit.type == "quiz" %}
- {{unit.quiz.description}}
- {% else %}
- {{unit.lesson.name}}
- {% endif %}
+ <a href="{{URL_ROOT}}/exam/quizzes/view_module/{{module.id}}/{{course.id}}">
+ {{module.name|title}}</a>
</td>
<td>
- {% get_unit_status course module unit user as status %}
- {% if status == "completed" %}
- <span class="label label-success">{{status|title}}
+ <span class="glyphicon glyphicon-chevron-down" id="learning_units{{module.id}}{{course.id}}_down">
</span>
- {% elif status == "inprogress" %}
- <span class="label label-info">{{status|title}}
+ <span class="glyphicon glyphicon-chevron-up" id="learning_units{{module.id}}{{course.id}}_up" style="display: none;">
</span>
- {% else %}
- <span class="label label-warning">{{status|title}}
- </span>
- {% endif %}
- </td>
- <td>
- {% if unit.type == "quiz" %}
- {% if unit.quiz.is_exercise %}
- Exercise
- {% else %}
- Quiz
- {% endif %}
- {% else %}
- Lesson
- {% endif %}
+ <a data-toggle="collapse" data-target="#learning_units{{module.id}}{{course.id}}" onclick="view_unit('learning_units{{module.id}}{{course.id}}');">
+ View Lessons/Quizzes/Exercises</a>
+ <div id="learning_units{{module.id}}{{course.id}}" class="collapse">
+ <table class="table">
+ <tr>
+ <th>Lesson/Quiz/Exercise</th>
+ <th>Status</th>
+ <th>Type</th>
+ <th>View AnswerPaper</th>
+ </tr>
+ {% for unit in module.get_learning_units %}
+ <tr>
+ <td>
+ {% if unit.type == "quiz" %}
+ {{unit.quiz.description}}
+ {% else %}
+ {{unit.lesson.name}}
+ {% endif %}
+ </td>
+ <td>
+ {% get_unit_status course module unit user as status %}
+ {% if status == "completed" %}
+ <span class="label label-success">{{status|title}}
+ </span>
+ {% elif status == "inprogress" %}
+ <span class="label label-info">{{status|title}}
+ </span>
+ {% else %}
+ <span class="label label-warning">{{status|title}}
+ </span>
+ {% endif %}
+ </td>
+ <td>
+ {% if unit.type == "quiz" %}
+ {% if unit.quiz.is_exercise %}
+ Exercise
+ {% else %}
+ Quiz
+ {% endif %}
+ {% else %}
+ Lesson
+ {% endif %}
+ </td>
+ <td>
+ {% if unit.type == "quiz" %}
+ {% if unit.quiz.view_answerpaper %}
+ <a href="{{ URL_ROOT }}/exam/view_answerpaper/{{ unit.quiz.questionpaper_set.get.id }}/{{course.id}}">
+ <i class="fa fa-eye" aria-hidden="true"></i> Can View </a>
+ {% else %}
+ <a>
+ <i class="fa fa-eye-slash" aria-hidden="true">
+ </i> Cannot view now </a>
+ {% endif %}
+ {% else %}
+ ------
+ {% endif %}
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
</td>
<td>
- {% if unit.type == "quiz" %}
- {% if unit.quiz.view_answerpaper %}
- <a href="{{ URL_ROOT }}/exam/view_answerpaper/{{ unit.quiz.questionpaper_set.get.id }}/{{course.id}}"><i class="fa fa-eye" aria-hidden="true"></i> Can View </a>
+ {% get_module_status user module course as module_status %}
+ Status:
+ {% if module_status == "completed" %}
+ <span class="label label-success">
+ {{module_status|title}}
+ </span>
+ {% elif module_status == "inprogress" %}
+ <span class="label label-info">
+ {{module_status|title}}
+ </span>
{% else %}
- <a>
- <i class="fa fa-eye-slash" aria-hidden="true">
- </i> Cannot view now </a>
+ <span class="label label-warning">
+ {{module_status|title}}
+ </span>
{% endif %}
- {% else %}
- ------
- {% endif %}
</td>
- </ul>
</tr>
- {% endfor %}
- </table>
- </div>
- {% endfor %}
+ {% endfor %}
+ </table>
{% else %}
<h3> No lectures found </h3>
{% endif %}
diff --git a/yaksh/templates/yaksh/quizzes_user.html b/yaksh/templates/yaksh/quizzes_user.html
index cf08752..49f8d2d 100644
--- a/yaksh/templates/yaksh/quizzes_user.html
+++ b/yaksh/templates/yaksh/quizzes_user.html
@@ -39,25 +39,44 @@ No Courses to display
</b></h4>
</div>
<div class="col-md-4">
- {% if not course.active %}
- <span class="label label-danger">Closed</span>
- {% endif %}
{% if user in course.requests.all %} <span class="label label-warning">Request Pending </span>
{% elif user in course.rejected.all %}<span class="label label-danger">Request Rejected</span>
{% elif user in course.students.all %}<span class="label label-info">Enrolled</span>
{% else %}
- {% if course.is_active_enrollment %}
- {% if course.is_self_enroll %}
- <a class="btn btn-success" href="{{ URL_ROOT }}/exam/self_enroll/{{ course.id }}">Enroll</a>
+ {% if course.active %}
+ {% if course.is_active_enrollment %}
+ {% if course.is_self_enroll %}
+ <a class="btn btn-success" href="{{ URL_ROOT }}/exam/self_enroll/{{ course.id }}">Enroll</a>
+ {% else %}
+ <a class="btn btn-success" href="{{ URL_ROOT }}/exam/enroll_request/{{ course.id }}">Enroll</a>
+ {% endif %}
{% else %}
- <a class="btn btn-success" href="{{ URL_ROOT }}/exam/enroll_request/{{ course.id }}">Enroll</a>
+ <span class="label label-danger" style="font-size: 15px">
+ Enrollment Closed
+ </span>
{% endif %}
{% else %}
- <span class="label label-danger">Enrollment Closed</span>
+ <span class="label label-danger" style="font-size: 15px">
+ Course is not activated
+ </span>
{% endif %}
{% endif %}
</div>
+ <div class="col-md-4">
+ {% if course.days_before_start != 0 %}
+ <span class="label label-info" style="font-size: 15px">
+ {{course.days_before_start}} day(s) to start
+ </span>
+ {% endif %}
+ </div>
</div>
+ {% if course.is_active_enrollment %}
+ <div class="alert alert-info">
+ Start Date&nbsp;: {{course.start_enroll_time}}
+ <br>
+ End Date&nbsp;&nbsp;: {{course.end_enroll_time}}
+ </div>
+ {% endif %}
{% if course.instructions %}
<div class="row">
diff --git a/yaksh/templates/yaksh/view_profile.html b/yaksh/templates/yaksh/view_profile.html
index 5f06135..ce95226 100644
--- a/yaksh/templates/yaksh/view_profile.html
+++ b/yaksh/templates/yaksh/view_profile.html
@@ -31,6 +31,10 @@
<th><label for="id_position"><h5>Position:</h5></label></th>
<th><label for="id_position"><h5>{{ user.profile.position }}</h5></label></th>
</tr>
+ <tr>
+ <th><label for="id_position"><h5>Timezone:</h5></label></th>
+ <th><label for="id_position"><h5>{{ user.profile.timezone }}</h5></label></th>
+ </tr>
</table>
<a class="btn btn-primary pull-right" href="{{ URL_ROOT }}/exam/editprofile/">Edit Profile</a>
{% endblock %}
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index a0ccd49..49bba00 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -1676,6 +1676,24 @@ class CourseTestCases(unittest.TestCase):
updated_percent = self.course.percent_completed(self.student1)
self.assertEqual(updated_percent, 25)
+ def test_course_time_remaining_to_start(self):
+ # check if course has 0 days left to start
+ self.assertEqual(self.course.days_before_start(), 0)
+
+ # check if course has some days left to start
+ course_time = self.course.start_enroll_time
+ self.course.start_enroll_time = datetime(
+ 2199, 12, 31, 10, 8, 15, 0,
+ tzinfo=pytz.utc
+ )
+ self.course.save()
+ updated_course = Course.objects.get(id=self.course.id)
+ time_diff = updated_course.start_enroll_time - timezone.now()
+ actual_days = time_diff.days + 1
+ self.assertEqual(updated_course.days_before_start(), actual_days)
+ self.course.start_enroll_time = course_time
+ self.course.save()
+
###############################################################################
class TestCaseTestCases(unittest.TestCase):