Mercurial > hg > webaudioevaluationtool
comparison scripts/comment_parser.php @ 640:828d6b96af57 Dev_main
Fixed some comment/score parser issues on PHP.
| author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
|---|---|
| date | Thu, 24 Mar 2016 12:29:39 +0000 |
| parents | b09a9f38fc76 |
| children |
comparison
equal
deleted
inserted
replaced
| 639:27dc7a36ecd3 | 640:828d6b96af57 |
|---|---|
| 33 // Iterate over each audioHolder node | 33 // Iterate over each audioHolder node |
| 34 foreach($xml_object->page as $pageInstance) | 34 foreach($xml_object->page as $pageInstance) |
| 35 { | 35 { |
| 36 // Find the page in the comment_struct | 36 // Find the page in the comment_struct |
| 37 $page_struct = null; | 37 $page_struct = null; |
| 38 foreach($comment_struct as $comment_struct_page) | 38 if($pageInstance['state'] == "complete") { |
| 39 { | 39 foreach($comment_struct as $comment_struct_page) |
| 40 if ($pageInstance['ref'] == $comment_struct_page->id) | |
| 41 { | 40 { |
| 42 $page_struct = $comment_struct_page; | 41 if ($pageInstance['ref'] == $comment_struct_page->id) |
| 43 break; | |
| 44 } | |
| 45 } | |
| 46 if ($page_struct == null) { | |
| 47 array_push($comment_struct,new testPage($pageInstance['ref'])); | |
| 48 $page_struct = $comment_struct[count($comment_struct)-1]; | |
| 49 } | |
| 50 // Get the audioelements of the page | |
| 51 foreach($pageInstance->audioelement as $fragment) | |
| 52 { | |
| 53 // Find the page in the comment_struct | |
| 54 $element_struct = null; | |
| 55 foreach($page_struct->elements as $page_struct_element) | |
| 56 { | |
| 57 if ($fragment['name'] == $page_struct_element->id) | |
| 58 { | 42 { |
| 59 $element_struct = $page_struct_element; | 43 $page_struct = $comment_struct_page; |
| 60 break; | 44 break; |
| 61 } | 45 } |
| 62 } | 46 } |
| 63 if ($element_struct == null) { | 47 if ($page_struct == null) { |
| 64 array_push($page_struct->elements,new audioElement($fragment['name'])); | 48 array_push($comment_struct,new testPage($pageInstance['ref'])); |
| 65 $element_struct = $page_struct->elements[count($page_struct->elements)-1]; | 49 $page_struct = $comment_struct[count($comment_struct)-1]; |
| 66 } | 50 } |
| 67 $element_struct->addComment($fragment->comment->response); | 51 // Get the audioelements of the page |
| 52 foreach($pageInstance->audioelement as $fragment) | |
| 53 { | |
| 54 // Find the page in the comment_struct | |
| 55 $element_struct = null; | |
| 56 foreach($page_struct->elements as $page_struct_element) | |
| 57 { | |
| 58 if ($fragment['name'] == $page_struct_element->id) | |
| 59 { | |
| 60 $element_struct = $page_struct_element; | |
| 61 break; | |
| 62 } | |
| 63 } | |
| 64 if ($element_struct == null) { | |
| 65 array_push($page_struct->elements,new audioElement($fragment['name'])); | |
| 66 $element_struct = $page_struct->elements[count($page_struct->elements)-1]; | |
| 67 } | |
| 68 $element_struct->addComment($fragment->comment->response); | |
| 69 } | |
| 68 } | 70 } |
| 69 } | 71 } |
| 70 } | 72 } |
| 71 } | 73 } |
| 72 // Now we have a sub <xml> containing all comment data | 74 // Now we have a structure containing all comment data |
| 73 switch($_GET['format']) { | 75 switch($_GET['format']) { |
| 74 case "XML": | 76 case "XML": |
| 75 // Convert to an XML | 77 // Convert to an XML |
| 76 $doc_struct = new SimpleXMLElement('<waetprocess/>'); | 78 $doc_struct = new SimpleXMLElement('<waetprocess/>'); |
| 77 foreach($comment_struct as $page_struct) | 79 foreach($comment_struct as $page_struct) |
