Skip to content

Commit

Permalink
Started layout for experiment pages.
Browse files Browse the repository at this point in the history
Also fixed up the seeds, wrote some tests, and updated angular-ui

new file:   app/assets/javascripts/angular/controllers/experiments.js
modified:   app/assets/javascripts/angular/controllers/listen.js
modified:   app/assets/javascripts/app.js
modified:   app/assets/templates/home.html
new file:   app/assets/templates/rapid_scanning_experiment.html
new file:   app/assets/templates/tour_experiment.html
modified:   app/controllers/media_controller.rb
modified:   app/models/tag.rb
modified:   db/development_seeds.rb
new file:   public/experiments/rapid_scan.json
modified:   spec/models/tag_spec.rb
modified:   vendor/assets/javascripts/angular-ui-ieshiv.js
modified:   vendor/assets/javascripts/angular-ui.js
  • Loading branch information
atruskie committed Mar 7, 2013
1 parent 257fabe commit eeb77cb
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 8 deletions.
41 changes: 41 additions & 0 deletions app/assets/javascripts/angular/controllers/experiments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use strict";

;
(function (undefined) {
var app = angular.module('bawApp.controllers');

app.controller('ExperimentsCtrl', ['$scope', '$resource', '$routeParams', '$route', '$http', 'Media', 'AudioEvent', 'Tag',

/**
* The listen controller.
* @param $scope
* @param $resource
* @param $routeParams
* @param AudioEvent
* @constructor
* @param Tag
* @param Media
* @param $route
* @param $http
*/
function ExperimentsCtrl($scope, $resource, $routeParams, $route, $http, Media, AudioEvent, Tag) {

$scope.results = {};

// todo: populate user information

// download experiment protocol
$http.get('/experiments/rapid_scan.json').
success(function(data, status, headers, config) {
$scope.spec = data;
}).error(function( data, status, headers, config) {
alert("downloading test specification failed");
});


function downloadResults() {

}

}]);
})();
2 changes: 1 addition & 1 deletion app/assets/javascripts/angular/controllers/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@

