-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from writecrow/handle-multiple-students
Support pipe separators and multiple instances
- Loading branch information
Showing
9 changed files
with
298 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace writecrow\TagConverter; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test files are converted correctly. | ||
*/ | ||
class StructureTest extends TestCase { | ||
|
||
/** | ||
* Provides data. | ||
*/ | ||
public function dataProvider() { | ||
return [ | ||
'Traditional' => [ | ||
'filename' => 'file-with-traditional-structure.txt', | ||
'expected' => '{"Student ID":"10410","Country":"China","Institution":"University of Arizona","Course":"ENGL 106","Mode":"Face to Face","Length":"16 weeks","Assignment":"DE","Draft":"F","Year in School":"1","Gender":"M","Course Year":"2018","Course Semester":"Spring","College":"Colleges Letters Arts Science","Program":"No Major Selected Ltr Art Sci","Proficiency Exam":"TOEFL","Exam total":"73.0","Exam reading":"17.0","Exam listening":"18.0","Exam speaking":"17.0","Exam writing":"21.0","Instructor":"1018","Section":"1039","text":"English:106-005\nUnit1 Project: Description and Explanation\nLanguage Change in my Blog Writing\nWhen the author write about Sociolinguistics, he always write about the variation about language.\n"}', | ||
], | ||
'Single' => [ | ||
'filename' => 'file-with-single-student.txt', | ||
'expected' => '{"Student IDs":"10527","Group ID":"NA","Institution":"University of Arizona","Course":"ENGL 106","Mode":"Face to Face","Length":"16 weeks","Assignment":"DE","Draft":"F","Course Year":"2019","Course Semester":"Spring","Instructor":"1019","Section":"1057","Student ID":"10527","Country":"NA","L1":"NA","Heritage Spanish Speaker":"NA","Year in School":"1","Gender":"F","College":"Eller College of Management","Program":"Pre-Economics","Proficiency Exam":"TOEFL","Exam total":"85.0","Exam reading":"21.0","Exam listening":"24.0","Exam speaking":"20.0","Exam writing":"20.0","text":"2019-2-19. 10:00am\nAuthor-Spolsky. <name> <name>\nClass section-Eng106\nIn my re-write passage, I followed some rules of the blog and informal writing. Generally, this article is written for myself, so the goal of the rewriting article is to help me better understand this article.\n"}', | ||
], | ||
'Multiple' => [ | ||
'filename' => 'file-with-multiple-students.txt', | ||
'expected' => '{"Student IDs":["10527","10528"],"Group ID":"NA","Institution":"University of Arizona","Course":"ENGL 106","Mode":"Face to Face","Length":"16 weeks","Assignment":"DE","Draft":"F","Course Year":"2019","Course Semester":"Spring","Instructor":"1019","Section":"1057","Student ID":["10527","10528"],"Country":["NA","CHN"],"L1":["NA","Chinese"],"Heritage Spanish Speaker":["NA","NA"],"Year in School":["1","2"],"Gender":["F","M"],"College":["Eller College of Management","School B"],"Program":["Pre-Economics","English"],"Proficiency Exam":["TOEFL","TOEFL"],"Exam total":["85.0","89.0"],"Exam reading":["21.0","22.0"],"Exam listening":["24.0","25.0"],"Exam speaking":["20.0","21.0"],"Exam writing":["20.0","21.0"],"text":"2019-2-19. 10:00am\nAuthor-Spolsky. <name> <name>\nClass section-Eng106\nIn my re-write passage, I followed some rules of the blog and informal writing. Generally, this article is written for myself, so the goal of the rewriting article is to help me better understand this article.\n"}', | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Test assertions. | ||
* | ||
* @dataProvider dataProvider | ||
*/ | ||
public function testStructure($filename, $expected) { | ||
$input = file_get_contents('test/data/' . $filename, FILE_USE_INCLUDE_PATH); | ||
$actual = TagConverter::json($input); | ||
$this->assertEquals($expected, html_entity_decode($actual)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<Text> | ||
<Student IDs: 10527|10528> | ||
<Group ID: NA> | ||
<Institution: University of Arizona> | ||
<Course: ENGL 106> | ||
<Mode: Face to Face> | ||
<Length: 16 weeks> | ||
<Assignment: DE> | ||
<Draft: F> | ||
<Course Year: 2019> | ||
<Course Semester: Spring> | ||
<Instructor: 1019> | ||
<Section: 1057> | ||
</Text> | ||
|
||
<Student 1> | ||
<Student ID: 10527> | ||
<Country: NA> | ||
<L1: NA> | ||
<Heritage Spanish Speaker: NA> | ||
<Year in School: 1> | ||
<Gender: F> | ||
<College: Eller College of Management> | ||
<Program: Pre-Economics> | ||
<Proficiency Exam: TOEFL> | ||
<Exam total: 85.0> | ||
<Exam reading: 21.0> | ||
<Exam listening: 24.0> | ||
<Exam speaking: 20.0> | ||
<Exam writing: 20.0> | ||
</Student 1> | ||
|
||
<Student 2> | ||
<Student ID: 10528> | ||
<Country: CHN> | ||
<L1: Chinese> | ||
<Heritage Spanish Speaker: NA> | ||
<Year in School: 2> | ||
<Gender: M> | ||
<College: School B> | ||
<Program: English> | ||
<Proficiency Exam: TOEFL> | ||
<Exam total: 89.0> | ||
<Exam reading: 22.0> | ||
<Exam listening: 25.0> | ||
<Exam speaking: 21.0> | ||
<Exam writing: 21.0> | ||
</Student 1> | ||
<End Header> | ||
|
||
2019-2-19. 10:00am | ||
Author-Spolsky. <name> <name> | ||
Class section-Eng106 | ||
In my re-write passage, I followed some rules of the blog and informal writing. Generally, this article is written for myself, so the goal of the rewriting article is to help me better understand this article. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<Text> | ||
<Student IDs: 10527> | ||
<Group ID: NA> | ||
<Institution: University of Arizona> | ||
<Course: ENGL 106> | ||
<Mode: Face to Face> | ||
<Length: 16 weeks> | ||
<Assignment: DE> | ||
<Draft: F> | ||
<Course Year: 2019> | ||
<Course Semester: Spring> | ||
<Instructor: 1019> | ||
<Section: 1057> | ||
</Text> | ||
|
||
<Student 1> | ||
<Student ID: 10527> | ||
<Country: NA> | ||
<L1: NA> | ||
<Heritage Spanish Speaker: NA> | ||
<Year in School: 1> | ||
<Gender: F> | ||
<College: Eller College of Management> | ||
<Program: Pre-Economics> | ||
<Proficiency Exam: TOEFL> | ||
<Exam total: 85.0> | ||
<Exam reading: 21.0> | ||
<Exam listening: 24.0> | ||
<Exam speaking: 20.0> | ||
<Exam writing: 20.0> | ||
</Student 1> | ||
<End Header> | ||
|
||
2019-2-19. 10:00am | ||
Author-Spolsky. <name> <name> | ||
Class section-Eng106 | ||
In my re-write passage, I followed some rules of the blog and informal writing. Generally, this article is written for myself, so the goal of the rewriting article is to help me better understand this article. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Student ID: 10410> | ||
<Country: China> | ||
<Institution: University of Arizona> | ||
<Course: ENGL 106> | ||
<Mode: Face to Face> | ||
<Length: 16 weeks> | ||
<Assignment: DE> | ||
<Draft: F> | ||
<Year in School: 1> | ||
<Gender: M> | ||
<Course Year: 2018> | ||
<Course Semester: Spring> | ||
<College: Colleges Letters Arts Science> | ||
<Program: No Major Selected Ltr Art Sci> | ||
<Proficiency Exam: TOEFL> | ||
<Exam total: 73.0> | ||
<Exam reading: 17.0> | ||
<Exam listening: 18.0> | ||
<Exam speaking: 17.0> | ||
<Exam writing: 21.0> | ||
<Instructor: 1018> | ||
<Section: 1039> | ||
<End Header> | ||
|
||
English:106-005 | ||
Unit1 Project: Description and Explanation | ||
Language Change in my Blog Writing | ||
When the author write about Sociolinguistics, he always write about the variation about language. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Demonstration file of using TagConverter library. | ||
*/ | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
use writecrow\TagConverter\TagConverter; | ||
|
||
$file = file_get_contents('test/data/file-with-multiple-students.txt', FILE_USE_INCLUDE_PATH); | ||
|
||
$text = TagConverter::json($file); | ||
|
||
echo '<div><pre><code>'; | ||
print_r($text); | ||
echo '</code></pre></div>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Demonstration file of using TagConverter library. | ||
*/ | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
use writecrow\TagConverter\TagConverter; | ||
|
||
$file = file_get_contents('test/data/file-with-single-student.txt', FILE_USE_INCLUDE_PATH); | ||
|
||
$text = TagConverter::php($file); | ||
|
||
echo '<div><pre><code>'; | ||
print_r($text); | ||
echo '</code></pre></div>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Demonstration file of using TagConverter library. | ||
*/ | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
use writecrow\TagConverter\TagConverter; | ||
|
||
$file = file_get_contents('test/data/file-with-traditional-structure.txt', FILE_USE_INCLUDE_PATH); | ||
|
||
$text = TagConverter::php($file); | ||
|
||
echo '<div><pre><code>'; | ||
print_r($text); | ||
echo '</code></pre></div>'; |