var studyIds = '8yadFPpU BJy6fEDf Rg2cMBZ6 fE4k21MW 8yadFPpU PDkQDt6u 96Lij7wH 9ogFv8Ac xebrDvFe A4ujYOer'.split(' ');

// from 4r1qk/5p1p/pp2rPpR/2pbP1Q1/3pR3/2P5/P5PP/2B3K1 w - - 2 28
// to   4r1qk/5p1p/pp2rPpR/2pbP1Q1/3pR3/2P5/P5PP/2B3K1 w - - 0 1
function fixFen(fen) {
  var parts = fen.split(' ');
  parts[4] = '0';
  parts[5] = '1';
  return parts.join(' ');
}

var chapters = db.study_chapter.find({
  studyId: {
    $in: studyIds
  }
}).forEach(function(chapter) {

  var fen = chapter.root.f;
  var fixed = fixFen(fen);
  if (fixed != fen) {
    print('Fix chapter ' + chapter._id + ': ' + fixed);
    db.study_chapter.update({
      _id: chapter._id
    }, {
      $set: {
        'root.f': fixed
      }
    });
  }
});

@@ -568,16 +568,20 @@
 chapter 
+FEN 
 ' + chap
@@ -725,12 +725,218 @@
 %7D);%0A  %7D%0A
+  if (chapter.root.p != 0) %7B%0A    print('Fix chapter root ply ' + chapter._id);%0A    db.study_chapter.update(%7B%0A      _id: chapter._id%0A    %7D, %7B%0A      $set: %7B%0A        'root.p': NumberInt(0)%0A      %7D%0A    %7D);%0A  %7D%0A
 %7D);%0A

fix practice chapter initial ply - closes #2593