viewof _webr_editor_{{block_id}} = {
  const { WebRExerciseEditor, b64Decode } = window._exercise_ojs_runtime;
  const scriptContent = document.querySelector(`script[type=\"webr-{{block_id}}-contents\"]`).textContent;
  const block = JSON.parse(b64Decode(scriptContent));

  // Default exercise configuration
  const options = Object.assign(
    {
      id: "webr-{{block_id}}-contents",
      envir: `exercise-env-${block.attr.exercise}`,
      error: false,
      caption: 'Exercise',
    },
    block.attr
  );

  const editor = new WebRExerciseEditor(webROjs.webRPromise, block.code, options);
  return editor.container;
}
viewof _webr_value_{{block_id}} = webROjs.process(_webr_editor_{{block_id}}, {{block_input}});
_webr_feedback_{{block_id}} = {
  const { WebRGrader } = window._exercise_ojs_runtime;
  const emptyFeedback = document.createElement('div');

  const grader = new WebRGrader(_webr_value_{{block_id}}.evaluator);
  const feedback = await grader.gradeExercise();
  if (!feedback) return emptyFeedback;
  return feedback;
}
