summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/templatetags/custom_filters.py5
-rw-r--r--yaksh/views.py14
2 files changed, 14 insertions, 5 deletions
diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py
index 056421f..fae0382 100644
--- a/yaksh/templatetags/custom_filters.py
+++ b/yaksh/templatetags/custom_filters.py
@@ -87,3 +87,8 @@ def get_answer_for_arrange_options(ans, question):
@register.filter(name='replace_spaces')
def replace_spaces(name):
return name.replace(" ", "_")
+
+
+@register.simple_tag
+def get_questions_by_type(all_questions, question_type):
+ return [question for question in all_questions if question.type == question_type]
diff --git a/yaksh/views.py b/yaksh/views.py
index 1bb335c..5c3ba93 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -28,10 +28,12 @@ import re
# Local imports.
from yaksh.code_server import get_result as get_result_from_code_server
from yaksh.models import (
- Answer, AnswerPaper, AssignmentUpload, Course, FileUpload, Profile,
- QuestionPaper, QuestionSet, Quiz, Question, TestCase, User,
- FIXTURES_DIR_PATH, MOD_GROUP_NAME, Lesson, LessonFile, LearningUnit,
- LearningModule, CourseStatus
+ Answer, AnswerPaper, AssignmentUpload, Course, FileUpload, FloatTestCase,
+ HookTestCase, IntegerTestCase, McqTestCase, Profile,
+ QuestionPaper, QuestionSet, Quiz, Question, StandardTestCase,
+ StdIOBasedTestCase, StringTestCase, TestCase, User,
+ get_model_class, FIXTURES_DIR_PATH, MOD_GROUP_NAME, Lesson, LessonFile,
+ LearningUnit, LearningModule, CourseStatus, question_types
)
from yaksh.forms import (
UserRegisterForm, UserLoginForm, QuizForm, QuestionForm,
@@ -613,6 +615,7 @@ def show_question(request, question, paper, error_message=None,
course = Course.objects.get(id=course_id)
module = course.learning_module.get(id=module_id)
all_modules = course.get_learning_modules()
+ all_question_types = [types[0] for types in question_types]
context = {
'question': question,
'paper': paper,
@@ -627,7 +630,8 @@ def show_question(request, question, paper, error_message=None,
'can_skip': can_skip,
'delay_time': delay_time,
'quiz_type': quiz_type,
- 'all_modules': all_modules
+ 'all_modules': all_modules,
+ "question_types": all_question_types
}
answers = paper.get_previous_answers(question)
if answers: