Working towards a Solution - Some Hints!
1. Download the sample module data files and familiarise yourself with the data and data
format. I will provide them soon have an agrement.
2. Think about what data you will need to extract from each line of the module data
files to calculate the required statistics, and how you will do this using PHP. It may
be helpful to review the work we have undertaken in class about file manipulation,
string manipulation and the use of arrays.
3. Download the [login to view URL] file from the TMA resources folder in Moodle and create
an includes subfolder to store it in. Create a basic test PHP script to test using the
provided mmmr() function on a test array list of numbers, to understand how it works.
Once you have this working, think about how you will read the module mark
numbers from the data files and store them, so that you can pass them to the mmmr()
function to calculate mean, mode and range.
4. Produce an initial pseudo-code design outlining the basic structure and sequence of
your PHP script. Then provide details of how you will (1) read individual lines from the
file, (2) validate data, (3) assign data to appropriate data structures (variables and
arrays) (4) output in HTML format. Think carefully about how you will count;
“Distinction”, “Merit”, “Pass” and “Fail” grades. Use functions to avoid duplicating
code (for example, to validate Module Codes, Dates, and assign a grade to a
5. It may be helpful to test your script against a single data file to check it is working as
expected before trying to work with all the files. Also, try to get the data in line 1 of the
files analysed and working before moving on to the module marks lines. You should
provide validation checks to see if a data file is empty, if line 1 contains a valid header
and subsequent lines contain valid data. Report an error if there is an empty file (you
will need to check if the file contains only white space as well as 0 bytes), the header
should have 4 data items and the data lines 2 data items. If all that is ok you can then
validate each header item to the File coding specification and each individual
student/mark data pair. N.B. you do not need to validate the file names against
module leader data in the files.
6. Once you are confident extracting the required data from one file and all the data is
validating correctly, move on to calculate and display the required statistics.
7. Once you have one file working correctly, open all the module data files in PHP
and loop through each one extracting data and calculating statistics for each file.
8. You will need to create a new module data file that contains no data errors;
“[login to view URL]”. Use a simple ASCII text editor to do this by cloning one of the supplied
files. Only files with a .txt extension should be processed, any other files should be
ignored. Create another test file called “[login to view URL]” and includeit in your submission to
test this works.
9. Code should not be repeated - marks are awarded for the careful use of functions and
code re-use, Try not to repeat any code even though you are analysing multiple log
Deliverables to Submit for Assessment
The following TMA deliverables must be submitted electronically in the Assessment Tile à
Turnitin Dropbox in Moodle BEFORE the start of Session 5, as a single ZIP file,
[login to view URL]:
1. A Word or Pdf document, which contains your pseudo-code design and any
comments you feel necessary to explain how you designed your solution.
2. All of your PHP source files in the folder structure required to publish the site.