|
364 | 364 | if (result.length === 1 || !result[1]) { |
365 | 365 | return label; |
366 | 366 | } |
367 | | - // xss-lint: disable=javascript-concat-html |
368 | | - return label + "<description>" + result[1] + "</description>\n"; |
| 367 | + |
| 368 | + return label + "<description>" + result[1] + "</description>\n"; // xss-lint: disable=javascript-concat-html |
369 | 369 | }); |
370 | 370 |
|
371 | 371 | // Pull out demand hints, || a hint || |
|
377 | 377 | for (i = 0; i < options.length; i += 1) { |
378 | 378 | inner = /\s*\|\|(.*?)\|\|/.exec(options[i]); |
379 | 379 | if (inner) { |
380 | | - // xss-lint: disable=javascript-concat-html |
381 | | - demandhints += " <hint>" + inner[1].trim() + "</hint>\n"; |
| 380 | + demandhints += " <hint>" + inner[1].trim() + "</hint>\n"; // xss-lint: disable=javascript-concat-html |
382 | 381 | } |
383 | 382 | } |
384 | 383 | return ""; |
|
461 | 460 | optiontag += correct[1]; |
462 | 461 | } |
463 | 462 | optiontag += '">'; |
464 | | - // xss-lint: disable=javascript-concat-html |
465 | | - return "\n<optionresponse>\n" + optiontag + "</optioninput>\n</optionresponse>\n\n"; |
| 463 | + |
| 464 | + return "\n<optionresponse>\n" + optiontag + "</optioninput>\n</optionresponse>\n\n"; // xss-lint: disable=javascript-concat-html |
466 | 465 | } |
467 | 466 |
|
468 | 467 | // new style [[ many-lines ]] |
|
482 | 481 | if (label) { |
483 | 482 | label = ' label="' + label + '"'; |
484 | 483 | } |
485 | | - // xss-lint: disable=javascript-concat-html |
486 | | - hintstr = " <optionhint" + label + ">" + textHint.hint + "</optionhint>"; |
| 484 | + |
| 485 | + hintstr = " <optionhint" + label + ">" + textHint.hint + "</optionhint>"; // xss-lint: disable=javascript-concat-html |
487 | 486 | } |
488 | | - // xss-lint: disable=javascript-concat-html |
489 | | - optionlines += " <option" + correctstr + ">" + textHint.nothint + hintstr + "</option>\n"; |
| 487 | + |
| 488 | + optionlines += " <option" + correctstr + ">" + textHint.nothint + hintstr + "</option>\n"; // xss-lint: disable=javascript-concat-html |
490 | 489 | } |
491 | 490 | } |
492 | | - // xss-lint: disable=javascript-concat-html |
493 | | - return "\n<optionresponse>\n <optioninput>\n" + optionlines + " </optioninput>\n</optionresponse>\n\n"; |
| 491 | + |
| 492 | + return "\n<optionresponse>\n <optioninput>\n" + optionlines + " </optioninput>\n</optionresponse>\n\n"; // xss-lint: disable=javascript-concat-html |
494 | 493 | }); |
495 | 494 |
|
496 | 495 | // multiple choice questions |
|
525 | 524 | hint = extractHint(value); |
526 | 525 | if (hint.hint) { |
527 | 526 | value = hint.nothint; |
528 | | - // xss-lint: disable=javascript-concat-html |
529 | | - value = value + " <choicehint" + hint.labelassign + ">" + hint.hint + "</choicehint>"; |
| 527 | + |
| 528 | + value = value + " <choicehint" + hint.labelassign + ">" + hint.hint + "</choicehint>"; // xss-lint: disable=javascript-concat-html |
530 | 529 | } |
531 | | - // xss-lint: disable=javascript-concat-html |
532 | | - choices += ' <choice correct="' + correct + '"' + fixed + ">" + value + "</choice>\n"; |
| 530 | + |
| 531 | + choices += ' <choice correct="' + correct + '"' + fixed + ">" + value + "</choice>\n"; // xss-lint: disable=javascript-concat-html |
533 | 532 | } |
534 | 533 | } |
535 | 534 | result = "<multiplechoiceresponse>\n"; |
|
572 | 571 | // lone case of hint text processing outside of extractHint, since syntax here is unique |
573 | 572 | hintbody = abhint[2]; |
574 | 573 | hintbody = hintbody.replace("&lf;", "\n").trim(); |
575 | | - // xss-lint: disable=javascript-concat-html |
576 | | - endHints += ' <compoundhint value="' + abhint[1].trim() + '">' + hintbody + "</compoundhint>\n"; |
| 574 | + |
| 575 | + endHints += ' <compoundhint value="' + abhint[1].trim() + '">' + hintbody + "</compoundhint>\n"; // xss-lint: disable=javascript-concat-html |
577 | 576 | // eslint-disable-next-line no-continue |
578 | 577 | continue; // bail |
579 | 578 | } |
|
595 | 594 | // checkbox choicehints get their own line, since there can be two of them |
596 | 595 | // <choicehint selected="true">You’re right that apple is a fruit.</choicehint> |
597 | 596 | if (select) { |
598 | | - // xss-lint: disable=javascript-concat-html |
599 | | - hints += '\n <choicehint selected="true">' + select[2].trim() + "</choicehint>"; |
| 597 | + hints += '\n <choicehint selected="true">' + select[2].trim() + "</choicehint>"; // xss-lint: disable=javascript-concat-html |
600 | 598 | } |
601 | 599 | select = /{\s*(u|unselected):((.|\n)*?)}/i.exec(inner); |
602 | 600 | if (select) { |
603 | | - // xss-lint: disable=javascript-concat-html |
604 | | - hints += '\n <choicehint selected="false">' + select[2].trim() + "</choicehint>"; |
| 601 | + hints += '\n <choicehint selected="false">' + select[2].trim() + "</choicehint>"; // xss-lint: disable=javascript-concat-html |
605 | 602 | } |
606 | 603 |
|
607 | 604 | // Blank out the original text only if the specific "selected" syntax is found |
|
610 | 607 | value = hint.nothint; |
611 | 608 | } |
612 | 609 | } |
613 | | - // xss-lint: disable=javascript-concat-html |
614 | | - groupString += ' <choice correct="' + correct + '">' + value + hints + "</choice>\n"; |
| 610 | + |
| 611 | + groupString += ' <choice correct="' + correct + '">' + value + hints + "</choice>\n"; // xss-lint: disable=javascript-concat-html |
615 | 612 | } |
616 | 613 | } |
617 | 614 |
|
|
676 | 673 | hintLine = ""; |
677 | 674 | if (textHint.hint) { |
678 | 675 | firstAnswer = textHint.nothint; |
679 | | - // xss-lint: disable=javascript-concat-html |
680 | | - hintLine = " <correcthint" + textHint.labelassign + ">" + textHint.hint + "</correcthint>\n"; |
| 676 | + |
| 677 | + hintLine = " <correcthint" + textHint.labelassign + ">" + textHint.hint + "</correcthint>\n"; // xss-lint: disable=javascript-concat-html |
681 | 678 | } |
682 | 679 |
|
683 | 680 | // Range case |
684 | 681 | if (isRangeToleranceCase(firstAnswer)) { |
685 | 682 | // [5, 7) or (5, 7), or (1.2345 * (2+3), 7*4 ] - range tolerance case |
686 | 683 | // = (5*2)*3 should not be used as range tolerance |
687 | | - // xss-lint: disable=javascript-concat-html |
688 | | - numericalResponseString = '<numericalresponse answer="' + firstAnswer + '">\n'; |
| 684 | + |
| 685 | + numericalResponseString = '<numericalresponse answer="' + firstAnswer + '">\n'; // xss-lint: disable=javascript-concat-html |
689 | 686 | } else { |
690 | 687 | answerData = getAnswerData(firstAnswer); |
691 | | - // xss-lint: disable=javascript-concat-html |
692 | | - numericalResponseString = '<numericalresponse answer="' + answerData.answer + '">\n'; |
| 688 | + |
| 689 | + numericalResponseString = '<numericalresponse answer="' + answerData.answer + '">\n'; // xss-lint: disable=javascript-concat-html |
693 | 690 | if (answerData.default) { |
694 | | - // xss-lint: disable=javascript-concat-html |
695 | 691 | numericalResponseString += |
696 | | - ' <responseparam type="tolerance" default="' + answerData.default + '" />\n'; |
| 692 | + ' <responseparam type="tolerance" default="' + answerData.default + '" />\n'; // xss-lint: disable=javascript-concat-html |
697 | 693 | } |
698 | 694 | } |
699 | 695 |
|
|
715 | 711 | } |
716 | 712 |
|
717 | 713 | if (additionalTextHint.hint) { |
718 | | - // xss-lint: disable=javascript-concat-html |
719 | 714 | additionalHintLine = |
720 | | - "<correcthint" + |
721 | | - additionalTextHint.labelassign + |
722 | | - ">" + |
723 | | - additionalTextHint.hint + |
724 | | - "</correcthint>"; |
| 715 | + "<correcthint" + // xss-lint: disable=javascript-concat-html |
| 716 | + additionalTextHint.labelassign + // xss-lint: disable=javascript-concat-html |
| 717 | + ">" + // xss-lint: disable=javascript-concat-html |
| 718 | + additionalTextHint.hint + // xss-lint: disable=javascript-concat-html |
| 719 | + "</correcthint>"; // xss-lint: disable=javascript-concat-html |
725 | 720 | } |
726 | 721 |
|
727 | | - // xss-lint: disable=javascript-concat-html |
728 | | - additionalAnswerString += ' <additional_answer answer="' + orMatch[1] + '">'; |
| 722 | + additionalAnswerString += ' <additional_answer answer="' + orMatch[1] + '">'; // xss-lint: disable=javascript-concat-html |
729 | 723 | additionalAnswerString += additionalHintLine; |
730 | 724 | additionalAnswerString += "</additional_answer>\n"; |
731 | 725 | } |
|
755 | 749 | typ = ' type="ci regexp"'; |
756 | 750 | firstAnswer = firstAnswer.slice(1).trim(); |
757 | 751 | } |
758 | | - // xss-lint: disable=javascript-concat-html |
759 | | - string = '<stringresponse answer="' + firstAnswer + '"' + typ + " >\n"; |
| 752 | + |
| 753 | + string = '<stringresponse answer="' + firstAnswer + '"' + typ + " >\n"; // xss-lint: disable=javascript-concat-html |
760 | 754 | if (textHint.hint) { |
761 | | - // xss-lint: disable=javascript-concat-html |
762 | 755 | string += " <correcthint" + textHint.labelassign + ">" + textHint.hint + "</correcthint>\n"; // xss-lint: disable=javascript-concat-html |
763 | 756 | } |
764 | 757 |
|
|
767 | 760 | textHint = extractHint(values[i]); |
768 | 761 | notMatch = /^not\=\s*(.*)/.exec(textHint.nothint); |
769 | 762 | if (notMatch) { |
770 | | - // xss-lint: disable=javascript-concat-html |
771 | 763 | string += |
772 | | - ' <stringequalhint answer="' + |
773 | | - notMatch[1] + |
774 | | - '"' + |
775 | | - textHint.labelassign + |
776 | | - ">" + |
777 | | - textHint.hint + |
778 | | - "</stringequalhint>\n"; |
| 764 | + ' <stringequalhint answer="' + // xss-lint: disable=javascript-concat-html |
| 765 | + notMatch[1] + // xss-lint: disable=javascript-concat-html |
| 766 | + '"' + // xss-lint: disable=javascript-concat-html |
| 767 | + textHint.labelassign + // xss-lint: disable=javascript-concat-html |
| 768 | + ">" + // xss-lint: disable=javascript-concat-html |
| 769 | + textHint.hint + // xss-lint: disable=javascript-concat-html |
| 770 | + "</stringequalhint>\n"; // xss-lint: disable=javascript-concat-html |
779 | 771 |
|
780 | 772 | // eslint-disable-next-line no-continue |
781 | 773 | continue; |
782 | 774 | } |
783 | 775 | orMatch = /^or\=\s*(.*)/.exec(textHint.nothint); |
784 | 776 | if (orMatch) { |
785 | 777 | // additional_answer with answer= attribute |
786 | | - // xss-lint: disable=javascript-concat-html |
787 | | - string += ' <additional_answer answer="' + orMatch[1] + '">'; |
| 778 | + |
| 779 | + string += ' <additional_answer answer="' + orMatch[1] + '">'; // xss-lint: disable=javascript-concat-html |
788 | 780 | if (textHint.hint) { |
789 | | - // xss-lint: disable=javascript-concat-html |
790 | | - string += "<correcthint" + textHint.labelassign + ">" + textHint.hint + "</correcthint>"; |
| 781 | + string += "<correcthint" + textHint.labelassign + ">" + textHint.hint + "</correcthint>"; // xss-lint: disable=javascript-concat-html |
791 | 782 | } |
792 | 783 | string += "</additional_answer>\n"; |
793 | 784 | } |
|
803 | 794 |
|
804 | 795 | // replace explanations |
805 | 796 | xml = xml.replace(/\[explanation\]\n?([^\]]*)\[\/?explanation\]/gim, function (match, p1) { |
806 | | - // xss-lint: disable=javascript-concat-html |
807 | 797 | return ( |
808 | | - '<solution>\n<div class="detailed-solution">\n' + |
| 798 | + '<solution>\n<div class="detailed-solution">\n' + // xss-lint: disable=javascript-concat-html |
809 | 799 | gettext("Explanation") + |
810 | | - "\n\n" + |
811 | | - p1 + |
| 800 | + "\n\n" + // xss-lint: disable=javascript-concat-html |
| 801 | + p1 + // xss-lint: disable=javascript-concat-html |
812 | 802 | "\n</div>\n</solution>" |
813 | 803 | ); |
814 | 804 | }); |
815 | 805 |
|
816 | 806 | // replace code blocks |
817 | 807 | xml = xml.replace(/\[code\]\n?([^\]]*)\[\/?code\]/gim, function (match, p1) { |
818 | | - // xss-lint: disable=javascript-concat-html |
819 | | - return "<pre><code>" + p1 + "</code></pre>"; |
| 808 | + return "<pre><code>" + p1 + "</code></pre>"; // xss-lint: disable=javascript-concat-html |
820 | 809 | }); |
821 | 810 |
|
822 | 811 | // split scripts and preformatted sections, and wrap paragraphs |
823 | | - splits = xml.split(/(\<\/?(?:script|pre|label|description).*?\>)/g); |
| 812 | + splits = xml.split(/(<\/?(?:script|pre|label|description)[^>]*>)/gi); |
824 | 813 |
|
825 | 814 | // Wrap a string by <p> tag when line is not already wrapped by another tag |
826 | 815 | // true when line is not already wrapped by another tag false otherwise |
|
854 | 843 | responseTypesSelector = responseTypes.join(", "); |
855 | 844 |
|
856 | 845 | // make temporary xml |
857 | | - // xss-lint: disable=javascript-concat-html |
858 | | - $xml = $($.parseXML("<prob>" + xml + "</prob>")); |
| 846 | + |
| 847 | + $xml = $($.parseXML("<prob>" + xml + "</prob>")); // xss-lint: disable=javascript-concat-html |
859 | 848 | responseType = $xml.find(responseTypesSelector); |
860 | 849 |
|
861 | 850 | // convert if there is only one responsetype |
|
903 | 892 | }); |
904 | 893 | finalDemandHints = ""; |
905 | 894 | if (demandHintTags.length) { |
906 | | - // xss-lint: disable=javascript-concat-html |
907 | | - finalDemandHints = "\n<demandhint>\n" + demandHintTags.join("") + "</demandhint>"; |
| 895 | + finalDemandHints = "\n<demandhint>\n" + demandHintTags.join("") + "</demandhint>"; // xss-lint: disable=javascript-concat-html |
908 | 896 | } |
909 | 897 | // make all responsetypes descendants of a single problem element |
910 | | - // xss-lint: disable=javascript-concat-html |
911 | | - finalXml = "<problem>\n" + responseTypesXML.join("\n\n") + finalDemandHints + "\n</problem>"; |
| 898 | + |
| 899 | + finalXml = "<problem>\n" + responseTypesXML.join("\n\n") + finalDemandHints + "\n</problem>"; // xss-lint: disable=javascript-concat-html |
912 | 900 | return finalXml; |
913 | 901 | }; |
914 | 902 |
|
|
0 commit comments