Skip to content

Commit

Permalink
Writing Extract reports
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Apr 11, 2018
1 parent 8c440a9 commit 24cd7f5
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/naprrql/gql_schemas/naplan_schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type NaplanData {
item_results_report_by_school(acaraIDs: [String]): [ItemResponseDataSet]
## reporting (ui) object for writing item responses per student
item_writing_results_report_by_school(acaraIDs: [String]): [ItemResponseDataSet]
## reporting (ui) object for writing item responses per student, intended for export to marking systems, adds randomised ID to student (AnonymisedId in OtherIdList)
writing_item_for_marking_report_by_school(acaraIDs: [String]): [ItemResponseDataSet]
## report of all school summaries not linked to one of the acaraIDs
orphan_school_summary_report(acaraIDs: [String]): [ScoreSummary]
## report of all events not linked to one of the acaraIDs
Expand Down
22 changes: 22 additions & 0 deletions app/naprrql/naprrql.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var report = flag.Bool("report", false, "Creates .csv reports. Existing reports

// var isrprint = flag.Bool("isrprint", false, "Creates .csv files for use in isr printing")
// var itemprint = flag.Bool("itemprint", false, "Creates .csv files reporting item results for each student against items")
var writingextract = flag.Bool("writingextract", false, "Creates .csv file extract of all writing items, for input into marking systems")
var qa = flag.Bool("qa", false, "Creates .csv files for QA checking of NAPLAN results")
var vers = flag.Bool("version", false, "Reports version of NIAS distribution")

Expand Down Expand Up @@ -83,6 +84,17 @@ func main() {
closeDB()
os.Exit(1)
}

// create the writing item report
if *writingextract {
// launch web-server
startWebServer(true)
writeWritingExtractReports()
// shut down
closeDB()
os.Exit(1)
}

/*
// create the isr printing reports
if *isrprint {
Expand Down Expand Up @@ -181,6 +193,16 @@ func writeItemPrintingReports() {
log.Println("item printing reports generated...")
}

//
// create item printing reports
//
func writeWritingExtractReports() {
// clearReportsDirectory() // - check this
log.Println("generating Writing item extract reports...")
naprrql.GenerateWritingExtractReports()
log.Println("Writing item extract reports generated...")
}

// create QA reports
//
func writeQAPrintingReports() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
query NAPItemResults($acaraIDs: [String]) {
writing_item_for_marking_report_by_school(acaraIDs: $acaraIDs) {
Test {
TestContent {
LocalId
TestName
TestLevel
TestDomain
TestYear
TestType
}
}
Testlet {
TestletContent {
LocalId
Node
LocationInStage
TestletName
LocalId
}
}
TestItem {
ItemID
TestItemContent {
NAPTestItemLocalId
ItemName
ItemType
Subdomain
WritingGenre
ItemSubstitutedForList {
SubstituteItem {
SubstituteItemRefId
LocalId
}
}
NAPWritingRubricList {
NAPWritingRubric {
RubricType
}
}
}
}
Student {
LocalId
BirthDate
Sex
YearLevel
ASLSchoolId
OtherIdList {
OtherId {
Type
Value
}
}
}
ParticipationCode
Response {
PathTakenForDomain
ParallelTest
PSI
TestletList {
Testlet {
NapTestletLocalId
TestletScore
ItemResponseList {
ItemResponse {
LocalID
Response
ResponseCorrectness
Score
LapsedTimeItem
SequenceNumber
SubscoreList {
Subscore {
SubscoreType
SubscoreValue
}
}
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Test Year,Test level,Jurisdiction Id,ACARA ID,PSI,Local school student ID,TAA student ID,Participation Code,Item Response,Anonymised Id
Test.TestContent.TestYear,Test.TestContent.TestLevel,Student.OtherIdList.OtherId.#[Type==JurisdictionId].Value,Student.ASLSchoolId,Response.PSI,Student.LocalId,Student.OtherIdList.OtherId.#[Type==TAAId].Value,ParticipationCode,Response.TestletList.Testlet.0.ItemResponseList.ItemResponse.0.Response,Student.OtherIdList.OtherId.#[Type==AnonymisedId].Value
62 changes: 57 additions & 5 deletions naprrql/item-report-pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,59 @@ func runItemPipeline(schools []string) error {
return WaitForPipeline(errcList...)
}

// Slight variant of the foregoing
func runWritingExtractPipeline(schools []string) error {

// setup pipeline cancellation
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
var errcList []<-chan error

// input stage
varsc, errc, err := itemParametersSource(ctx, schools...)
if err != nil {
return err
}
errcList = append(errcList, errc)

// transform stage
queryTemplates := getTemplates("./reporting_templates/writing_extract/")
var query string
for _, queryText := range queryTemplates {
query = queryText
}
jsonc, errc, err := itemQueryExecutor(ctx, query, DEF_GQL_URL, varsc)
if err != nil {
return err
}
errcList = append(errcList, errc)

// sink stage
// create working directory if not there
outFileDir := "./out/writing_extract"
err = os.MkdirAll(outFileDir, os.ModePerm)
if err != nil {
return err
}
csvFileName := "writing_extract.csv"
outFileName := outFileDir + "/" + csvFileName
// we're assuming a single output report
mapFileName := "./reporting_templates/writing_extract/itemWritingPrinting_map.csv"
errc, err = csvFileSink(ctx, outFileName, mapFileName, jsonc)
if err != nil {
return err
}
errcList = append(errcList, errc)

log.Println("Writing extract file writing... " + outFileName)
return WaitForPipeline(errcList...)
}

//
// acts as input feed to the pipeline, sends parameters to retrieve data for
// each school in turn
//
func itemParametersSource(ctx context.Context, schools ...string) (<-chan itemQueryParams, <-chan error, error) {
func itemParametersSource(ctx context.Context, schools ...string) (<-chan systemQueryParams, <-chan error, error) {

{ //check input variables, handle errors before goroutine starts
if len(schools) == 0 {
Expand All @@ -92,7 +140,7 @@ func itemParametersSource(ctx context.Context, schools ...string) (<-chan itemQu

}

out := make(chan itemQueryParams)
out := make(chan systemQueryParams)
errc := make(chan error, 1)
go func() {
defer close(out)
Expand All @@ -103,7 +151,8 @@ func itemParametersSource(ctx context.Context, schools ...string) (<-chan itemQu
errc <- errors.Errorf("school %v is empty string", schoolIndex+1)
return
}
vars := itemQueryParams{school: school}
//vars := itemQueryParams{school: school}
vars := systemQueryParams{schoolAcaraID: school}
// Send the data to the output channel but return early
// if the context has been cancelled.
select {
Expand All @@ -120,7 +169,7 @@ func itemParametersSource(ctx context.Context, schools ...string) (<-chan itemQu
// query executor transform stage takes query params in, excutes gql query
// and writes results to output chaneel
//
func itemQueryExecutor(ctx context.Context, query string, url string, in <-chan itemQueryParams) (<-chan gjson.Result, <-chan error, error) {
func itemQueryExecutor(ctx context.Context, query string, url string, in <-chan systemQueryParams) (<-chan gjson.Result, <-chan error, error) {

out := make(chan gjson.Result)
errc := make(chan error, 1)
Expand All @@ -129,13 +178,16 @@ func itemQueryExecutor(ctx context.Context, query string, url string, in <-chan
defer close(errc)
gql := NewGqlClient()
for params := range in {
vars := map[string]interface{}{"acaraID": params.school}
//vars := map[string]interface{}{"acaraID": params.school}
vars := map[string]interface{}{"acaraIDs": []string{params.schoolAcaraID}}

json, err := gql.DoQuery(url, query, vars)
if err != nil {
// Handle an error that occurs during the goroutine.
errc <- err
return
}
// log.Printf("%+v\n", json)
for _, result := range json.Array() {
// Send the data to the output channel but return early
// if the context has been cancelled.
Expand Down
33 changes: 33 additions & 0 deletions naprrql/napprr-rprt.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,31 @@ func GenerateItemPrintReports() {
wg.Wait()
}

//
// generates a specific 'report' which is the input
// file for item printing processes
//
func GenerateWritingExtractReports() {

schools, err := getSchoolsList()
if err != nil {
log.Fatalln("Cannot connect to naprrql server: ", err)
}

var wg sync.WaitGroup

wg.Add(1)
go func() {
defer wg.Done()
err = runWritingExtractReports(schools)
if err != nil {
log.Println("Error creating isr printing reports: ", err)
}
}()

wg.Wait()
}

// generates a specific 'report' which is the input
// file for item printing processes
//
Expand Down Expand Up @@ -138,6 +163,14 @@ func runItemPrintReports(schools []string) error {

}

func runWritingExtractReports(schools []string) error {

var pipelineError error
pipelineError = runWritingExtractPipeline(schools)
return pipelineError

}

func runQAReports(schools []string) error {

var pipelineError error
Expand Down
Loading

0 comments on commit 24cd7f5

Please sign in to comment.