Merge branch 'develop' into education-test-fixes
diff --git a/erpnext/www/lms/content.html b/erpnext/www/lms/content.html
index 9b8c45c..5607c08 100644
--- a/erpnext/www/lms/content.html
+++ b/erpnext/www/lms/content.html
@@ -58,7 +58,7 @@
 
 {% macro title() %}
 	<div class="mb-3">
-		<a href="#" class="text-muted">
+		<a href="/lms/course?name={{ course }}&program={{ program }}" class="text-muted">
 				Back to Course
 		</a>
 	</div>
diff --git a/erpnext/www/lms/course.html b/erpnext/www/lms/course.html
index 250c39d..7f7a311 100644
--- a/erpnext/www/lms/course.html
+++ b/erpnext/www/lms/course.html
@@ -45,7 +45,7 @@
 			<div onclick="show_singup()">
 		{% endif %}
 			{% if topic.hero_image %}
-			<div class="card-hero-img" style="background-image: url('{{ topic.hero_image }})'"></div>
+			<div class="card-hero-img" style="background-image: url('{{ topic.hero_image }}')"></div>
 			{% else %}
 			<div class="card-image-wrapper text-center">
 				<div class="image-body"><i class="fa fa-picture-o" aria-hidden="true"></i></div>
@@ -96,7 +96,7 @@
 				{{ card(topic) }}
 			{% endfor %}
 			{% if topics %}
-				{% for n in range(((topics|length)%3)) %}
+				{% for n in range( (3 - (topics|length)) %3) %}
 					{{ null_card() }}
 				{% endfor %}
 			{% endif %}
diff --git a/erpnext/www/lms/course.py b/erpnext/www/lms/course.py
index e7ed2e3..c18d64e 100644
--- a/erpnext/www/lms/course.py
+++ b/erpnext/www/lms/course.py
@@ -5,9 +5,16 @@
 no_cache = 1
 
 def get_context(context):
+	try:
+		program = frappe.form_dict['program']
+		course_name = frappe.form_dict['name']
+	except KeyError:
+		frappe.local.flags.redirect_location = '/lms'
+		raise frappe.Redirect
+
 	context.education_settings = frappe.get_single("Education Settings")
-	course = frappe.get_doc('Course', frappe.form_dict['name'])
-	context.program = frappe.form_dict['program']
+	course = frappe.get_doc('Course', course_name)
+	context.program = program
 	context.course = course
 
 	context.topics = course.get_topics()
diff --git a/erpnext/www/lms/index.html b/erpnext/www/lms/index.html
index 0114235..ffb4419 100644
--- a/erpnext/www/lms/index.html
+++ b/erpnext/www/lms/index.html
@@ -55,7 +55,7 @@
 				{{ program_card(program.program, program.has_access) }}
 			{% endfor %}
 			{% if featured_programs %}
-				{% for n in range((featured_programs|length)%3) %}
+				{% for n in range( (3 - (featured_programs|length)) %3) %}
 					{{ null_card() }}
 				{% endfor %}
 			{% endif %}
diff --git a/erpnext/www/lms/program.html b/erpnext/www/lms/program.html
index 6c144d4..271b781 100644
--- a/erpnext/www/lms/program.html
+++ b/erpnext/www/lms/program.html
@@ -77,7 +77,7 @@
 				{{ card(course) }}
 			{% endfor %}
 			{% if courses %}
-				{% for n in range((courses|length)%3) %}
+				{% for n in range( (3 - (courses|length)) %3) %}
 					{{ null_card() }}
 				{% endfor %}
 			{% endif %}
diff --git a/erpnext/www/lms/program.py b/erpnext/www/lms/program.py
index 1fcb3d3..7badedc 100644
--- a/erpnext/www/lms/program.py
+++ b/erpnext/www/lms/program.py
@@ -6,10 +6,16 @@
 no_cache = 1
 
 def get_context(context):
+	try:
+		program = frappe.form_dict['program']
+	except KeyError:
+		frappe.local.flags.redirect_location = '/lms'
+		raise frappe.Redirect
+
 	context.education_settings = frappe.get_single("Education Settings")
-	context.program = get_program(frappe.form_dict['program'])
+	context.program = get_program(program)
 	context.courses = [frappe.get_doc("Course", course.course) for course in context.program.courses]
-	context.has_access = utils.allowed_program_access(frappe.form_dict['program'])
+	context.has_access = utils.allowed_program_access(program)
 	context.progress = get_course_progress(context.courses, context.program)
 
 def get_program(program_name):
diff --git a/erpnext/www/lms/topic.html b/erpnext/www/lms/topic.html
index 3e439fc..1f0d187 100644
--- a/erpnext/www/lms/topic.html
+++ b/erpnext/www/lms/topic.html
@@ -48,7 +48,7 @@
 				{{ card(content, loop.index, topic.contents|length) }}
 			{% endfor %}
 			{% if contents %}
-				{% for n in range((contents|length)%3) %}
+				{% for n in range( (3 - (contents|length)) %3) %}
 					{{ null_card() }}
 				{% endfor %}
 			{% endif %}
diff --git a/erpnext/www/lms/topic.py b/erpnext/www/lms/topic.py
index 0af0778..f75ae8e 100644
--- a/erpnext/www/lms/topic.py
+++ b/erpnext/www/lms/topic.py
@@ -5,9 +5,13 @@
 no_cache = 1
 
 def get_context(context):
-	course = frappe.form_dict['course']
-	program = frappe.form_dict['program']
-	topic = frappe.form_dict['topic']
+	try:
+		course = frappe.form_dict['course']
+		program = frappe.form_dict['program']
+		topic = frappe.form_dict['topic']
+	except KeyError:
+		frappe.local.flags.redirect_location = '/lms'
+		raise frappe.Redirect
 
 	context.program = program
 	context.course = course