summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/test_views.py12
-rw-r--r--yaksh/views.py19
2 files changed, 19 insertions, 12 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 14c0c94..8592031 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -9,7 +9,6 @@ except ImportError:
import zipfile
import shutil
from markdown import Markdown
-
from django.contrib.auth.models import Group
from django.contrib.auth import authenticate
from django.core.urlresolvers import reverse
@@ -26,7 +25,7 @@ from yaksh.models import (
User, Profile, Question, Quiz, QuestionPaper, AnswerPaper, Answer, Course,
AssignmentUpload, McqTestCase, IntegerTestCase, StringTestCase,
FloatTestCase, FIXTURES_DIR_PATH, LearningModule, LearningUnit, Lesson,
- LessonFile
+ LessonFile, CourseStatus
)
from yaksh.decorators import user_has_profile
@@ -2744,10 +2743,11 @@ class TestCourseDetail(TestCase):
response = self.client.get(reverse('yaksh:get_user_data',
kwargs={'course_id': self.user1_course.id,
'student_id': self.student.id}))
- err_msg = response.json()['user_data'].replace("\n", "").strip()
- actual_err = dedent("""\
- You are neither course creator nor course teacher for {0}""".format(
- self.user1_course.name))
+ err_msg = response.json()['user_data'].strip()
+ actual_err = ('You are neither course creator '
+ 'nor course teacher for {0}'.format(
+ self.user1_course.name)
+ )
self.assertEqual(response.status_code, 200)
self.assertEqual(err_msg, actual_err)
diff --git a/yaksh/views.py b/yaksh/views.py
index 8a0ab90..3341aca 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -2698,8 +2698,10 @@ def course_modules(request, course_id, msg=None):
context = {"course": course, "user": user, "msg": msg}
course_status = CourseStatus.objects.filter(course=course, user=user)
context['course_percentage'] = course.get_completion_percent(user)
- context['modules'] = [(module, module.get_module_complete_percent(course, user))
- for module in learning_modules]
+ context['modules'] = [
+ (module, module.get_module_complete_percent(course, user))
+ for module in learning_modules
+ ]
if course_status.exists():
course_status = course_status.first()
if not course_status.grade:
@@ -2778,16 +2780,21 @@ def get_user_data(request, course_id, student_id):
data['msg'] = 'You are not a moderator'
data['status'] = False
elif not course.is_creator(user) and not course.is_teacher(user):
- msg = 'You are neither course creator nor course teacher for {0}'.format(
- course.name)
+ msg = dedent(
+ """\
+ You are neither course creator nor course teacher for {0}
+ """.format(course.name)
+ )
data['msg'] = msg
data['status'] = False
else:
student = User.objects.get(id=student_id)
data['status'] = True
modules = course.get_learning_modules()
- module_percent = [(module, module.get_module_complete_percent(course, student))
- for module in modules]
+ module_percent = [
+ (module, module.get_module_complete_percent(course, student))
+ for module in modules
+ ]
data['modules'] = module_percent
_update_course_percent(course, student)
data['course_percentage'] = course.get_completion_percent(student)