If you haven't already, start by getting "Not Applicable: Per Variable" from the Community Question Library and replace its footer with this modified script:
<style>
#[% QuestionName() %]_div {
display: none;
}
.error_quest_highlight2 {
border: 1px solid red !important;
}
</style>
<script>
var GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS = {
questionName: '',
notApplicableLabel: 'N/A',
checkboxMinimumChecks: 0, // If the question uses checkboxes, this can be updated with the minimum number of checks a respondent must respond with.
errorMessage: 'Question must be answered or "Not Applicable" must be selected.'
};
$(document).ready(function(){
// Icons
var icons = {
empty: 'fa-star',
half: 'fa-star-half',
full: 'fa-star'
};
// Question, list
if (!GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.questionName) {
GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.questionName = $('#[% QuestionName() %]_div').prevAll('.question')[0].id.replace(/_div/, '');
}
var question = GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.questionName;
var qdiv = $('#' + question + '_div');
var list = $('input[name=hid_list_[% QuestionName() %]]').val().split(',').map(Number);
// Move checkboxes
$('#[% QuestionName() %]_div .mobile_select').removeClass('mobile_select');
$('#[% QuestionName() %]_div .response_row').css('text-align', 'center');
$('#[% QuestionName() %]_div .input_cell').css('display', 'inline-block');
$('#[% QuestionName() %]_div .option_cell').css('display', 'inline-block');
GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.grid = SSI_GetGridQuestionSettings(question);
if (!GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.grid.mobile) {
$('#[% QuestionName() %]_div .option_cell').remove();
if (GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.grid.orientation == 'row') {
$('#' + question + '_div .column_header_row').append('<td>' + GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.notApplicableLabel + '</td>');
$('#' + question + '_div .inner_table > tbody > tr:first-child > td:last-child').css('text-align', 'center');
list.forEach(function(item){
$('#' + question + '_r' + item + '_row').append('<td></td>');
$('#' + question + '_r' + item + '_row > td:last-child').append($('#[% QuestionName() %]_' + item).closest('.response_row'));
});
}
else {
$('#' + question + '_div .inner_table > tbody').append('<tr><td>' + GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.notApplicableLabel +'</td></tr>');
$('#' + question + '_div .inner_table > tbody > tr:last-child > td').css('text-align', 'right');
list.forEach(function(item){
$('#' + question + '_div .inner_table > tbody > tr:last-child').append('<td></td');
$('#' + question + '_div .inner_table > tbody > tr:last-child > td:last-child').append($('#[% QuestionName() %]_' + item).closest('.response_row'));
});
}
fixGridAltColors(question);
}
else {
$('#[% QuestionName() %]_div .option_cell label').text(GLOBAL_SAWTOOTH_[% QuestionName() %]_SETTINGS.notApplicableLabel);
list.forEach(function(item){
$('#' + question + '_div .mobile_grid_card[data-card_num=' + item + ']').append($('#[% QuestionName() %]_' + item).closest('.response_row'));
});
}
// N/A click event
var runNotApplicable = function(){
var columns = $('input[name="hid_col_list_' + question + '"]').val().split(',');
list.forEach(function(item){
if (SSI_GetValue('[% QuestionName() %]_' + item)) {
var input = $('#' + question + '_r' + item + '_c' + columns[0]);
$(input).val('');
updateStars(question, item, 0, icons);
var starsContainer = $(input).siblings('.starsContainer');
$(starsContainer).css('position', 'relative');
$(starsContainer).find('.star').css('opacity', .5);
var overlay = $('<div class="starOverlay"></div>');
$(overlay).css('position', 'absolute').css('top', 0).css('left', 0).css('height', '100%').css('width', '100%').css('z-index', 9999);
$(overlay).click(function(e){
e.stopPropagation();
});
$(starsContainer).append($(overlay));
}
else {
var starsContainer = $('#' + question + '_r' + item + '_c' + columns[0]).siblings('.starsContainer');
$(starsContainer).find('.star').css('opacity', 1);
$(starsContainer).find('.starOverlay').remove();
}
});
}
$(document).on('lighthouseCheckboxChanged', runNotApplicable);
runNotApplicable();
})
function fixGridAltColors(question) {
if (!$('#' + question + '_div .mobile_grid').length) {
var firstCellIsAltColor1 = $('#' + question + '_div .inner_table > tbody > tr:first-child > td:nth-child(1)').hasClass('alt_color1');
var secondCellIsAltColor1 = $('#' + question + '_div .inner_table > tbody > tr:first-child > td:nth-child(1)').hasClass('alt_color1');
var primaryAltColor = firstCellIsAltColor1 ? 'alt_color1' : 'alt_color2';
var secondaryAltColor = firstCellIsAltColor1 ? 'alt_color2' : 'alt_color1';
if (firstCellIsAltColor1 == secondCellIsAltColor1) {
$('#' + question + '_div .inner_table > tbody > tr:even > td').removeClass(secondaryAltColor).addClass(primaryAltColor);
$('#' + question + '_div .inner_table > tbody > tr:odd > td').removeClass(primaryAltColor).addClass(secondaryAltColor);
}
else {
$('#' + question + '_div .inner_table > tbody > tr > td:even').removeClass(secondaryAltColor).addClass(primaryAltColor);
$('#' + question + '_div .inner_table > tbody > tr > td:odd').removeClass(primaryAltColor).addClass(secondaryAltColor);
}
}
}
</script>
Lines 22-24 should be updated with icon information in the stars question.
Note that this question also requires "Better Lighthouse Library" from the Community Question Library as well.