Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      37176

      Description

      See http://moodle.org/mod/forum/discuss.php?d=82896
      Acually on return from a submit the answer field is set to zero even if there was no values writen precedently.

        Activity

        Hide
        Pierre Pichet added a comment - - edited

        Calculated question after converting the wild cards to there actula values form the datasets, calculate the answer formula results and tranfer its quiz display to numerical question which finally transfer it to short answer.
        So the actual coding of the calcultead display on a quiz quiz follow mostly the short answer code.
        The answer (or response field)in a quiz is an HTML input element which has the following value
        line 140 +- of shortanswer/questiontype.php
        /// Print input controls

        if (isset($state->responses['']))

        { $value = ' value="'.s($state->responses[''], true).'" '; } else { $value = ' value="" '; }

        For some "obscured class mechanism" in the PHP code if there is no input on a calculated question in a quiz but the user submit values for other questiontypes, the '' (empty) response field is interpreted as 0 by the s. HTML function.
        To obtain a true nil display I just complete the if with an additional test
        if (isset($state->responses[''])&& $state->responses['']!='') { $value = ' value="'.s($state->responses[''], true).'" '; }

        else

        { $value = ' value="" '; }

        There was no noticeable interferences with the two other types (i.e. numerical or shortanswer) who used the same code .

        Just waiting a little before CVS to 1.9 and the other previous versions which use the same code.

        Show
        Pierre Pichet added a comment - - edited Calculated question after converting the wild cards to there actula values form the datasets, calculate the answer formula results and tranfer its quiz display to numerical question which finally transfer it to short answer. So the actual coding of the calcultead display on a quiz quiz follow mostly the short answer code. The answer (or response field)in a quiz is an HTML input element which has the following value line 140 +- of shortanswer/questiontype.php /// Print input controls if (isset($state->responses [''] )) { $value = ' value="'.s($state->responses[''], true).'" '; } else { $value = ' value="" '; } For some "obscured class mechanism" in the PHP code if there is no input on a calculated question in a quiz but the user submit values for other questiontypes, the '' (empty) response field is interpreted as 0 by the s. HTML function. To obtain a true nil display I just complete the if with an additional test if (isset($state->responses [''] )&& $state->responses [''] !='') { $value = ' value="'.s($state->responses[''], true).'" '; } else { $value = ' value="" '; } There was no noticeable interferences with the two other types (i.e. numerical or shortanswer) who used the same code . Just waiting a little before CVS to 1.9 and the other previous versions which use the same code.
        Hide
        Pierre Pichet added a comment -

        CVS done to moodle 1.7

        Show
        Pierre Pichet added a comment - CVS done to moodle 1.7

          People

          • Assignee:
            Pierre Pichet
            Reporter:
            Pierre Pichet
            Participants:
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: