Index: lams_central/src/java/org/lamsfoundation/lams/web/qb/PrintQuestionsController.java =================================================================== diff -u -rc2b79a48e116ee67d7de18bfb4b793fda02b58e7 -ra2ba5772ecb96d0d5436043ba0da03b6b1a5cdc2 --- lams_central/src/java/org/lamsfoundation/lams/web/qb/PrintQuestionsController.java (.../PrintQuestionsController.java) (revision c2b79a48e116ee67d7de18bfb4b793fda02b58e7) +++ lams_central/src/java/org/lamsfoundation/lams/web/qb/PrintQuestionsController.java (.../PrintQuestionsController.java) (revision a2ba5772ecb96d0d5436043ba0da03b6b1a5cdc2) @@ -1,13 +1,19 @@ package org.lamsfoundation.lams.web.qb; -import org.lamsfoundation.lams.util.imgscalr.Scalr; +import org.lamsfoundation.lams.qb.model.QbOption; +import org.lamsfoundation.lams.qb.model.QbQuestion; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.support.RequestContextUtils; import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; import java.util.Map; @Controller @@ -19,9 +25,28 @@ // read Flash Attributes set by another module and put them in the model Map inputFlashMap = RequestContextUtils.getInputFlashMap(request); if (inputFlashMap != null) { + + Map> randomisedOptions = new HashMap<>(); + model.addAttribute("printRandomisedOptions", randomisedOptions); for (String key : inputFlashMap.keySet()) { if (key.startsWith("print")) { model.addAttribute(key, inputFlashMap.get(key)); + + if (key.equals("printQuestions")) { + Collection questions = (Collection) inputFlashMap.get(key); + for (QbQuestion question : questions) { + if (question.getType().equals(QbQuestion.TYPE_MATCHING_PAIRS) || question.getType() + .equals(QbQuestion.TYPE_ORDERING)) { + // randomise the order of options when correct answers are hidden + List optionNames = new ArrayList<>(); + for (QbOption option : question.getQbOptions()) { + optionNames.add(option.getName()); + } + Collections.shuffle(optionNames); + randomisedOptions.put(question.getUid(), optionNames); + } + } + } } } } Index: lams_central/web/qb/printQuestions.jsp =================================================================== diff -u -r740df184f8cb7d5b0da48c84f15ca0f5ab0bcdbd -ra2ba5772ecb96d0d5436043ba0da03b6b1a5cdc2 --- lams_central/web/qb/printQuestions.jsp (.../printQuestions.jsp) (revision 740df184f8cb7d5b0da48c84f15ca0f5ab0bcdbd) +++ lams_central/web/qb/printQuestions.jsp (.../printQuestions.jsp) (revision a2ba5772ecb96d0d5436043ba0da03b6b1a5cdc2) @@ -26,6 +26,10 @@ color: var(--bs-success); } + .reveal-answers { + display: none; + } + .hide-answers .option-feedback, .hide-answers .option-correct-label { display: none; @@ -36,6 +40,10 @@ color: initial; } + .hide-answers .reveal-answers { + display: block; + } + @media print { .hide-print { display: none; @@ -84,26 +92,108 @@
  • -
      - -
    1. -
      - - - - () + + + +
        + +
      1. +
        + + + + () + + +
        + + "> + + + +
      2. +
        +
      +
      + + +
        + +
      1. + + + () - -
      - - "> - - - -
    2. -
      -
    +
  • + + +
      + +
    1. + +
    2. +
      +
    + + + +
      + +
    1. +
      + + + + () + + +
      +

      + : + +

      + + "> + + + +
    2. +
      +
    +
    + + +

    + + + () + + + () + + +

    +
    + + +
      + +
    1. + +
    2. +
      +
    +
      + +
    1. + +
    2. +
      +
    +
    +