From 2f9be05e044bed7e032ab8535c09835f76a44c50 Mon Sep 17 00:00:00 2001
From: matt-farmer
Date: Thu, 27 Apr 2017 13:21:16 +1000
Subject: [PATCH] Testing Support
Minor updates and debugging enabled for web-ui so users can inspect
data structures in the console of the browser.
---
app/naprr/naprr.go | 26 ++++++++++++---
app/naprr/public/js/naprr.js | 1 +
app/naprr/public/js/naprr_graphs.js | 2 +-
app/naprr/public/js/naprr_schoolinfo.js | 42 +++++++++++++++----------
app/naprr/public/js/naprr_ui.js | 30 ++++++++++++++++++
naprr/contractor_csvdata_ingest.go | 11 ++++---
naprr/naprr_webserver.go | 2 +-
naprr/reportgenerator.go | 4 ++-
naprr/reportwriter.go | 2 +-
9 files changed, 90 insertions(+), 30 deletions(-)
diff --git a/app/naprr/naprr.go b/app/naprr/naprr.go
index 82b7f75..7eec06f 100644
--- a/app/naprr/naprr.go
+++ b/app/naprr/naprr.go
@@ -2,11 +2,12 @@ package main
import (
"flag"
- "github.com/nats-io/nats-streaming-server/server"
- "github.com/nsip/nias2/naprr"
"log"
"net"
"os"
+
+ "github.com/nats-io/nats-streaming-server/server"
+ "github.com/nsip/nias2/naprr"
// "os/exec"
// "os/signal"
"runtime"
@@ -15,6 +16,7 @@ import (
var rewrite = flag.Bool("rewrite", false, "rewrite regenerates all reports without re-loading data")
var webonly = flag.Bool("webonly", false, "just launch web data explorer")
+var yr3writing = flag.Bool("yr3writing", false, "read external yr3 writing files")
func main() {
@@ -37,14 +39,28 @@ func main() {
di := naprr.NewDataIngest()
di.Run()
- di.RunYr3Writing()
+
+ //
+ // only parse external yr3 if requested
+ //
+ // if *yr3writing {
+ // log.Println("attempting to read yr3 writing files...")
+ // di.RunYr3Writing()
+ // }
+
di.Close()
rb := naprr.NewReportBuilder()
log.Println("Generating report data...")
rb.Run()
- log.Println("Generating report data, Year 3 Writing...")
- rb.RunYr3W(false)
+
+ //
+ // report on yr3 only if requested
+ //
+ // if *yr3writing {
+ // log.Println("Generating report data, Year 3 Writing...")
+ // rb.RunYr3W(false)
+ // }
}
log.Println("Writing report files...")
diff --git a/app/naprr/public/js/naprr.js b/app/naprr/public/js/naprr.js
index 56a4311..e3d694d 100644
--- a/app/naprr/public/js/naprr.js
+++ b/app/naprr/public/js/naprr.js
@@ -4,6 +4,7 @@ var participationData = [];
var domainscoresData = [];
var codeframeData = [];
var schoolinfoData = {};
+var debug =true;
var currentASLId;
diff --git a/app/naprr/public/js/naprr_graphs.js b/app/naprr/public/js/naprr_graphs.js
index 7bb39f8..18974e6 100644
--- a/app/naprr/public/js/naprr_graphs.js
+++ b/app/naprr/public/js/naprr_graphs.js
@@ -41,7 +41,7 @@ function createScoreSummaryGraph(ssdata)
attributes['Value'] = +ssdata.Summ.DomainBottomNational60Percent;
data.push(attributes);
- console.log(data);
+ // console.log(data);
var orderMeasures = [
'Bottom National 60%',
diff --git a/app/naprr/public/js/naprr_schoolinfo.js b/app/naprr/public/js/naprr_schoolinfo.js
index 4e97ef6..5f042c9 100644
--- a/app/naprr/public/js/naprr_schoolinfo.js
+++ b/app/naprr/public/js/naprr_schoolinfo.js
@@ -33,8 +33,6 @@ function createSchoolInfoReport()
// console.log(schoolinfoData);
- var contactInfo = schoolinfoData.SchoolContactList.SchoolContact[0].ContactInfo;
-
$("#si-header").empty();
$("#si-contact").empty();
$("#si-establishment").empty();
@@ -43,19 +41,26 @@ function createSchoolInfoReport()
$("#si-header").append("" +
schoolinfoData.SchoolName + "
");
- $("#si-contact").append("" + contactInfo.Address.Street.Line1 +
- ", " + contactInfo.Address.City +
- ", " + contactInfo.Address.StateProvince +
- ", " + contactInfo.Address.PostalCode +
- ".
");
+ var contactExists = schoolinfoData.SchoolContactList.SchoolContact !== null ? true : false
+ if (contactExists)
+ {
+ contactInfo = schoolinfoData.SchoolContactList.SchoolContact[0].ContactInfo;
+ $("#si-contact").append("" + contactInfo.Address.Street.Line1 +
+ ", " + contactInfo.Address.City +
+ ", " + contactInfo.Address.StateProvince +
+ ", " + contactInfo.Address.PostalCode +
+ ".
");
- $("#si-contact").append("Principal: " + schoolinfoData.PrincipalInfo.ContactName.FullName +
- ".
");
+ $("#si-contact").append("Principal: " + schoolinfoData.PrincipalInfo.ContactName.FullName +
+ ".
");
+
+ $("#si-contact").append("Contact: " + contactInfo.Name.FullName + "
" +
+ "Phone: " + contactInfo.PhoneNumberList.PhoneNumber[0].Number +
+ " Ext.: " + contactInfo.PhoneNumberList.PhoneNumber[0].Extension +
+ ".
");
+
+ }
- $("#si-contact").append("Contact: " + contactInfo.Name.FullName + "
" +
- "Phone: " + contactInfo.PhoneNumberList.PhoneNumber[0].Number +
- " Ext.: " + contactInfo.PhoneNumberList.PhoneNumber[0].Extension +
- ".
");
$("#si-establishment").append("ACARA (ASL) Id: " + schoolinfoData.ACARAId + "
" +
"Local Id: " + schoolinfoData.LocalId + "
" +
@@ -76,10 +81,13 @@ function createSchoolInfoReport()
"LGA: " + schoolinfoData.LocalGovernmentArea + "
" +
"Federal Electorate: " + schoolinfoData.FederalElectorate + "
" +
"Religious Affiliation: " + schoolinfoData.ReligiousAffiliation + "
" +
- "Geographic Location: " + schoolinfoData.SchoolGeographicLocation + "
" +
- "Grid Location: " + contactInfo.Address.GridLocation.Latitude +
- ", " + contactInfo.Address.GridLocation.Longitude + "
" +
- ".
");
+ "Geographic Location: " + schoolinfoData.SchoolGeographicLocation + "
");
+
+ if (contactExists)
+ {
+ $("#si-extended").append("Grid Location: " + contactInfo.Address.GridLocation.Latitude +
+ ", " + contactInfo.Address.GridLocation.Longitude + "
");
+ }
diff --git a/app/naprr/public/js/naprr_ui.js b/app/naprr/public/js/naprr_ui.js
index 9082efe..a59dc1c 100644
--- a/app/naprr/public/js/naprr_ui.js
+++ b/app/naprr/public/js/naprr_ui.js
@@ -156,6 +156,12 @@ function initSchoolChooserHandler()
scoresummaryData = data;
console.log("score summary data downloaded for " + acaraid +
" elements: " + scoresummaryData.length);
+
+ if (debug)
+ {
+ console.log(scoresummaryData);
+ }
+
// display on screen while other reports download
hideReport();
createScoreSummaryReport();
@@ -169,6 +175,12 @@ function initSchoolChooserHandler()
domainscoresData = data;
console.log("domain scores data downloaded for " + acaraid +
" elements: " + domainscoresData.length);
+
+ if (debug)
+ {
+ console.log(domainscoresData);
+ }
+
});
$.get("/naprr/participation/" + acaraid, function(data, status)
@@ -177,6 +189,12 @@ function initSchoolChooserHandler()
participationData = data;
console.log("participation data downloaded for " + acaraid +
" elements: " + participationData.length);
+
+ if (debug)
+ {
+ console.log(participationData);
+ }
+
});
$.get("/naprr/schoolinfo/" + acaraid, function(data, status)
@@ -185,6 +203,12 @@ function initSchoolChooserHandler()
schoolinfoData = data;
console.log("school info data downloaded for " + acaraid);
+ if (debug)
+ {
+ console.log(schoolinfoData);
+ }
+
+
});
$.get("/naprr/codeframe", function(data, status)
@@ -192,6 +216,12 @@ function initSchoolChooserHandler()
codeframeData = {};
codeframeData = data;
console.log("codeframe data downloaded.");
+
+ if (debug)
+ {
+ console.log(codeframeData);
+ }
+
});
});
diff --git a/naprr/contractor_csvdata_ingest.go b/naprr/contractor_csvdata_ingest.go
index d73fabf..3abcd30 100644
--- a/naprr/contractor_csvdata_ingest.go
+++ b/naprr/contractor_csvdata_ingest.go
@@ -3,15 +3,18 @@ package naprr
import (
"bufio"
//ms "github.com/mitchellh/mapstructure"
- "github.com/nats-io/nuid"
"strconv"
+
+ "github.com/nats-io/nuid"
//"github.com/nats-io/go-nats-streaming"
"fmt"
+ "log"
+ "path/filepath"
+
"github.com/nsip/nias2/lib"
nxml "github.com/nsip/nias2/xml"
"github.com/twinj/uuid"
- "log"
- "path/filepath"
+
//"sync"
)
@@ -30,7 +33,7 @@ func (di *DataIngest) RunYr3Writing() {
func parsePearsonCSVFileDirectory() []string {
files, _ := filepath.Glob("./in/Pearson/*.txt")
if len(files) == 0 {
- log.Fatalln("No results data zip files found in input folder.")
+ log.Fatalln("No Pearson format data files found in input folder.")
}
return files
}
diff --git a/naprr/naprr_webserver.go b/naprr/naprr_webserver.go
index f14c892..3023fae 100644
--- a/naprr/naprr_webserver.go
+++ b/naprr/naprr_webserver.go
@@ -123,7 +123,7 @@ func (rrs *ResultsReportingServer) Run() {
//
e.GET("/naprr/codeframe", func(c echo.Context) error {
- cfds := rrs.sr.GetCodeFrameData("report.cframe")
+ cfds := rrs.sr.GetCodeFrameData(REPORTS_CODEFRAME)
return c.JSON(http.StatusAccepted, cfds)
})
diff --git a/naprr/reportgenerator.go b/naprr/reportgenerator.go
index 74e0566..f815e92 100644
--- a/naprr/reportgenerator.go
+++ b/naprr/reportgenerator.go
@@ -2,9 +2,10 @@
package naprr
import (
+ "log"
+
"github.com/nats-io/go-nats-streaming"
"github.com/nsip/nias2/lib"
- "log"
)
type ReportGenerator struct {
@@ -234,6 +235,7 @@ func (rg *ReportGenerator) GenerateParticipationData(nd *NAPLANData, sd *SchoolD
for _, ei := range pds.EventInfos {
pds.Summary[ei.Test.TestContent.TestDomain] = ei.Event.ParticipationCode
}
+
payload, err := rg.ge.Encode(pds)
if err != nil {
log.Println("unable to encode pds: ", err)
diff --git a/naprr/reportwriter.go b/naprr/reportwriter.go
index e30b713..62a9355 100644
--- a/naprr/reportwriter.go
+++ b/naprr/reportwriter.go
@@ -33,7 +33,7 @@ func (rw *ReportWriter) Run() {
rw.writeSchoolLevelReports(schools)
rw.writeAggregateSchoolReports(schools)
rw.writeTestLevelReports()
- rw.writeYr3WReports()
+ // rw.writeYr3WReports()
log.Println("All reports written\n")