Skip to content

Commit

Permalink
USU: Added Configurable group id prepend string
Browse files Browse the repository at this point in the history
  • Loading branch information
scody committed Aug 12, 2016
1 parent bac53d5 commit bf44af6
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import od.providers.config.TranslatableKeyValueConfigurationOptions;
import od.providers.events.EventProvider;
import od.repository.mongo.MongoTenantRepository;
import od.utils.LRS_Options;
import od.utils.LoggingRequestInterceptor;

import org.apache.commons.lang.StringUtils;
import org.apereo.lai.Event;
import org.apereo.lai.impl.EventImpl;
import org.apereo.openlrs.model.event.v2.EventStats;
Expand All @@ -33,6 +35,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
Expand All @@ -58,6 +64,9 @@
*
*/
@Component("events_openlrs")
@Configuration
@EnableConfigurationProperties
@ConfigurationProperties(prefix="lrs_options")
public class OpenLRSEventProvider extends BaseProvider implements EventProvider {

private static final Logger log = LoggerFactory.getLogger(OpenLRSEventProvider.class);
Expand All @@ -67,6 +76,12 @@ public class OpenLRSEventProvider extends BaseProvider implements EventProvider
private static final String NAME = String.format("%s_NAME", BASE);
private static final String DESC = String.format("%s_DESC", BASE);

@Autowired
private LRS_Options lrs_Options;

//@Value("${optional}")
//private String emptyValue;

@Autowired private MongoTenantRepository mongoTenantRepository;
private ProviderConfiguration providerConfiguration;

Expand Down Expand Up @@ -216,8 +231,13 @@ public JsonNode postEvent(JsonNode marshallableObject, ProviderOptions options)

@Override
public EventStats getEventStatsForCourse(ProviderOptions options) {

RestTemplate restTemplate = new RestTemplate();


String fullCourseId = options.getCourseId();
if (StringUtils.isNotEmpty(lrs_Options.getGroup_id_prependString())) {
fullCourseId = lrs_Options.getGroup_id_prependString() + fullCourseId;
}

//set interceptors/requestFactory
ClientHttpRequestInterceptor ri = new LoggingRequestInterceptor();
Expand All @@ -241,7 +261,7 @@ public EventStats getEventStatsForCourse(ProviderOptions options) {
HttpHeaders headers = createHeadersWithBasicAuth(providerData.findValueForKey("key"), providerData.findValueForKey("secret"));

UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(caliperUrl)
.queryParam("groupId", "http://localhost:8080/portal/site/de5db688-b7ec-449a-94d3-deb9af208f2b");
.queryParam("groupId", fullCourseId);

HttpEntity<?> entity = new HttpEntity<>(headers);

Expand Down
26 changes: 26 additions & 0 deletions src/main/java/od/utils/LRS_Options.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package od.utils;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.ConfigFileApplicationContextInitializer;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;

@Configuration
@EnableConfigurationProperties
@ConfigurationProperties(prefix="lrs_options")
//@PropertySource(value = "classpath:application.yml")
@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class)
public class LRS_Options {

private String group_id_prependString;

public String getGroup_id_prependString() {
return group_id_prependString;
}

public void setGroup_id_prependString(String group_id_prependString) {
this.group_id_prependString = group_id_prependString;
}

}
52 changes: 52 additions & 0 deletions src/main/java/org/apereo/openlrs/model/event/v2/EventStats.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
*
*/
package org.apereo.openlrs.model.event.v2;

import java.io.Serializable;
import java.util.Map;


/**
* @author ggilbert
*
*/
public class EventStats implements Serializable {
private static final long serialVersionUID = 1L;
private long total;
private long max;
private Map<String,Long> totalByWeekNumber;
private Map<String, StudentEventStats> studentEventStats;

public long getTotal() {
return total;
}

public void setTotal(long total) {
this.total = total;
}

public Map<String, Long> getTotalByWeekNumber() {
return totalByWeekNumber;
}

public void setTotalByWeekNumber(Map<String, Long> totalByWeekNumber) {
this.totalByWeekNumber = totalByWeekNumber;
}

public Map<String, StudentEventStats> getStudentActivityStats() {
return studentEventStats;
}

public void setStudentActivityStats(Map<String, StudentEventStats> studentEventStats) {
this.studentEventStats = studentEventStats;
}

public void setMax(Long maxValue) {
this.max = maxValue;
}

public Long getMax() {
return this.max;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.apereo.openlrs.model.event.v2;

import java.io.Serializable;
import java.util.Map;

public class StudentEventStats implements Serializable{
private static final long serialVersionUID = 1L;
private long total;
private Map<String,Long> totalByWeekNumber;
private String studentId;
private String studentName;

public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
public Map<String, Long> getTotalByWeekNumber() {
return totalByWeekNumber;
}
public void setTotalByWeekNumber(Map<String, Long> totalByWeekNumber) {
this.totalByWeekNumber = totalByWeekNumber;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getStudentName() {
return studentName;
}
public void setStudentName(String studentName) {
this.studentName = studentName;
}
}
8 changes: 7 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ spring:
data:
mongodb:
uri: mongodb://localhost/od



lrs_options:
## Prepend string for the Group Id... likely it's the Server URL configured for Sakai
group_id_prependString: http://localhost:8080/portal/site/


40 changes: 25 additions & 15 deletions src/main/resources/public/cards/sakai/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ angular
};


$scope.chooseGraph = function() {
if ($scope.currentGraph == 'messageView') {
$scope.chooseGraph = function(view) {

$scope.viewType=view;
if (view == 'Message View') {
$scope.messageViewGraph();
}
if ($scope.currentGraph == 'studentView') {
if (view == 'Student View') {
$scope.studentViewGraph();
}

}
//test
//show Messages View
Expand Down Expand Up @@ -153,7 +156,7 @@ angular
// create a network
var container = document.getElementById('mynetwork');
var options = {};
var network = new vis.Network(container, data, options);
var network = new vis.Network(container, $scope.graphData, options);
$scope.network = network;
};

Expand All @@ -165,7 +168,7 @@ angular
var data = {};
data.id = value[0].person_sourcedid;
data.value = value.forumData.length;
data.label = value[0].person.name_full;
data.label = value[0].person.name_full + ' (' + value.forumData.length + ')';
data.color = value.color;
data.title = value.forumData.length + " forum contributions";

Expand Down Expand Up @@ -231,6 +234,7 @@ angular

$scope.showLineGraphGroup = function(userId, userName, color) {


$scope.activityGraphGroups = new vis.DataSet();
$scope.activityGraphDataset = new vis.DataSet();
$scope.activityGraphOptions = {
Expand All @@ -249,6 +253,18 @@ angular
id: 'average',
content: 'course activity average',
});

// add average items
var numStudents = Object.keys($scope.data).length;
Object.keys($scope.activityData.totalByWeekNumber).forEach(function (key) {
$scope.activityGraphDataset.add( [
{x: "week of: " + key, y: $scope.activityData.totalByWeekNumber[key]/numStudents, group: 'average'}
]);
});



if(userId!=null) {

var fullUserId = 'mailto:' + userId + '@tincanapi.dev.sakaiproject.org';

Expand All @@ -260,13 +276,7 @@ angular
});
}

// add average items
var numStudents = Object.keys($scope.data).length;
Object.keys($scope.activityData.totalByWeekNumber).forEach(function (key) {
$scope.activityGraphDataset.add( [
{x: "week of: " + key, y: $scope.activityData.totalByWeekNumber[key]/numStudents, group: 'average'}
]);
});




Expand All @@ -290,7 +300,7 @@ angular
}
});


}


