Skip to content

Error with rendering problem #62

Description

@pstaabp

When loading the following problem: Library/MC/PreAlgebra/setPreAlgebraC01S06/SUbtractingIntegers03.pg

I'm getting an error:

VM1878:1 Uncaught TypeError: Cannot read properties of undefined (reading 'style')
    at <anonymous>:1:61
    at eval (Problem.vue?3854:162)
    at NodeList.forEach (<anonymous>)
    at eval (Problem.vue?3854:157)
    at Generator.next (<anonymous>)
    at fulfilled (VM1642 Problem.vue:16)

I think the actual line is:

origScript.parentNode?.replaceChild(newScript, origScript);

Activity

  1. pstaabp commented on Nov 18, 2021

    @pstaabp
    SponsorMemberAuthor

    I just dug into this a bit more. In webwork 2, at the bottom of the problem, the following is in the rendered problem:

    <p>
      <b style="display: none;">Note: </b>
      <i>
         <script>var bb = document.getElementsByTagName("b");bb[bb.length-1].style.display="none"</script>
         <input type="hidden" name="_status" value="2772722728292A">
         <input type="hidden" name="_reseed" id="_reseed" value="0">
      </I>
    </p>
    

    However, in webwork3, the same block is:

    <p>
      <script>var bb = document.getElementsByTagName("b");bb[bb.length-1].style.display="none"</script>
      <input type="hidden" name="_status" value="2772722728292A">
      <input type="hidden" name="_reseed" id="_reseed" value="0">
    </p>
    

    so it's missing the <b style="display: none;">Note: </b> so there is an error thrown when the script is run.

    I'm not sure why this is like this. What's the point of printing: "Note:" then hiding it.

  2. drdrew42 commented on Nov 18, 2021

    @drdrew42
    SponsorMember

    Yet another reason to ditch problemRandomize.pl

      #
      #  Add the problemRandomize message and data
      #
      if ($isWhen && !$okDate) {
        $result->{msg} .= "</i><br /><b>".$main::PG->maketext("Note:")."</b> <i>" if $result->{msg};
        $result->{msg} .= $main::PG->maketext("You can get a new version of this problem after the due date.");
      }
      if (!$result->{msg}) {
        # hack to remove unwanted "<b>Note: </b>" from the problem
        #  (it is inserted automatically by Problem.pm when {msg} is non-emtpy).
        $result->{msg} .= '<script>var bb = document.getElementsByTagName("b");'
                       .  'bb[bb.length-1].style.display="none"</script>';
      }
      $result->{msg} .= qq!<input type="hidden" name="_status" value="$data" />!;
  3. pstaabp commented on Nov 19, 2021

    @pstaabp
    SponsorMemberAuthor

    I think having problem versions will allow us to do this in a built-in way, correct?

  4. dlglin commented on Nov 19, 2021

    @dlglin
    Member

    Even webwork2 has a built-in way to do this without problemRandomize.pl (though it has issues). I agree with @drdrew42 that there is no reason to support problemRandomize.pl going forward. In the past the decision was made by the OPL board to not accept problems that include it, so I would like to see it removed from problems in the OPL. Just don't tell @drjt I said that, since it looks like it's mostly MC problems that include it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions