Skip to content

Commit

Permalink
Dev: first part for #6451 : give the id of the answers element accord…
Browse files Browse the repository at this point in the history
…ing to Expression Manager
  • Loading branch information
Shnoulle committed Aug 13, 2012
1 parent 4327ce3 commit 231e2a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions application/helpers/qanda_helper.php
Expand Up @@ -2162,6 +2162,7 @@ function do_ranking($ia)
$answer .="</ul>"
. "<div style='display:none' id='ranking-{$ia[0]}-maxans'>{".$max_answers."}</div>"
. "<div style='display:none' id='ranking-{$ia[0]}-minans'>{".$min_answers."}</div>"
. "<div style='display:none' id='ranking-{$ia[0]}-name'>javatb".$myfname."</div>"
. "</div>";
// The list with HTML answres
$answer .="<div style=\"display:none\">";
Expand Down
20 changes: 11 additions & 9 deletions 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
Expand Down Expand Up @@ -39,15 +41,15 @@ if (typeof samelistheight === 'undefined'){samelistheight=true;}
if($(this).val()!=''){
ranked.push($(this).val());
htmloption=$("#htmlblock-"+qID+'-'+$(this).val()).html();
var liCode = '<li class="ui-state-default choice" id="choice_'+$(this).val()+'">' + htmloption + '</li>'
var liCode = '<li class="ui-state-default choice" id="'+rankingname+$(this).val()+'">' + htmloption + '</li>'
$(liCode).appendTo('#sortable-rank-'+qID+'');
}
});
$('#question'+qID+' .answers-list .select-item:first option').each(function(index, Element) {
var thisvalue=$(this).val();
if(thisvalue!='' && jQuery.inArray(thisvalue,ranked)<0){
htmloption=$("#htmlblock-"+qID+'-'+$(this).val()).html();
var liCode = '<li class="ui-state-default choice" id="choice_'+$(this).val()+'">' + htmloption + '</li>'
var liCode = '<li class="ui-state-default choice" id="'+rankingname+$(this).val()+'">' + htmloption + '</li>'
$(liCode).appendTo('#sortable-choice-'+qID+'');
}
});
Expand Down Expand Up @@ -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');
Expand All @@ -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");
Expand Down

0 comments on commit 231e2a1

Please sign in to comment.