Hello everyone,

Whenever I open a Learners Engagement page for any particular course in 
Insights(*hawthorn.master*), it internally calls analytics-data-api 
endpoint at */api/v0/course_learner_metadata/{course_id}* and endpoint 
returns JSON response containing a “date_range” under a 
“engagement_ranges”. (*Note:* I checked edx-analytics-api documentation (
https://edx.readthedocs.io/projects/edx-data-analytics-api/en/latest/) but, 
I didn’t found API reference for same.)


So, If any learner engagement found during a week for a particular course, 
it gives date_range object with a valid date as follows:
“engagement_ranges”: {
  “date_range”: {
    “start”: “2019-07-24”,
    “end”: “2019-07-31”
  },
  …
}


But if there is no learners activity/engagement found during a week for any 
particular course, it gives date_range objects with start_date and end_date 
as a null value.
“engagement_ranges”: {
  “date_range”: {
    “start”: null,
    “end”: null
  },
  …
}


Above response is parsed by backbone js located at 
*edx-analytics-dashboard/analytics_dashboard/static/apps/learners/roster/views/activity-date-range.js*
 and 
if date_range has a *start* and *end* in response then data is parsed using 
Utils.formatDate() so if the date is null it gives invalid date as a 
response and final string is “*Activity between Invalid date - Invalid date*
”.


[image: No%20Records%20Found]
No Records Found.png1373×542 25.6 KB
<https://aws1.discourse-cdn.com/business7/uploads/openedx/original/1X/84ecd7d001fd662293e82c09e6952474694b8e28.png>


There should be a condition like, if “start” and “end” is available in 
“date_range” dict and they have a valid date, then it should proceed to 
parse, else it executes else condition from ternary expression and returns 
“n/a” so final string should be “*Activity between n/a - n/a*” as per 
backbone test cases.


Current Codebase:
return {
    startDate: _(dateRange).has(‘start’) ? 
Utils.formatDate(dateRange.start) : naText,
    endDate: _(dateRange).has(‘end’) ? Utils.formatDate(dateRange.end) : 
naText
};


It should be as following:
return {
    startDate: _(dateRange).has(‘start’) and ! _.isNull(dateRange[‘start’]) 
? Utils.formatDate(dateRange.start) : naText,
    endDate: _(dateRange).has(‘end’) and ! _.isNull(dateRange[‘end’]) ? 
Utils.formatDate(dateRange.end) : naText
};

Please help me with this ASAP.

-- 
***Please note! This Google Group has been deprecated - visit 
https://discuss.openedx.org/
--- 
You received this message because you are subscribed to the Google Groups 
"General Open edX discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to edx-code+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/edx-code/b3ec7b05-151f-4ebb-95d1-dcf424a0945c%40googlegroups.com.

Reply via email to