comparison analysis/analysis.js @ 1285:ae57d9f618cb

Analysis: Get filtered score values. Download filtered data.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 31 Mar 2016 14:24:52 +0100
parents 6c819878ac85
children d219aa5329aa
comparison
equal deleted inserted replaced
1284:6c819878ac85 1285:ae57d9f618cb
587 var self = this; 587 var self = this;
588 // Collect the test types and counts 588 // Collect the test types and counts
589 this.testSavedDiv = document.getElementById("test-saved"); 589 this.testSavedDiv = document.getElementById("test-saved");
590 this.testSaves = null; 590 this.testSaves = null;
591 this.selectURL = null; 591 this.selectURL = null;
592 592
593 this.specification = new Specification(); 593 this.specification = new Specification();
594 get("../test-schema.xsd").then(function(response){ 594 get("../test-schema.xsd").then(function(response){
595 var parse = new DOMParser(); 595 var parse = new DOMParser();
596 self.specification.schema = parse.parseFromString(response,'text/xml'); 596 self.specification.schema = parse.parseFromString(response,'text/xml');
597 },function(error){ 597 },function(error){
643 // Changed the test specification 643 // Changed the test specification
644 this.selectURL = event.currentTarget.getAttribute("source"); 644 this.selectURL = event.currentTarget.getAttribute("source");
645 this.update(this.selectURL); 645 this.update(this.selectURL);
646 } 646 }
647 } 647 }
648
649 this.updateData = function(req_str) {
650 // Now go get that data
651 get(req_str).then(function(response){
652 // Returns the data
653 chartContext.valueData = JSON.parse(response);
654 },function(error){console.error(error);});
655 }
648 } 656 }
649 657
650 var interfaceContext = new function() { 658 var interfaceContext = new function() {
651 // This creates the interface for the user to connect with the dynamic back-end to retrieve data 659 // This creates the interface for the user to connect with the dynamic back-end to retrieve data
652 this.rootDOM = document.createElement("div"); 660 this.rootDOM = document.createElement("div");
661 this.getDataButton = {
662 button: document.createElement("button"),
663 parent: this,
664 handleEvent: function(event) {
665 // Get the list of files:
666 var req_str = "../scripts/get_filtered_score.php"+this.parent.getFilterString();
667 testData.updateData(req_str);
668 }
669 }
670 this.getDataButton.button.textContent = "Get Filtered Data";
671 this.getDataButton.button.addEventListener("click",this.getDataButton);
672
653 this.filterDOM = document.createElement("div"); 673 this.filterDOM = document.createElement("div");
654 this.filterDOM.innerHTML = "<p>PreTest Filters</p><div id='filter-count'></div>"; 674 this.filterDOM.innerHTML = "<p>PreTest Filters</p><div id='filter-count'></div>";
655 this.filterObjects = []; 675 this.filterObjects = [];
656 this.generateFilters = function(specification) { 676 this.generateFilters = function(specification) {
657 // Filters are based on the pre and post global surverys 677 // Filters are based on the pre and post global surverys
771 default: 791 default:
772 break; 792 break;
773 } 793 }
774 } 794 }
775 document.getElementById("test-saved").appendChild(this.filterDOM); 795 document.getElementById("test-saved").appendChild(this.filterDOM);
776 } 796 document.getElementById("test-saved").appendChild(this.getDataButton.button);
777 this.getFileCount = function() { 797 }
778 // First we must get the filter pairs 798 this.getFilterString = function() {
779 var pairs = []; 799 var pairs = [];
780 for (var obj of this.filterObjects) { 800 for (var obj of this.filterObjects) {
781 pairs = pairs.concat(obj.getFilterPairs()); 801 pairs = pairs.concat(obj.getFilterPairs());
782 } 802 }
783 var req_str = "../scripts/get_filtered_count.php?url="+testData.selectURL; 803 var req_str = "?url="+testData.selectURL;
784 var index = 0; 804 var index = 0;
785 while(pairs[index] != undefined) { 805 while(pairs[index] != undefined) {
786 req_str += '&'; 806 req_str += '&';
787 req_str += pairs[index][0]+"="+pairs[index][1]; 807 req_str += pairs[index][0]+"="+pairs[index][1];
788 index++; 808 index++;
789 } 809 }
790 get(req_str).then(function(response){ 810 return req_str;
811 }
812 this.getFilteredUrlArray = function() {
813 var req_str = "../scripts/get_filtered_count.php"+this.getFilterString();
814 return get(req_str).then(function(response){
791 var urls = JSON.parse(response); 815 var urls = JSON.parse(response);
792 var str = "Filtered to "+urls.urls.length+" file"; 816 return urls.urls;
793 if (urls.urls.length != 1) { 817 },function(error){
818 console.error(error);
819 });
820 }
821 this.getFileCount = function() {
822 // First we must get the filter pairs
823 this.getFilteredUrlArray().then(function(response){
824 var str = "Filtered to "+response.length+" file";
825 if (response.length != 1) {
794 str += "s."; 826 str += "s.";
795 } else { 827 } else {
796 str += "."; 828 str += ".";
797 } 829 }
798 document.getElementById("filter-count").textContent = str; 830 document.getElementById("filter-count").textContent = str;
799 },function(error){ 831 },function(error){});
800 console.error(error); 832 }
801 }); 833 }
802 }
803 }