LMS: Fixed view for Quiz
Co-authored-by: Chinmay Pai <chinmaydpai@gmail.com>
This commit is contained in:
		
							parent
							
								
									91bbe10495
								
							
						
					
					
						commit
						0d4135ec2b
					
				| @ -17,6 +17,11 @@ class Quiz(Document): | |||||||
| 		pass | 		pass | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	def get_question(self): | 	def get_questions(self): | ||||||
| 		pass | 		quiz_question = self.get_all_children() | ||||||
|  | 		if quiz_question: | ||||||
|  | 			questions = [frappe.get_doc('Question', question.question_link) for question in quiz_question] | ||||||
|  | 			return questions | ||||||
|  | 		else: | ||||||
|  | 			return None | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -22,6 +22,11 @@ def get_context(context): | |||||||
|         context.program_name = program_name |         context.program_name = program_name | ||||||
|         context.content_type = content_type |         context.content_type = content_type | ||||||
|         context.next_content_type, context.next_content = get_next_content(content_name, content_type, current_course.get_content_info()) |         context.next_content_type, context.next_content = get_next_content(content_name, content_type, current_course.get_content_info()) | ||||||
|  |         if content_type == "Quiz": | ||||||
|  |             context.questions = current_content.get_questions() | ||||||
|  |             print(content_type) | ||||||
|  |             print(current_content.title) | ||||||
|  |             print(context.questions) | ||||||
| 
 | 
 | ||||||
| def get_next_content(c_name, c_type, content_list): | def get_next_content(c_name, c_type, content_list): | ||||||
|     try: |     try: | ||||||
|  | |||||||
| @ -1,15 +1,15 @@ | |||||||
| {% macro quiz(loop_index, question) %} | {% macro quiz(loop_index, question) %} | ||||||
| <div class="question mt-4" id="question['question']" data-question="{{ question['id'] }}"> | <div class="question mt-4" id="{{ question.question }}" data-question="{{ question.name }}"> | ||||||
|     <h5>{{ loop_index }}{{ question['question'] }}</h5> |     <h5>{{ loop_index }}{{ question.question }}</h5> | ||||||
|     <div class="options ml-2"> |     <div class="options ml-2"> | ||||||
|         <div class="form-check pb-1 hidden"> |         <div class="form-check pb-1 hidden"> | ||||||
|             <input class="form-check-input" type="radio" name="{{ question['id'] }}" value="0" checked> |             <input class="form-check-input" type="radio" name="{{ question['id'] }}" value="0" checked> | ||||||
|         </div> |         </div> | ||||||
|         {% for option in question['options'] %} |         {% for option in question.options %} | ||||||
|         <div class="form-check pb-1"> |         <div class="form-check pb-1"> | ||||||
|             <input class="form-check-input" type="radio" name="{{ question['id'] }}" id="{{loop_index}}-{{ option }}" value="{{ option }}"> |             <input class="form-check-input" type="radio" name="{{ question.name }}" id="{{loop_index}}-{{ option.option }}" value="{{ option.option }}"> | ||||||
|             <label class="form-check-label" for="{{loop_index}}-{{ option }}"> |             <label class="form-check-label" for="{{loop_index}}-{{ option.option }}"> | ||||||
|                 {{ option }} |                 {{ option.option }} | ||||||
|             </label> |             </label> | ||||||
|         </div> |         </div> | ||||||
|         {% endfor %} |         {% endfor %} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user