Upgrade from 1.0.x or 1.1.x to 1.2.x

Bug fix

After the bug https://issues.ametys.org/browse/SURVEY-44, fixed for 1.2.x versions, execute the following script (in repository console) to migrate your data :

var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:survey-option)", javax.jcr.query.Query.XPATH);

var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
    var optNode = nodes.next();
    var name = optNode.getName().substring(7);
    if (name.indexOf("opt-") != 0)
      var escapedName = org.ametys.cms.FilterNameHelper.filterName("opt-" + name);
      optNode.getSession().move(optNode.getPath(), optNode.getParent().getPath() + "/ametys:" + escapedName);
println (count + " options have been renamed");

NB: This script renames all jcr nodes representing an option of a multiple or single choice in a survey to avoid space or special caracters. For exemple, all options named like "ametys:First choice" will be renamed to "ametys:opt-first-choice"


Note that after this operation you will loose the preceding statistics on single choice, multiple choice or matrix question. Indeed, the given answers stored in database for statistics will be now incoherent with the survey data.
For exemple, a visitor who has answered "First choice" to a single choice question, has inserted the following line in SESSION_ANSWERS sql table

5question1First choice
However the excepted line is now :