Skip to content

Commit

Permalink
Fix dashboard code on develop (allow for empty alternative urls for
Browse files Browse the repository at this point in the history
installation)
  • Loading branch information
torinfo committed Feb 8, 2019
1 parent 1e7d75f commit 35275b1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
4 changes: 3 additions & 1 deletion website_code/scripts/template_management.js
Expand Up @@ -702,7 +702,9 @@ function getProjectInformation_stateChanged() {
url = site_url + info.template_id;
q = {};

q['activities'] = [url].concat(info.lrs.lrsurls.split(",")).concat(info.lrs.site_allowed_urls.split(",").map(url => url + info.template_id)).filter(url => url != "");
if (info.lrs.site_allowed_urls != null && info.lrs.site_allowed_urls != undefined && info.lrs.site_allowed_urls != "") {
q['activities'] = [url].concat(info.lrs.lrsurls.split(",")).concat(info.lrs.site_allowed_urls.split(",").map(url => url + info.template_id)).filter(url => url != "");
}
q['activity'] = url;

q['verb'] = "http://adlnet.gov/expapi/verbs/launched";
Expand Down
9 changes: 6 additions & 3 deletions website_code/scripts/xapi_dashboard.js
Expand Up @@ -1400,16 +1400,19 @@ xAPIDashboard.prototype.helperGetDate = function(datetimepicker) {
return mTime;
};

xAPIDashboard.prototype.regenerate_dashboard = function()
{
xAPIDashboard.prototype.regenerate_dashboard = function() {
$("#journeyData").html("<img class='loading-gif' src='editor/img/loading16.gif'/>");
$("#group-select option:not(:first-child)").remove();
var url = site_url + this.data.info.template_id;
var start = this.helperGetDate('#dp-start');
var end = this.helperGetDate('#dp-end');
end = new Date(moment(end).add(1, 'days').toISOString());
var q = {};
q['activities'] = [url].concat(this.data.info.lrs.lrsurls.split(",")).concat(this.data.info.lrs.site_allowed_urls.split(",").map(url => url + this.data.info.template_id)).filter(url => url != "");
if (this.data.info.lrs.lrsurls != null && this.data.info.lrs.lrsurls != "undefined" && this.data.info.lrs.lrsurls != ""
&& this.data.info.lrs.site_allowed_urls != null && this.data.info.lrs.site_allowed_urls != "undefined" && this.data.info.lrs.site_allowed_urls != "")
{
q['activities'] = [url].concat(this.data.info.lrs.lrsurls.split(",")).concat(this.data.info.lrs.site_allowed_urls.split(",").map(url => url + this.data.info.template_id)).filter(url => url != "");
}
q['activity'] = url;
q['related_activities'] = true;
q['since'] = start.toISOString();
Expand Down
10 changes: 7 additions & 3 deletions website_code/scripts/xapi_dashboard_data.js
Expand Up @@ -137,12 +137,16 @@ DashboardState.prototype.getStatements = function(query, handler) {

DashboardState.prototype.combineUrls = function()
{
var urls = [site_url + this.info.template_id].concat(this.info.lrs.lrsurls.split(",")).concat(this.info.lrs.site_allowed_urls.split(",").map(url => url + this.info.template_id)).filter(url => url != "");
urls.push(site_url + this.info.template_id)
var url = site_url + this.info.template_id;
var urls = [url];
if (this.info.lrs.lrsurls != null && this.info.lrs.lrsurls != "undefined" && this.info.lrs.lrsurls != ""
&& this.info.lrs.site_allowed_urls != null && this.info.lrs.site_allowed_urls != "undefined" && this.info.lrs.site_allowed_urls != "") {
urls = [url].concat(this.info.lrs.lrsurls.split(",")).concat(this.info.lrs.site_allowed_urls.split(",").map(url => url + this.info.template_id)).filter(url => url != "");
}
var mapping = function(url)
{
return url;
}
};
if(urls.length > 1)
{
mapping = function(url)
Expand Down
10 changes: 9 additions & 1 deletion xapi_proxy.php
Expand Up @@ -364,7 +364,15 @@ function convertToCurl($headers)
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $lrs_key . ':' . $lrs_secret);

list($header, $contents) = preg_split('/([\r\n][\r\n])\\1/', curl_exec($ch), 2);
// Disable SSL peer verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($ch);
if ($response === false)
{
_debug("Error: ", curl_error($ch));
}
list($header, $contents) = preg_split('/([\r\n][\r\n])\\1/', $response, 2);

$status = curl_getinfo($ch);
$info = curl_getinfo($ch, CURLINFO_HEADER_OUT);
Expand Down

0 comments on commit 35275b1

Please sign in to comment.