From 231e2a161d44a5ab0a2a3cb5068aeecacbfed4a7 Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Mon, 13 Aug 2012 19:02:14 +0200 Subject: [PATCH] Dev: first part for #6451 : give the id of the answers element according to Expression Manager --- application/helpers/qanda_helper.php | 1 + scripts/ranking.js | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index d1bd3aff3d1..231d769e689 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -2162,6 +2162,7 @@ function do_ranking($ia) $answer .="" . "" . "" + . "" . ""; // The list with HTML answres $answer .="
"; diff --git a/scripts/ranking.js b/scripts/ranking.js index 7400e6f4200..fa28ad61f52 100644 --- a/scripts/ranking.js +++ b/scripts/ranking.js @@ -1,9 +1,11 @@ function doDragDropRank(qID, showpopups, samechoiceheight, samelistheight) { // TODO : advanced setting in attributes -if (typeof showpopups === 'undefined'){showpopups=true;} -if (typeof samechoiceheight === 'undefined'){samechoiceheight=true;} -if (typeof samelistheight === 'undefined'){samelistheight=true;} - maxanswers= parseInt($("#ranking-"+qID+"-maxans").text(),10); + if (typeof showpopups === 'undefined'){showpopups=true;} + if (typeof samechoiceheight === 'undefined'){samechoiceheight=true;} + if (typeof samelistheight === 'undefined'){samelistheight=true;} + maxanswers= parseInt($("#ranking-"+qID+"-maxans").text(),10); + rankingname= $("#ranking-"+qID+"-name").text(); + rankingnamewidth=rankingname.length; //Add a class to the question $('#question'+qID+'').addClass('dragDropRanking'); // Hide the default answers list @@ -39,7 +41,7 @@ if (typeof samelistheight === 'undefined'){samelistheight=true;} if($(this).val()!=''){ ranked.push($(this).val()); htmloption=$("#htmlblock-"+qID+'-'+$(this).val()).html(); - var liCode = '
  • ' + htmloption + '
  • ' + var liCode = '
  • ' + htmloption + '
  • ' $(liCode).appendTo('#sortable-rank-'+qID+''); } }); @@ -47,7 +49,7 @@ if (typeof samelistheight === 'undefined'){samelistheight=true;} var thisvalue=$(this).val(); if(thisvalue!='' && jQuery.inArray(thisvalue,ranked)<0){ htmloption=$("#htmlblock-"+qID+'-'+$(this).val()).html(); - var liCode = '
  • ' + htmloption + '
  • ' + var liCode = '
  • ' + htmloption + '
  • ' $(liCode).appendTo('#sortable-choice-'+qID+''); } }); @@ -103,8 +105,8 @@ function updateDragDropRank(qID){ $('#sortable-rank-'+qID+' li').each(function(index) { // Get value of ranked item var liID = $(this).attr("id"); - liIDArray = liID.split('_'); - $('#question'+qID+' .select-item select').eq(index).val(liIDArray[1]); + liValue = liID.substr(rankingnamewidth); + $('#question'+qID+' .select-item select').eq(index).val(liValue); }); $('#question'+qID+' .select-item select').each(function(){ checkconditions($(this).val(),$(this).attr("name"),'select-one','onchange'); @@ -124,7 +126,7 @@ function sortableAlert (qID,showpopups) function loadDragDropRank(qID){ $('#question'+qID+' .select-item select').each(function(){ if($(this).val()!=''){ - $('#sortable-choice-'+qID+' li#choice_'+$(this).val()).appendTo('#sortable-rank-'+qID); + $('#sortable-choice-'+qID+' li#'+rankingname+$(this).val()).appendTo('#sortable-rank-'+qID); } }); $('#sortable-rank-'+qID+' li').removeClass("error");