comparison ape.js @ 1561:bd06a7dc0418

Feature #1271 and #1272 implemented.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 17 Jun 2015 16:37:32 +0100
parents c7c95761323d
children 6922eac3b945
comparison
equal deleted inserted replaced
1560:950f14a6506e 1561:bd06a7dc0418
80 alert('You have not played fragment ' + hasBeenPlayed[0] + ' yet. Please listen, rate and comment all samples before submitting.'); 80 alert('You have not played fragment ' + hasBeenPlayed[0] + ' yet. Please listen, rate and comment all samples before submitting.');
81 } 81 }
82 return false; 82 return false;
83 } 83 }
84 return true; 84 return true;
85 } 85 };
86 86
87 Interface.prototype.checkAllMoved = function() { 87 Interface.prototype.checkAllMoved = function() {
88 var audioObjs = audioEngineContext.audioObjects; 88 var audioObjs = audioEngineContext.audioObjects;
89 var state = true; 89 var state = true;
90 var strNums = []; 90 var strNums = [];
110 } else { 110 } else {
111 alert('You have not moved fragment ' + strNums[0] + ' yet. Please listen, rate and comment all samples before submitting.'); 111 alert('You have not moved fragment ' + strNums[0] + ' yet. Please listen, rate and comment all samples before submitting.');
112 } 112 }
113 } 113 }
114 return state; 114 return state;
115 } 115 };
116 116
117 Interface.prototype.checkAllCommented = function() { 117 Interface.prototype.checkAllCommented = function() {
118 var audioObjs = audioEngineContext.audioObjects; 118 var audioObjs = audioEngineContext.audioObjects;
119 var audioHolder = testState.stateMap[testState.stateIndex]; 119 var audioHolder = testState.stateMap[testState.stateIndex];
120 var state = true; 120 var state = true;
143 alert('You have not commented on fragment ' + strNums[0] + ' yet. Please listen, rate and comment all samples before submitting.'); 143 alert('You have not commented on fragment ' + strNums[0] + ' yet. Please listen, rate and comment all samples before submitting.');
144 } 144 }
145 } 145 }
146 } 146 }
147 return state; 147 return state;
148 } 148 };
149 149
150 // Bindings for audioObjects 150 // Bindings for audioObjects
151 151
152 // Create the top div for the Title element 152 // Create the top div for the Title element
153 var titleAttr = specification.title; 153 var titleAttr = specification.title;
408 $('.comment-div').removeClass('comment-box-playing'); 408 $('.comment-div').removeClass('comment-box-playing');
409 $('#comment-div-'+id).addClass('comment-box-playing'); 409 $('#comment-div-'+id).addClass('comment-box-playing');
410 } 410 }
411 }; 411 };
412 412
413 this.exportXMLDOM = function() { 413 this.exportXMLDOM = function(audioObject) {
414 // Called by the audioObject holding this element. Must be present 414 // Called by the audioObject holding this element. Must be present
415 var node = document.createElement('value'); 415 var node = document.createElement('value');
416 node.textContent = convSliderPosToRate(this.trackSliderObj); 416 node.textContent = convSliderPosToRate(this.trackSliderObj);
417 return node; 417 return node;
418 }; 418 };
419 this.getValue = function() {
420 return convSliderPosToRate(this.trackSliderObj);
421 }
419 } 422 }
420 423
421 function dragEnd(ev) { 424 function dragEnd(ev) {
422 // Function call when a div has been dropped 425 // Function call when a div has been dropped
423 var slider = document.getElementById('slider'); 426 var slider = document.getElementById('slider');
441 444
442 function buttonSubmitClick() // TODO: Only when all songs have been played! 445 function buttonSubmitClick() // TODO: Only when all songs have been played!
443 { 446 {
444 var checks = specification.commonInterface.options; 447 var checks = specification.commonInterface.options;
445 var canContinue = true; 448 var canContinue = true;
449
450 // Check that the anchor and reference objects are correctly placed
451 var audioObjs = audioEngineContext.audioObjects;
452 var audioHolder = testState.stateMap[testState.stateIndex];
453 var anchorId = null;
454 var referenceId = null;
455 for (var i=0; i<audioObjs.length; i++) {
456 if (audioObjs[i].specification.anchor == true && anchorId == null) {anchorId = i;}
457 if (audioObjs[i].specification.reference == true && referenceId == null) {referenceId = i;}
458 }
459 if (anchorId != null) {
460 if (audioObjs[anchorId].specification.marker != null) {
461 if (audioObjs[anchorId].interfaceDOM.getValue() > audioObjs[anchorId].specification.marker)
462 {
463 // Anchor is not set below
464 console.log('Anchor node not below marker value');
465 alert('Please keep listening');
466 return;
467 }
468 } else {
469 // No marker value given, ensure it is the minimum value
470 var anchorVal = audioObjs[anchorId].interfaceDOM.getValue();
471 for (var i=0; i<audioObjs.length; i++) {
472 if (i != anchorId) {
473 if (anchorVal > audioObjs[i].interfaceDOM.getValue()) {
474 // Anchor not the minimum
475 console.log('No marker set, anchor node not the minimum');
476 alert('Please keep listening');
477 return;
478 }
479 }
480 }
481 }
482 }
483 if (referenceId != null) {
484 if (audioObjs[referenceId].specification.marker != null) {
485 if (audioObjs[referenceId].interfaceDOM.getValue() < audioObjs[referenceId].specification.marker)
486 {
487 // Anchor is not set below
488 console.log('Reference node not above marker value');
489 alert('Please keep listening');
490 return;
491 }
492 } else {
493 // No marker value given, ensure it is the minimum value
494 var referenceVal = audioObjs[referenceId].interfaceDOM.getValue();
495 for (var i=0; i<audioObjs.length; i++) {
496 if (i != referenceId) {
497 if (referenceVal > audioObjs[i].interfaceDOM.getValue()) {
498 // Anchor not the minimum
499 console.log('No marker set, reference node not the maximum');
500 alert('Please keep listening');
501 return;
502 }
503 }
504 }
505 }
506 }
507
446 for (var i=0; i<checks.length; i++) { 508 for (var i=0; i<checks.length; i++) {
447 if (checks[i].type == 'check') 509 if (checks[i].type == 'check')
448 { 510 {
449 switch(checks[i].check) { 511 switch(checks[i].check) {
450 case 'fragmentPlayed': 512 case 'fragmentPlayed':