Widget:Quiz Multiple Choice

Infrastructure for building an eXe-like multiple choice quiz  $(function { $('head').append(' ' + 'div.weQuiz { border-style: solid; border-width: 1px;' + 'border-color: #AAAAAA; padding: 1ex; background-color: #F6F9ED; }' + 'ul.weQquestion { list-style-type: decimal; list-style-image: none; margin-left: 75px;}' + 'ul.weQoption { list-style-type: none; list-style-image: none;}' + 'ul.weQresponse { list-style-type: none; list-style-image: none; display: none; }' + 'img.weQuiz { float: left; }' + 'h1.weQuiz {font-size: 130%; font-weight: bold; border: none; }' + ' '); var qn = 'q' + ;  var mix = ;  var rand = ],[;  var $q = $('#' + qn);  $q.children('ul')    .addClass('weQquestion').wrap('  ')    .children('li').addClass('weQquestion')    .children('ul').addClass('weQoption')    .children('li').addClass('weQoption')    .children('ul').addClass('weQresponse')    .children('li').addClass('weQresponse');  $qs = $('li.weQquestion', $q);  // for each of the questions  if (mix == 'true'){     for (var i=0; i<$qs.length; ++i) {       rand.push([]);       $('li.weQoption', $qs[i]).each(function(ix) { var nqn = qn + '_' + i;        rand[i][ix]='' + $(this).html + ' '; });    }    for (var i=0; i<$qs.length; ++i) {       rand[i].sort(function{return Math.random - 0.5});       $('li.weQoption', $qs[i]).each(function(iy) { $(this).replaceWith(rand[i][iy]); });    }  } else {    for (var i=0; i<$qs.length; ++i) {      $('li.weQoption', $qs[i]).each(function(ix) { var nqn = qn + '_' + i;       $(this).replaceWith('' + $(this).html + ' '); });    }  }  $('li.weQoption', $q).click(function { $(this).find('ul').show('fast'); }); });