Skip to content

Commit

Permalink
Added more to my side of the experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Mar 11, 2013
1 parent 75289ce commit 98a9355
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 14 deletions.
64 changes: 60 additions & 4 deletions app/assets/javascripts/angular/controllers/experiments.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@
// todo: populate user information

// download experiment protocol
var experiment = $routeParams.experiment == "tour" ? '/experiments/bird_tour.json' : '/experiments/rapid_scan.json';
var experiment = $routeParams.experiment == "tour" ? '/experiment_assets/bird_tour.json' : '/experiment_assets/rapid_scan.json';
$http.get(experiment).
success(function (data, status, headers, config) {
$scope.spec = data;
$scope.results.experiment = $scope.spec.experiment;

if ($routeParams.cheat) {
$scope.stage = $routeParams.cheat;
if ($scope.stage = $scope.EXPERIMENT_STAGE) {
$scope.step = 1;
}
}
}).error(function (data, status, headers, config) {
alert("downloading test specification failed");
Expand Down Expand Up @@ -88,15 +91,15 @@
return;
}

$scope.step = 0;
$scope.step = 1;
$scope.stage = $scope.EXPERIMENT_STAGE;

};

$scope.getPath = function () {
if ($scope.spec && $scope.spec.experimentSteps && $scope.spec.experimentSteps[$scope.step]) {
if ($scope.spec && $scope.spec.experimentSteps && $scope.spec.experimentSteps[$scope.step - 1]) {

return $scope.spec.experimentSteps[$scope.step].template
return $scope.spec.experimentSteps[$scope.step - 1].template
}
};

Expand Down Expand Up @@ -129,6 +132,59 @@
});
};

$scope.prettyResults = function() {
return JSON.stringify($scope.results, undefined, 2);
};


}]);


app.controller('RapidScanCtrl', ['$scope', '$resource', '$routeParams', '$route', '$http', 'Media', 'AudioEvent', 'Tag',
function RapidScanCtrl($scope, $resource, $routeParams, $route, $http, Media, AudioEvent, Tag) {
$scope.hello = "Hello world!";

$scope.bigScope = $scope.$parent;

$scope.bigScope.results.steps = angular.copy($scope.bigScope.spec.experimentSteps);

var stepResults;
$scope.$watch(function () {
return $scope.bigScope.step;
}, function (newValue, oldValue) {
stepResults = $scope.bigScope.results.steps[$scope.bigScope.step - 1];
});

$scope.startTimer = function() {
stepResults.startTime = Date.now();
};

$scope.startTimer = function() {
stepResults.endTime = Date.now();
};

$scope.SPECTROGRAM_WIDTH = 1080;
var PPS = 45;
$scope.flashes = function() {
var duration = stepResults.endTime - stepResults.startTime ;

// work out the number of flash cards that need to be shown
var adjustedPPS = PPS * stepResults.compression;
var segmentDuration = $scope.SPECTROGRAM_WIDTH / adjustedPPS;

var numberOfSegments = duration / segmentDuration;

var segments = [];
for(var i = 0; i < numberOfSegments; i++) {
var start = stepResults.endTime + (i * segmentDuration),
end = start + segmentDuration;

var imageUrl = "";

segments.push({start: start, end: end, imageLink: imageUrl});
}

return segments;
};
}]);
})();
22 changes: 14 additions & 8 deletions app/assets/templates/experiment_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,31 @@
.isa_info {
color: #00529B;
background-color: #BDE5F8;
background-image: url('/experiments/info.png');
background-image: url("/experiment_assets/info.png");
}
.isa_success {
color: #4F8A10;
background-color: #DFF2BF;
background-image:url('/experiments/success.png');
background-image:url("/experiment_assets/success.png");
}
.isa_warning {
color: #9F6000;
background-color: #FEEFB3;
background-image: url('/experiments/warning.png');
background-image: url("/experiment_assets/warning.png");
}
.isa_error {
color: #D8000C;
background-color: #FFBABA;
background-image: url('/experiments/error.png');
background-image: url("/experiment_assets/error.png");
}


.progress {
position: relative;
float: right;
top: 0;
right: 0;
margin-top: -75px;
}


</style>
Expand Down Expand Up @@ -95,7 +101,7 @@ <h3>Instructions</h3>
</div>
<div id="experimentBody" ng-show="stage == EXPERIMENT_STAGE">
<h2>Main experiment</h2>
<div>
<div class="progress">
Progress: {{step}}/{{spec.experimentSteps.length}} <meter value="{{step}}" max="{{spec.experimentSteps.length}}"></meter>
</div>
<div ng-include src="getPath()"></div>
Expand All @@ -120,7 +126,7 @@ <h2>Done!</h2>
We'd still really like your experiment data, could please email the information you see below?
<br/>
Copy this data:
<textarea readonly> {{results}} </textarea>
<textarea readonly> {{prettyResults()}} </textarea>
<p>
and send to: <a href="mailto:[email protected]">[email protected]</a>
</p>
Expand All @@ -130,7 +136,7 @@ <h2>Done!</h2>

