Tuesday, 10 October 2017

JavaScript Testing resources


An Overview of JavaScript Testing in 2017
https://medium.com/powtoon-engineering/a-complete-guide-to-testing-javascript-in-2017-a217b4cd5a2a

JSUnit
http://www.jsunit.net/
a Unit Testing framework for client-side (in-browser) JavaScript.


Jasmine (JavaScript testing framework)
https://en.wikipedia.org/wiki/Jasmine_(JavaScript_testing_framework)
Jasmine is an open source testing framework for JavaScript.[4] It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. 

Jasmine
https://github.com/jasmine/jasmine/releases

DalekJS
http://dalekjs.com/index.html
http://dalekjs.com/pages/getStarted.html#install
Automated cross browser testing with JavaScript!



TrueSkill resources

The original MS posts
https://www.microsoft.com/en-us/research/project/trueskill-ranking-system/
https://www.microsoft.com/en-us/research/project/trueskill-ranking-system/?from=http%3A%2F%2Fresearch.microsoft.com%2Fmlp%2Ftrueskill%2Frankcalculator.aspx

Moserware resources - the most important
http://www.moserware.com/2010/03/computing-your-skill.html

A detailed implementation of the TrueSkill algorithm to go along with my "Computing Your Skill" blog post
https://github.com/moserware/Skills

The key codefile: 1 player versus 1 player
https://github.com/moserware/Skills/blob/master/Skills/TrueSkill/TwoPlayerTrueSkillCalculator.cs


http://www.moserware.com/assets/computing-your-skill/The%20Math%20Behind%20TrueSkill.pdf


An implementation in the F language
https://blogs.technet.microsoft.com/apg/2008/06/16/trueskill-in-f/


Glicko paper
http://www.glicko.net/glicko/glicko.pdf

Glicko2 paper
http://www.glicko.net/glicko/glicko2.pdf

Glicko 2 in Javascript for Node.js
https://www.npmjs.com/package/glicko2

Lots of good commenting in the code
Glicko2 in a node-InTheBrowser demo
https://npm.runkit.com/glicko2

How the .cotcot changes as the competition progresses

Initially:

Root node
CompetitionIndividuelle
  Tireurs
     Tireur <1>  there is no UID for each fencer
     etc - e.g.   <Tireur Nom="Appleton" Prenom="Anna" DateNaissance="01.03.2010" Sexe="F" Club="FiF North Merchiston" Licence="" Categorie="" Ranking="0" Rating="" Exporte="0" Statut="F"/>
 <Equipes/>
 <Arbitres/>
 <Phases PhaseEnCours="0">
  <ClassementGeneral PhaseID="1" ID=""/>
 </Phases>

Define formula of 1 round of pools - Phases is updated with a TourDePoules.  Phase IDs are re-shuffled

<Phases PhaseEnCours="0">
  <TourDePoules PhaseID="2" ID="Round 1" ScoreMax="5" RepartitionEquilibre="1" PhaseSuivanteDesQualifies="3"/>
  <ClassementGeneral PhaseID="3" ID=""/>
</Phases>

After Check-in is done, each fencer changes Statut attrib, from F to Q
<Tireur Nom="Appleton" Prenom="Anna" DateNaissance="01.03.2010" Sexe="F" Club="FiF North Merchiston" Licence="" Categorie="" Ranking="0" Rating="" Exporte="0" Statut="Q"/>

Move to Next Round (Round 1 pools).
Fencers get a UID attribute, ID="n"
  <Tireur ID="1" Nom="Appleton" Prenom="Anna" DateNaissance="01.03.2010" Sexe="F" Club="FiF North Merchiston" Licence="" Categorie="" Ranking="0" Rating="" Exporte="0" Statut="Q"/>

Within TourDePoules, there are a set of Tireur tags, one per fencer, using only a REF="n" attrib and a RangInitial="n" attribute
Then a Poule is added, with UID attribute ID="n"
within the pool, each fencer gets Pool results attributes
    <Tireur REF="1" NoDansLaPoule="3" NbVictoires="0" NbMatches="4" RangPoule="0"/>
They are listed in pool appearance order
The REF attribute is based on initial appearance in the /cotcot file

TourDePoules PhaseId="2" becomes
 <TourDePoules PhaseID="2" ID="Round 1" ScoreMax="5" RepartitionEquilibre="1" NbDePoules="1" PhaseSuivanteDesQualifies="3">
   <Tireur REF="4" RangInitial="1"/>
   <Tireur REF="2" RangInitial="2"/>
   <Tireur REF="1" RangInitial="3"/>
   <Tireur REF="5" RangInitial="4"/>
   <Tireur REF="3" RangInitial="5"/>
   <Poule ID="1">
    <Tireur REF="4" NoDansLaPoule="1" NbVictoires="0" NbMatches="4" RangPoule="0"/>
    <Tireur REF="2" NoDansLaPoule="2" NbVictoires="0" NbMatches="4" RangPoule="0"/>
    <Tireur REF="1" NoDansLaPoule="3" NbVictoires="0" NbMatches="4" RangPoule="0"/>
    <Tireur REF="5" NoDansLaPoule="4" NbVictoires="0" NbMatches="4" RangPoule="0"/>
    <Tireur REF="3" NoDansLaPoule="5" NbVictoires="0" NbMatches="4" RangPoule="0"/>
   </Poule>
  </TourDePoules>

