Browse Source

Get lesson and assessment IDs to retrieve engagement information.

tags/20180716
Sam Black 2 years ago
parent
commit
e45e16bd89
2 changed files with 18 additions and 7 deletions
  1. +1
    -1
      vowel/models/analytics.py
  2. +17
    -6
      vowel/views/organisation/analytics.py

+ 1
- 1
vowel/models/analytics.py View File

@@ -62,7 +62,7 @@ class Engagement(db.Model):
return getattr(dur, division)
elif division == "minutes":
# This is not accurate, but see TODO above
return dur.seconds // 60 + (1 if dur.seconds % 60 else 0)
return dur.seconds // 60
else:
return dur.seconds



+ 17
- 6
vowel/views/organisation/analytics.py View File

@@ -23,8 +23,10 @@ from flask import jsonify
from flask import render_template
from flask_security import login_required

from vowel.models.assessments import Assessmentinstance
from vowel.models.courses import Course
from vowel.models.courses import Courseinstance
from vowel.models.lessons import Lessoninstance

from vowel.utils.auth import organisation_staff_member_access
from vowel.utils.analytics import course_engagements
@@ -258,21 +260,30 @@ def course_chart_engagement(course_id):
if "Course page" not in instance_info:
instance_info.append("Course page")
elif "lessons" in endpoint:
if url_args["lesson_id"] not in lesson_ids:
lesson_ids.append(url_args["lesson_id"])
lesson_inst = Lessoninstance.query.get(
url_args["lesson_instance_id"])

if not lesson_inst:
continue

if lesson_inst.lesson_id not in lesson_ids:
lesson_ids.append(lesson_inst.lesson_id)

lesson_str = "Lesson {}".format(lesson_ids.index(
url_args["lesson_id"]) + 1)
lesson_inst.lesson_id) + 1)
if lesson_str not in instance_info:
instance_info.append(lesson_str)
url_group[url] = lesson_str
elif "assessments" in endpoint:
if url_args["assessment_id"] not in assessment_ids:
assessment_ids.append(url_args["assessment_id"])
assessment_inst = Assessmentinstance.query.get(
url_args["assessment_instance_id"])

if assessment_inst.assessment_id not in assessment_ids:
assessment_ids.append(assessment_inst.assessment_id)

assessment_str = "Assessment {}".format(assessment_ids.index(
url_args["assessment_id"]) + 1)
assessment_inst.assessment_id) + 1)

if assessment_str not in instance_info:
instance_info.append(assessment_str)


Loading…
Cancel
Save