<p>Below is a copy of the data we have saved</p>

<textarea readonly > {{results}} </textarea>
<textarea readonly > {{prettyResults()}} </textarea>

<div id="summary"></div>
</div>
Expand Down
43 changes: 42 additions & 1 deletion app/assets/templates/rapid_scanning_experiment.html
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
<h1>BLA BLAH BLAH</h1>
<div ng-controller="RapidScanCtrl">

<style type="text/css">
.experimentContainer {
width: 100%;
text-align: center;
}

</style>

<div class="experimentContainer">

<div id="translateTest" ng-show="bigScope.step == 1">
<div id="instructions" >
<div>
<img src="/experiment_assets/Instructions.jpg">
</div>
</div>
<div>
<ul>
<li ng-repeat="segment in flashes()">
<p>
{{segment.start}}, {{segment.end}}
</p>
<img src="http://sail.usc.edu/Peter/mystery/mystery.jpg"></li>
</ul>
</div>
</div>

<!--<div id="flashTest" ng-show="bigScope.step == 2">-->
<!--<div id="instructions2" >-->
<!--<div>-->
<!--<img src="/experiment_assets/Instructions.jpg">-->
<!--</div>-->
<!--</div>-->
<!--<div>-->
<!--<img src="http://sail.usc.edu/Peter/mystery/mystery.jpg">-->
<!--</div>-->

<!--</div>-->
</div>
</div>
1 change: 1 addition & 0 deletions app/controllers/experiments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'FileUtils'
require 'modules/JSON_patch'

class ExperimentsController < ApplicationController

Expand Down
2 changes: 1 addition & 1 deletion public/ParticipantInformation.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ <h3>
All comments, responses, and personally identifiable user contributed data will
be treated confidentially. The actions that you perform to complete tasks on the
website may be monitored, such as the buttons you click and the identifier of the
recorded audio that is loaded. This monitoring will not include any personally identifiable
recorded audio that is loaded. This monitoring may include any personally identifiable
information. The monitoring is only for evaluating and improving the website, and
will only be available to the research team.
</p>
Expand Down
Binary file added public/experiment_assets/Instructions.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions public/experiment_assets/bird_tour.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"experiment": "Virtual bird tour",
"instructions": [
"This is a timed expersssssssssssssiment. You are encouraged to balance accurate work with finishing quickly.",
"This experiment is dessaaaaaaaaaaaasigned to measure how quickly acoustic events of interest can be detected",
"There are 3 parts asssssssssssof this experiment to complete",
"In total the expaaaaaaaaaaaaaaaaeriment should take no longer than 30 minutes",
"You may use externaaaaaaaaaaaaaaaal resources to assist you. We recommend preparing them before the experiment."
],
"experimentSteps": [
{
"template": "/assets/tour_experiment.html"
},
{
"template": "/assets/tour_experiment.html"
},
{
"template": "/assets/tour_experiment.html"
}
],
"experimentResultsPostUri": "/experiments"
}
Binary file added public/experiment_assets/error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/experiment_assets/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions public/experiment_assets/rapid_scan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"experiment": "Rapid Spectrogram Scanning",
"instructions": [
"This is a timed experiment. You are encouraged to balance accurate work with finishing quickly.",
"This experiment is designed to measure how quickly acoustic events of interest can be detected",
"There are 3 parts of this experiment to complete",
"In total the experiment should take no longer than 30 minutes",
"You may use external resources to assist you. We recommend preparing them before the experiment."
],
"experimentSteps": [
{
"template": "/assets/rapid_scanning_experiment.html",
"name": "ff-koala",
"type": "fast-forward",
"audioId": "some-guid",
"startTime": 1800,
"endTime": 2400,
"compression": 1
},
{
"template": "/assets/rapid_scanning_experiment.html",
"name": "flashing-koala",
"type": "flashing",
"startTime": 1800,
"endTime": 2400,
"compression": 1
},
{
"template": "/assets/rapid_scanning_experiment.html",
"name": "ff-night",
"type": "fast-forward",
"audioId": "some-guid",
"startTime": 1800,
"endTime": 2400,
"compression": 1
},
{
"template": "/assets/rapid_scanning_experiment.html",
"name": "flashing-night",
"type": "flashing",
"startTime": 1800,
"endTime": 2400,
"compression": 1
}
],
"experimentResultsPostUri": "/experiments"
}
Binary file added public/experiment_assets/success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/experiment_assets/warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 98a9355

Please sign in to comment.