$scope.select2Settings = {
allowClear: true,
tags: $scope.tags,
tags: $scope.tags
// id: function selectTagId(tag) {
// return tag.tagId;
// },
Expand Down
4 changes: 4 additions & 0 deletions app/assets/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ var bawApp = (function (undefined) {

when('/attribution', {templateUrl: '/assets/attributions.html'}).

// experiments
when('/experiments/tour', {templateUrl: '/assets/tour_experiment.html', controller: 'ExperimentsCtrl'}).
when('/experiments/rapidScan', {templateUrl: '/assets/rapid_scanning_experiment.html', controller: 'ExperimentsCtrl'}).

// missing route page
when('/', {templateUrl: '/assets/home.html', controller: 'HomeCtrl'}).
when('/404', {templateUrl: '/assets/error_404.html', controller: 'ErrorCtrl'}).
Expand Down
10 changes: 10 additions & 0 deletions app/assets/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ <h3>Audio Recordings and Annotations</h3>
<a href="/listen/1bd0d668-1471-4396-adc3-09ccd8fe949a">Listen2</a>
</p>

<h3>Experiments</h3>

<p>
<a href="/experiments/tour">Virtual birding tour</a>

<a href="/experiments/rapidScan">Rapid scanning</a>

</p>


<h3>Download annotations</h3>

<p>
Expand Down
46 changes: 46 additions & 0 deletions app/assets/templates/rapid_scanning_experiment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<div id="content" ng-controller="ExperimentsCtrl">
<h1>Experiment</h1>
<div id="experimentPreface">
<h2>Welcome</h2>
<p>
<a href="" style="">Ethics statement</a>
</p>
<h3>Instructions</h3>
<ul>
<li ng-repeat="step in spec.instructions">{{step}}</li>
<li>
Ensure you read the experiment <a href="http://www.google.com" ng-click="results.ethicsStatementViewed = true" target="_blank" style="">ethics statement</a>. You will need to click the link.
<br/>
<label>
<input type="checkbox" ng-checked="results.ethicsStatementViewed" disabled/>
I have visited the ethics page
</label>
<br/>
<label>
<input type="checkbox"/>
I consent to participating in this experiment and I understand I can leave at any time without penalty
</label>
<br/>
<label>
<input type="checkbox"/>
I do not wish to be contacted for follow up questions
</label>
</li>
</ul>
</div>
<div id="experimentBody">
<h2>Main experiment</h2>
<progress value="0" max="{{spec.experimentSteps.length}}" ></progress>
<ol id="experimentSteps">
<li ng-repeat="step in spec.experimentSteps"></li>
</ol>
</div>
<div id="experimentConclusion" style="">
<h2>Done!</h2>
<p>Thank you very much for participating.</p>
<p> If you choose you can download a copy of all the information we recorded during this experiment <a ng-click="downloadResults">here</a>.</p>
<p>Below is a summary of your results</p>
<div id="summary"></div>
</div>

</div>
Empty file.
2 changes: 1 addition & 1 deletion app/controllers/media_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def item
# if the format is a supported image format, locate a cached spectrogram or generate it, then stream it back.
#if image_media_types.include? final_format_requested

recording = AudioRecording.find_by_uuid(@file_info[:id])
recording = AudioRecording.find_by_uuid!(@file_info[:id])
@file_info[:date] = recording.recorded_date.strftime "%Y%m%d"
@file_info[:time] = recording.recorded_date.strftime "%H%M%S"
@file_info[:original_format] = Mime::Type.file_extension_of recording.media_type
Expand Down
1 change: 1 addition & 0 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ def type_of_tag=(new_type_of_tag)
after_initialize :init
def init
self.is_taxanomic ||= false
self.retired ||= false
end
end
13 changes: 13 additions & 0 deletions public/experiments/rapid_scan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"experiment": "Rapid Spectrogtam Scanning",
"instructions": [
"Step 1",
"Step 2"
],
"experimentSteps": [
{},
{},
{}
],
"experimentResultsPostUri": "/experiments"
}
2 changes: 1 addition & 1 deletion vendor/assets/javascripts/angular-ui-ieshiv.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* AngularUI - The companion suite for AngularJS
* @version v0.3.2 - 2013-02-12
* @version v0.4.0 - 2013-02-17
* @link http://angular-ui.github.com
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand Down
16 changes: 11 additions & 5 deletions vendor/assets/javascripts/angular-ui.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* AngularUI - The companion suite for AngularJS
* @version v0.3.2 - 2013-02-12
* @version v0.4.0 - 2013-02-17
* @link http://angular-ui.github.com
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand Down Expand Up @@ -70,6 +70,7 @@ angular.module('ui.directives').directive('uiCalendar',['ui.config', '$parse', f
var tracker = 0;
/* returns the length of all source arrays plus the length of eventSource itself */
var getSources = function () {
var equalsTracker = scope.$eval(attrs.equalsTracker);
tracker = 0;
angular.forEach(sources,function(value,key){
if(angular.isArray(value)){
Expand Down Expand Up @@ -951,6 +952,8 @@ angular.module('ui.directives').directive('uiSelect2', ['ui.config', '$timeout',
} else {
if (angular.isObject(controller.$viewValue)) {
elm.select2('data', controller.$viewValue);
} else if (!controller.$viewValue) {
elm.select2('data', null);
} else {
elm.select2('val', controller.$viewValue);
}
Expand Down Expand Up @@ -1002,17 +1005,20 @@ angular.module('ui.directives').directive('uiSelect2', ['ui.config', '$timeout',
}

// Set initial value since Angular doesn't
//elm.val(null);//scope.$eval(attrs.ngModel));
//elm.val(scope.$eval(attrs.ngModel));

// Initialize the plugin late so that the injected DOM does not disrupt the template compiler
$timeout(function () {
elm.select2(opts);

// Set initial value - I'm not sure about this but it seems to need to be there
elm.val(controller.$viewValue);
controller.$render();

// Not sure if I should just check for !isSelect OR if I should check for 'tags' key
if (!opts.initSelection && !isSelect)
elm.select2('data', controller.$viewValue);
controller.$setViewValue(elm.select2('data'));

//controller.$render();
controller.$setViewValue(elm.select2('data'));
});
};
}
Expand Down

0 comments on commit eeb77cb

Please sign in to comment.