changeset 1915:8d8f07be23d7

Fixed some comment/score parser issues on PHP.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Thu, 24 Mar 2016 12:29:39 +0000
parents 41de3c8f9ee4
children 9acdcbe7021f
files analysis/index.html scripts/comment_parser.php scripts/score_parser.php
diffstat 3 files changed, 34 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/analysis/index.html	Thu Mar 24 10:36:38 2016 +0000
+++ b/analysis/index.html	Thu Mar 24 12:29:39 2016 +0000
@@ -11,7 +11,7 @@
         <div id="test-charts">
             <p>Charts per test</p>
             <button onclick="chartContext.drawTestMean();">Means</button>
-            <button onclick="chartContext.drawTestBoxplot();">Means</button>
+            <button onclick="chartContext.drawTestBoxplot();">Boxplot</button>
         </div>
         <div id="page-charts">
             <p>Charts per test page</p>
--- a/scripts/comment_parser.php	Thu Mar 24 10:36:38 2016 +0000
+++ b/scripts/comment_parser.php	Thu Mar 24 12:29:39 2016 +0000
@@ -35,41 +35,43 @@
             {
                 // Find the page in the comment_struct
                 $page_struct = null;
-                foreach($comment_struct as $comment_struct_page)
-                {
-                    if ($pageInstance['ref'] == $comment_struct_page->id)
+                if($pageInstance['state'] == "complete") {
+                    foreach($comment_struct as $comment_struct_page)
                     {
-                        $page_struct = $comment_struct_page;
-                        break;
-                    }
-                }
-                if ($page_struct == null) {
-                    array_push($comment_struct,new testPage($pageInstance['ref']));
-                    $page_struct = $comment_struct[count($comment_struct)-1];
-                }
-                // Get the audioelements of the page
-                foreach($pageInstance->audioelement as $fragment)
-                {
-                    // Find the page in the comment_struct
-                    $element_struct = null;
-                    foreach($page_struct->elements as $page_struct_element)
-                    {
-                        if ($fragment['name'] == $page_struct_element->id)
+                        if ($pageInstance['ref'] == $comment_struct_page->id)
                         {
-                            $element_struct = $page_struct_element;
+                            $page_struct = $comment_struct_page;
                             break;
                         }
                     }
-                    if ($element_struct == null) {
-                        array_push($page_struct->elements,new audioElement($fragment['name']));
-                        $element_struct = $page_struct->elements[count($page_struct->elements)-1];
+                    if ($page_struct == null) {
+                        array_push($comment_struct,new testPage($pageInstance['ref']));
+                        $page_struct = $comment_struct[count($comment_struct)-1];
                     }
-                    $element_struct->addComment($fragment->comment->response);
+                    // Get the audioelements of the page
+                    foreach($pageInstance->audioelement as $fragment)
+                    {
+                        // Find the page in the comment_struct
+                        $element_struct = null;
+                        foreach($page_struct->elements as $page_struct_element)
+                        {
+                            if ($fragment['name'] == $page_struct_element->id)
+                            {
+                                $element_struct = $page_struct_element;
+                                break;
+                            }
+                        }
+                        if ($element_struct == null) {
+                            array_push($page_struct->elements,new audioElement($fragment['name']));
+                            $element_struct = $page_struct->elements[count($page_struct->elements)-1];
+                        }
+                        $element_struct->addComment($fragment->comment->response);
+                    }
                 }
             }
         }
     }
-    // Now we have a sub <xml> containing all comment data
+    // Now we have a structure containing all comment data
     switch($_GET['format']) {
         case "XML":
             // Convert to an XML
--- a/scripts/score_parser.php	Thu Mar 24 10:36:38 2016 +0000
+++ b/scripts/score_parser.php	Thu Mar 24 12:29:39 2016 +0000
@@ -73,7 +73,12 @@
                 // Iterate over each $element node
                 foreach($pageInstance->audioelement as $element) {
                     // Find our specific element tag
-                    $elementId = $element['name'];
+                    $elementId = null;
+                    if (isset($element['name'])) {
+                        $elementId = $element['name'];
+                    } else {
+                        $elementId = $element['ref'];
+                    }
                     $element_nest = $page_nest->findChild($elementId);
                     if ($element_nest == null) {
                         $element_nest = $page_nest->addNewChild($elementId);