在继续下一个问题之前,设置学习者:教程问题的尝试次数?

马尔·多里

我正在使用学习者:教程创建作业问题。在转到下一部分之前,我想给学生3种解决问题的尝试。我有progressive: true和,allow_skip: false但此刻,可以无限尝试一次,即使答案不正确,用户也可以继续下一个问题。一个问题的例子是:

### Part (a)

```{r part-a, echo=FALSE}

question_text(
  "Input all possible rupture paths:",
    answer("ABEF", correct = TRUE),
    answer("ABCDG", correct = TRUE),
    answer("ABCDEF",correct = TRUE),
    answer("ABDEF", correct = TRUE),
  allow_retry = TRUE,
  trim = TRUE
)
```
<br><br><br><br>
---

### Part (b)

```{r part-b1, echo=FALSE}

question_text(
  "Enter the deduced length due to the bolts for the ABEF rupture path:",
    answer("1.625", correct = TRUE),
    answer("1.6", correct = TRUE),
    answer("2(13/16)",correct = TRUE),
    incorrect = "Direction from top to bottom of the plate",
  allow_retry = TRUE,
  trim = TRUE
)
```

编辑

我遇到了有条件地打印代码块

```{r setup, echo=FALSE}
show_text <- FALSE
````

```{r conditional_block, eval=show_text}
print("this will only print when show.text is TRUE")
```

我想知道是否有一种方法可以设置show_text = TRUE测验问题的反馈是否正确,以便显示下一部分。

瓦尔迪

正如评论中指出的那样,您要查找的选项未在软件包中实现。
如果您的请求被接受,那么在以后的版本中可能就是这种情况

同时,如果您准备重建软件包,则修改以满足n次尝试问题很简单:

  1. 下载learner-master并将其解压缩到目录中

  2. 在RStudio下打开学习者.Rproj

  3. 打开R/quizz.R,找到发光的模块:question_module_server_impl并用下面的代码替换。

  4. 构建/安装并重新启动

  5. 您现在可以在allow_retry参数中设置重试次数:

question_text(
  "Enter the deduced length due to the bolts for the ABEF rupture path:",
    answer("1.625", correct = TRUE),
    answer("1.6", correct = TRUE),
    answer("2(13/16)",correct = TRUE),
    incorrect = "Direction from top to bottom of the plate",
  allow_retry = 2,
  trim = TRUE
)

想法是将现有allow_retry参数与以前的布尔值一起使用,或者与给出试验次数的整数一起使用,在这种情况下,将其与反应型计数器进行比较。

==================================================

的更新版本question_module_server_impl
修改的代码中所强调的# new ===还是# update ===

question_module_server_impl <- function(
  input, output, session,
  question
) {

  ns <- getDefaultReactiveDomain()$ns

  # new ============================
  # set counter
  val <- reactiveValues(
    numtry = 0
  )
  # ================================


  # set a seed for each user session for question methods to use
  question$seed <- random_seed()

  # only set when a submit button has been pressed
  # (or reset when try again is hit)
  # (or set when restoring)
  submitted_answer <- reactiveVal(NULL, label = "submitted_answer")

  is_correct_info <- reactive(label = "is_correct_info", {
    # question has not been submitted
    if (is.null(submitted_answer())) return(NULL)
    # find out if answer is right
    ret <- question_is_correct(question, submitted_answer())

    # new : Increment counter =======
    isolate(val$numtry <- val$numtry+1)
    # ===============================


    if (!inherits(ret, "learnr_mark_as")) {
      stop("`question_is_correct(question, input$answer)` must return a result from `correct`, `incorrect`, or `mark_as`")
    }
    ret
  })

  # should present all messages?
  is_done <- reactive(label = "is_done", {
    if (is.null(is_correct_info())) return(NULL)
    # updated ====================================================
    (!isTRUE(question$allow_retry>0)) || is_correct_info()$correct
    # ============================================================
  })


  button_type <- reactive(label = "button type", {
    if (is.null(submitted_answer())) {
      "submit"
    } else {
      # is_correct_info() should be valid
      if (is.null(is_correct_info())) {
        stop("`is_correct_info()` is `NULL` in a place it shouldn't be")
      }

      # update the submit button label
      if (is_correct_info()$correct) {
        "correct"
      } else {
        # not correct
        # updated =====================================
        if (isTRUE(val$numtry<question$allow_retry)|(question$allow_retry&is.logical(question$allow_retry))) {
          # not correct, but may try again
          "try_again"
        } else {
          # not correct and can not try again
          "incorrect"
        }
      }
    }
  })

  # disable / enable for every input$answer change
  answer_is_valid <- reactive(label = "answer_is_valid", {
    if (is.null(submitted_answer())) {
      question_is_valid(question, input$answer)
    } else {
      question_is_valid(question, submitted_answer())
    }
  })

  init_question <- function(restoreValue = NULL) {
    if (question$random_answer_order) {
      question$answers <<- shuffle(question$answers)
    }
    submitted_answer(restoreValue)
  }

  # restore past submission
  #  If no prior submission, it returns NULL
  past_submission_answer <- retrieve_question_submission_answer(session, question$label)
  # initialize like normal... nothing has been submitted
  #   or
  # initialize with the past answer
  #  this should cascade throughout the app to display correct answers and final outputs
  init_question(past_submission_answer)


  output$action_button_container <- renderUI({
    question_button_label(
      question,
      button_type(),
      answer_is_valid()
    )
  })

  output$message_container <- renderUI({
    req(!is.null(is_correct_info()), !is.null(is_done()))

    withLearnrMathJax(
      question_messages(
        question,
        messages = is_correct_info()$messages,
        is_correct = is_correct_info()$correct,
        is_done = is_done()
      )
    )
  })

  output$answer_container <- renderUI({
    if (is.null(submitted_answer())) {
      # has not submitted, show regular answers
      return(
        # if there is an existing input$answer, display it.
        # if there is no answer... init with NULL
        # Do not re-render the UI for every input$answer change
        withLearnrMathJax(
          question_ui_initialize(question, isolate(input$answer))
        )
      )
    }

    # has submitted

    if (is.null(is_done())) {
      # has not initialized
      return(NULL)
    }

    if (is_done()) {
      # if the question is 'done', display the final input ui and disable everything

      return(
        withLearnrMathJax(
          question_ui_completed(question, submitted_answer())
        )
      )
    }

    # if the question is NOT 'done', disable the current UI
    #   until it is reset with the try again button

    return(
      withLearnrMathJax(
        question_ui_try_again(question, submitted_answer())
      )
    )
  })


  observeEvent(input$action_button, {

    if (button_type() == "try_again") {
      # maintain current submission / do not randomize answer order
      # only reset the submitted answers
      # does NOT reset input$answer
      submitted_answer(NULL)

      # submit "reset" to server
      event_trigger(
        session,
        "reset_question_submission",
        data = list(
          label    = as.character(question$label),
          question = as.character(question$question)
        )
      )
      return()
    }

    submitted_answer(input$answer)

    # submit question to server
    event_trigger(
      session = session,
      event   = "question_submission",
      data    = list(
        label    = as.character(question$label),
        question = as.character(question$question),
        answer   = as.character(input$answer),
        correct  = is_correct_info()$correct
      )
    )

  })
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在R学习者中以编程方式创建一个带有多个答案的问题文本

来自分类Dev

下一个NSDateFormatter问题

来自分类Dev

SpeechRecognition:循环处理一组问题;在问下一个问题之前等待每个“口头”回答

来自分类Dev

单击下一个按钮时显示下一个问题

来自分类Dev

有没有一种方法可以让黄瓜在继续下一个场景之前再次尝试一个场景

来自分类Dev

有没有办法让黄瓜在继续下一个场景之前再次尝试一个场景

来自分类Dev

BrowseFragment下一个焦点问题

来自分类Dev

下一个Fit内存分配问题

来自分类Dev

对于下一个循环问题

来自分类Dev

在继续执行下一个任务之前,使gulp同步写入文件

来自分类Dev

C ++在继续下一个任务之前先完成当前任务

来自分类Dev

在继续下一个元素之前,如何将多个列表中的一个元素写入文件?

来自分类Dev

Datepicker上一个和下一个按钮图像问题

来自分类Dev

播放下一个/上一个按钮的问题?

来自分类Dev

学习者问题:一种根据状态有条件地设置一组字段样式的方法

来自分类Dev

jQuery循环-从下一个元素继续

来自分类Dev

Swift / iOS8:在Segue之前为下一个View Controller设置imageView

来自分类Dev

在渲染下一个组件 React-Redux 之前设置组件的状态

来自分类Dev

在下一个请求之前,更改Cookie不会对其产生影响-如何解决此问题?

来自分类Dev

创建新的/下一个Android活动时遇到的问题

来自分类Dev

反应:下一个问题出现时,复选框不会取消选中

来自分类Dev

使用引导程序注册表格上的下一个按钮的问题

来自分类Dev

CountdownCircleTimer持续时间在下一个问题中未更新

来自分类Dev

嵌套的循环问题将不会移到下一个文件

来自分类Dev

重新分配的问题-“无效的下一个大小”

来自分类Dev

C ++的下一个功能出了什么问题

来自分类Dev

如果选中了无线电输入,则显示下一个问题

来自分类Dev

Javascript测验-通过jQuery的next()方法到达下一个同级项的问题

来自分类Dev

在 jQuery 中定位下一个类时面临的问题

Related 相关文章

  1. 1

    在R学习者中以编程方式创建一个带有多个答案的问题文本

  2. 2

    下一个NSDateFormatter问题

  3. 3

    SpeechRecognition:循环处理一组问题;在问下一个问题之前等待每个“口头”回答

  4. 4

    单击下一个按钮时显示下一个问题

  5. 5

    有没有一种方法可以让黄瓜在继续下一个场景之前再次尝试一个场景

  6. 6

    有没有办法让黄瓜在继续下一个场景之前再次尝试一个场景

  7. 7

    BrowseFragment下一个焦点问题

  8. 8

    下一个Fit内存分配问题

  9. 9

    对于下一个循环问题

  10. 10

    在继续执行下一个任务之前,使gulp同步写入文件

  11. 11

    C ++在继续下一个任务之前先完成当前任务

  12. 12

    在继续下一个元素之前,如何将多个列表中的一个元素写入文件?

  13. 13

    Datepicker上一个和下一个按钮图像问题

  14. 14

    播放下一个/上一个按钮的问题?

  15. 15

    学习者问题:一种根据状态有条件地设置一组字段样式的方法

  16. 16

    jQuery循环-从下一个元素继续

  17. 17

    Swift / iOS8:在Segue之前为下一个View Controller设置imageView

  18. 18

    在渲染下一个组件 React-Redux 之前设置组件的状态

  19. 19

    在下一个请求之前,更改Cookie不会对其产生影响-如何解决此问题?

  20. 20

    创建新的/下一个Android活动时遇到的问题

  21. 21

    反应:下一个问题出现时,复选框不会取消选中

  22. 22

    使用引导程序注册表格上的下一个按钮的问题

  23. 23

    CountdownCircleTimer持续时间在下一个问题中未更新

  24. 24

    嵌套的循环问题将不会移到下一个文件

  25. 25

    重新分配的问题-“无效的下一个大小”

  26. 26

    C ++的下一个功能出了什么问题

  27. 27

    如果选中了无线电输入,则显示下一个问题

  28. 28

    Javascript测验-通过jQuery的next()方法到达下一个同级项的问题

  29. 29

    在 jQuery 中定位下一个类时面临的问题

热门标签

归档