Changing the avoid conflicts flag to "Club" changes the TourDePoules Attributes
Decalage="/club/"
  <TourDePoules PhaseID="2" ID="Round 1" ScoreMax="5" RepartitionEquilibre="1" Decalage="/club/" NbDePoules="1" PhaseSuivanteDesQualifies="3">

Belle Poule will either display by pools, or a list of fencers, in pool-fencer order, with the pool number displayed

Marking up one bout (bout 7) results in
Pool's Fencers are updated, if they were involved in a bout
NoDansLaPoule is their Pool idNum  REF is their competitionUid num
e.g.
<Tireur REF="1" NoDansLaPoule="1" NbVictoires="1" NbMatches="4" TD="5" TR="3" RangPoule="1"/>
The bouts are all added
Unscored bouts are added, with the two fencers identified by their competitionUid
e.g.
     <Match ID="1">
     <Tireur REF="1"/>
     <Tireur REF="2"/>
    </Match>
The two fencers involved in the bout have their results updated
e.g.
The two fencers are identified by their competition UID, NOT their number in the Pool
For the scored bout, scores and result are added as attributes.   Only the scored bout receives scores
e.g. 
    <Match ID="7">
     <Tireur REF="4" Score="3" Statut="D"/>
     <Tireur REF="1" Score="5" Statut="V"/>
    </Match>

One match is added for every one on the boutlist, in BP boutlist order


If you load in renamed versions of the earier status of the Competition .cotcot file, it happily accepts it.












NodeLists and HTMLCollections

If you use a selector, e.g. getElementsByTagName

it returns a HTMLCollection

This is (more or less) an array of items matching the selector.

What it makes really hard to do is access the children of the elements returned in the collection



e.g.

Tireurs
     Tireur tId="1"
     Tireur tId="2"
     etc


Actually, If they are all child nodes of a single element of an HTMLcollection, then simply 

TireursInASingleNode = xmlDoc.getElementsByTagName("Tireurs");

listOfFencers = TireursInASingleNode[0].getElementsByTagName("Tireur")
// get all the child elements of the 0th node in Tireurs







Monday, 9 October 2017

Details of the Belle Poule .cotcot file

It appears to be an FIE-standard XML file

Root tag CompetitionIndividuelle

Tag
CompetitionIndividuelle
Attrs
Couleur="#hhhhhh" Hex RGB code
ID="59d6f347"  <8 hexigits, as a string>
Annee="yyyy"
Arme="F" [or S or E, I'm guessing]
Sexe="FM" [I'm guessing the other options are "F" or "M"]
Categorie="M13" [for Moins de 13? - Under 13]
Niveau="X" [???]
Date="dd.mm.yyyy"
Appel="11:00"
Scratch="11:20"
Debut="11:30"
TitreLong="PaFF Trial 3"
URLorganisateur="http://paff.uk.to"
ScoreAleatoire="0"
TailleMinimaleEquipe="3"
ClassementDefautEquipe="9999"
ClassementManuel="0"
Lieu="Edinburgh"


FENCERS

Fencers ("Tireurs")
Statut
= Status

"F"
Entered, not checked-in
"Q"
Checked-in

Sexe
= Gender   "M" or "F"

Nom
= Surname (last name in the import file)

Prenom
=First Name

Equipe
= Team within a Club

DateNaissance
DoB, in the date format of BP's host

Nation
Ligue
Club
Categorie
Ranking  All set to "0"
Rating
Exporte  All set to "0"

Equipes

i.e. Teams - within clubs

Arbitres

Referees

Phases 

Attributes
PhaseEnCours="0"

Tags Within Phases

TourDePoules (Pools round)

PhaseID="2"
ID="Round #1" /* user input in Preferences */
ScoreMax="5"
RepartitionEquilibre="1"
PhaseSuivanteDesQualifies="3"

PhaseDeTableaux (DE)

PhaseId="3"
ID=""
ScoreMax="10"
PlaceTirees="0"

Classement General  (Final results?)

PhaseId="4"
ID="4"

</Phases>

So within phases, each round is set up (whether pools or DE) , and then the Final the Pools or DE is set up, then the final results

Questions: What happens when you change the Max Score for a round of Pools, after it has been previously set up?


Originally, test data was
Pools - 1 round
DE

And there was Pools PhaseId 2
DE Phase ID 3
Classification PhaseId 4

On deleting the DE table in BP, it was removed from the Phases, and the follwing Phases had their PhaseID decreased by 1

Adding a second round of pools to the formula forces teh pools for the first round of pools to be defined.

Getting the info by name from the whole document means that that I pick up the Tireur tags in TourDePoules and Poule as  well as in Tireur






Saturday, 7 October 2017

TrueSkill Calculator

Here is an implementation of TrueSkill in C#

This is the simplest implentation - 1 player versus one player

https://github.com/moserware/Skills/blob/master/Skills/TrueSkill/TwoPlayerTrueSkillCalculator.cs

Loading XML data into the browser

Implicit rules for XML


It requires an encoding defintition in the <xml> statement
To be loaded as a unity, it requires a top-level node - e.g. "catalog" in "books.xml"

The file suffix must be .xml
Re-naming a valid .xml file with a different suffix causes a null object to be returned.



That node

The XML file needs to be suffixed as .xml

The load process for a Belle Poule .cotcot file is currently

Save the .cotcot file into the appropriate /org/<org>/<competition>/[<event>/] folder in CK

How do you do that, when BP is storing locally, and CK is remote?


Copy the .cotcot file, changing its suffix to .xml

Load the .xml into the browser




On save, save as .xml

Copy the .xml file, and rename to <prevFileName>suffix.cotcot

Load into BP