var newOptions = {
Expand Down Expand Up @@ -360,10 +370,10 @@ angular

//Create the Student View of the Forum Data
$scope.studentViewGraph();


// activity
$scope.activityData = responses[2];
$scope.activityData = responses[2];
$scope.showLineGraphGroup();
// end activity
});

Expand Down
18 changes: 16 additions & 2 deletions src/main/resources/public/cards/sakai/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,25 @@ <h5 translate="ERROR_CODE" translate-values="{{errorData}}"></h5>

<div class="navbar-collapse collapse od-subheader-background-color m-b m-t">
<div class="nav navbar-nav"><p class="navbar-text"><strong >FORUM ACTIVITY</strong></p></div>
<div align="right"> <select class="navbar-text" name="singleSelect" ng-model="currentGraph" ng-change="chooseGraph()">

<div class="navbar-collapse collapse nav navbar-nav navbar-right">
<ul ng-show="contextMapping && contextMapping.dashboards" class="nav navbar-nav navbar-left">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{viewType}}<span class="caret"></span></a>
<ul class="dropdown-menu" ng-model="currentGraph"><a ui-sref="index.dashboard({cmid:contextMapping.id,dbid:dashboard.id})" id="LINK_INDEX_DASHBOARD_SELECT">
<li ng-click="chooseGraph('Message View')"><a>&nbsp;&nbsp;Message View</a></li>
<li ng-click="chooseGraph('Student View')"><a>&nbsp;&nbsp;Student View</a></li>
</ul>

</li>
</ul>
</div>

<!-- div align="right"> <select class="navbar-text" name="singleSelect" ng-model="currentGraph" ng-change="chooseGraph()">
<option value="messageView">Messages View</option>
<option value="studentView">Students View</option>
</select>
</div>
</div -->
</div>

<div class="box-shadow--6dp od-background-color-white" style="height: 400px;">
Expand Down

0 comments on commit bf44af6

Please sign in to comment.