Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Ranking Question Display change

  • nandan
  • nandan's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
9 years 11 months ago #120722 by nandan
Replied by nandan on topic Ranking Question Display change
Again, sorry for the late reply and thanks a lot for the code. I shall be getting some of my coders to have a look at this.
The topic has been locked.
  • AlessandraAndreotti
  • AlessandraAndreotti's Avatar
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago #168662 by AlessandraAndreotti
Replied by AlessandraAndreotti on topic Ranking Question Display change
Dear Tony,
I have the same problem.
I'm using LimeSurvey version 2.54.1 and a copy of the default template.
I've followed your instructions but it doesn't work.

One note:
you said "You can overwrite the core updateDragDropRank() function in template.js and insert the ranked numbers"
but in the template.js I haven't the updateDragDropRank() function.
What am I doing wrong?

Thanks in advance for your help.
Best,
Alessandra
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #168691 by Joffm
Replied by Joffm on topic Ranking Question Display change
Hi, Alessandra,
just an explanation why it might not work.
nandan worked with LS version 2.05/2.06 and template "Skeleton Quest"

You work with version 2.54 with a totally different template structure.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • AlessandraAndreotti
  • AlessandraAndreotti's Avatar
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago - 6 years 11 months ago #168695 by AlessandraAndreotti
Replied by AlessandraAndreotti on topic Ranking Question Display change
Hi Joffm,
thank you very much for the explanation.

Do you have any idea on how it can be done with the default template?

Thank you in advance.
Best,
Alessandra
Last edit: 6 years 11 months ago by AlessandraAndreotti.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #168698 by Joffm
Replied by Joffm on topic Ranking Question Display change
Hi, Alessandra,

unfortunately no; otherwise I'd provided it.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: AlessandraAndreotti
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago - 6 years 11 months ago #168710 by tpartner
Replied by tpartner on topic Ranking Question Display change

One note:
you said "You can overwrite the core updateDragDropRank() function in template.js and insert the ranked numbers"
but in the template.js I haven't the updateDragDropRank() function.
What am I doing wrong?

Yes, you need to place a copy of that function in your template.js file. It will override the core function.

Place this in template.js:

Code:
function updateDragDropRank(qID){
  var maxanswers= parseInt($("#ranking-"+qID+"-maxans").text().trim(),10);
  var rankingname= "javatbd"+$("#ranking-"+qID+"-name").text().trim();
  var relevancename= "relevance"+$("#ranking-"+qID+"-name").text().trim();
  var rankingnamewidth=rankingname.length;
  $('#question'+qID+' .select-item select').val('');
  $('#sortable-rank-'+qID+' li').each(function(index) {
    // Get value of ranked item
    var liID = $(this).attr("id");
    liValue = liID.substr(rankingnamewidth);
    $('#question'+qID+' .select-item select').eq(index).val(liValue);
  });
  // Update #relevance and lauch checkconditions function
  $("[id^=" + relevancename + "]").val('0');
  $('#question'+qID+' .select-item select:lt('+maxanswers+')').each(function(index){
    number=index+1;
    if($(this).val()!="")
    {
      $("#"+relevancename+number).val("1");
    }
    $(this).trigger("change",{ source : 'dragdrop'});
  });
  $('#sortable-rank-'+qID+' li').removeClass("error");
  $('#sortable-choice-'+qID+' li').removeClass("error");
  $('#sortable-rank-'+qID+' li:gt('+(maxanswers*1-1)+')').addClass("error");
 
  // Numbers for ranked items
  $('#question'+qID+' .rank-number').remove();
  $('#question'+qID+' .dragDropRankList li').each(function(i) {
    $(this).prepend('<span class="rank-number">'+(i+1)+':</span>');
  });
}

Place something like this in template.css:

Code:
.rank-number {
  display: inline-block;
  margin-right: 5px;
  color: #FF0000;
}


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 11 months ago by tpartner.
The topic has been locked.
  • AlessandraAndreotti
  • AlessandraAndreotti's Avatar
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago - 6 years 11 months ago #168717 by AlessandraAndreotti
Replied by AlessandraAndreotti on topic Ranking Question Display change
Hi Tony!
Thanks for your suggestions.
I've followed your instructions but it still doesn't work. :(
At the end of the "scripts/template.js" of my template, I've inserted the script you suggested.
Then, at the end of the "css/template.css" of my template I've inserted this script (as you suggested):

.rank-number {
display: inline-block;
margin-right: 5px;
color: #FF0000;
}


This is what I have:

In attachment an example for test.
What am I doing wrong?

Thanks in advance for your help.

Alessandra
Last edit: 6 years 11 months ago by AlessandraAndreotti.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #168729 by tpartner
Replied by tpartner on topic Ranking Question Display change
Can you please activate a test survey and give us a link here so we can see the source HTML?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • AlessandraAndreotti
  • AlessandraAndreotti's Avatar
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago #168731 by AlessandraAndreotti
Replied by AlessandraAndreotti on topic Ranking Question Display change
Sure!

That is the link: sondaggi.centroexplora.it/index.php/649854?lang=en

Thank you very much!
Alessandra
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #168733 by tpartner
Replied by tpartner on topic Ranking Question Display change
The problem is that your template.js file is being loaded before ranking.js (first screenshot below). It should be loaded last, as on my server (second screenshot below).

The assets manager may be causing that. Try setting debug to 1 in application/config/config.php. This should load the template files directly instead of from /tmp/assets.




Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: AlessandraAndreotti
The topic has been locked.
  • AlessandraAndreotti
  • AlessandraAndreotti's Avatar
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago #168797 by AlessandraAndreotti
Replied by AlessandraAndreotti on topic Ranking Question Display change
Hi Tony,
I've tried your suggestion (set debug to 1 in application/config/config.php) and now it works!!! :woohoo:
Thank you very much.
Best,
Alessandra
The topic has been locked.
More
5 years 2 weeks ago #198173 by dnvservices
Replied by dnvservices on topic Ranking Question Display change
If possible, could you please share a template lsq that you have figured out? Thank you.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose