original_string: public function process_ma($xml, &$questions) {
          if ($this->getpath($xml, array('POOL', '#', 'QUESTION_MULTIPLEANSWER'), false, false)) {
              $maquestions = $this->getpath($xml,
                      array('POOL', '#', 'QUESTION_MULTIPLEANSWER'), false, false);
          } else {
              return;
          }
  
          foreach ($maquestions as $thisquestion) {
              $question = $this->process_common($thisquestion);
  
              $correctfeedback = $this->getpath($thisquestion,
                      array('#', 'GRADABLE', 0, '#', 'FEEDBACK_WHEN_CORRECT', 0, '#'),
                      '', true);
              $incorrectfeedback = $this->getpath($thisquestion,
                      array('#', 'GRADABLE', 0, '#', 'FEEDBACK_WHEN_INCORRECT', 0, '#'),
                      '', true);
              $question->correctfeedback = $this->cleaned_text_field($correctfeedback);
              // As there is no partially correct feedback we use incorrect one.
              $question->partiallycorrectfeedback = $this->cleaned_text_field($incorrectfeedback);
              $question->incorrectfeedback = $this->cleaned_text_field($incorrectfeedback);
  
              $question->qtype = 'multichoice';
              $question->defaultmark = 1;
              $question->single = 0; // More than one answers allowed.
  
              $choices = $this->getpath($thisquestion, array('#', 'ANSWER'), false, false);
              $correctanswerids = array();
              foreach ($this->getpath($thisquestion,
                      array('#', 'GRADABLE', 0, '#', 'CORRECTANSWER'), false, false) as $correctanswer) {
                  if ($correctanswer) {
                      $correctanswerids[] = $this->getpath($correctanswer,
                              array('@', 'answer_id'),
                              '', true);
                  }
              }
              $fraction = 1 / count($correctanswerids);
  
              foreach ($choices as $choice) {
                  $choicetext = $this->getpath($choice, array('#', 'TEXT', 0, '#'), '', true);
                  // Put this choice in the question object.
                  $question->answer[] = $this->cleaned_text_field($choicetext);
  
                  $choiceid = $this->getpath($choice, array('@', 'id'), '', true);
  
                  $iscorrect = in_array($choiceid, $correctanswerids);
  
                  if ($iscorrect) {
                      $question->fraction[] = $fraction;
                  } else {
                      $question->fraction[] = 0;
                  }
                  // There is never feedback specific to each choice.
                  $question->feedback[] = $this->text_field('');
              }
              $questions[] = $question;
          }
      }
code: public function process_ma($xml, &$questions) {
          if ($this->getpath($xml, array('POOL', '#', 'QUESTION_MULTIPLEANSWER'), false, false)) {
              $maquestions = $this->getpath($xml,
                      array('POOL', '#', 'QUESTION_MULTIPLEANSWER'), false, false);
          } else {
              return;
          }
  
          foreach ($maquestions as $thisquestion) {
              $question = $this->process_common($thisquestion);
  
              $correctfeedback = $this->getpath($thisquestion,
                      array('#', 'GRADABLE', 0, '#', 'FEEDBACK_WHEN_CORRECT', 0, '#'),
                      '', true);
              $incorrectfeedback = $this->getpath($thisquestion,
                      array('#', 'GRADABLE', 0, '#', 'FEEDBACK_WHEN_INCORRECT', 0, '#'),
                      '', true);
              $question->correctfeedback = $this->cleaned_text_field($correctfeedback);
              // As there is no partially correct feedback we use incorrect one.
              $question->partiallycorrectfeedback = $this->cleaned_text_field($incorrectfeedback);
              $question->incorrectfeedback = $this->cleaned_text_field($incorrectfeedback);
  
              $question->qtype = 'multichoice';
              $question->defaultmark = 1;
              $question->single = 0; // More than one answers allowed.
  
              $choices = $this->getpath($thisquestion, array('#', 'ANSWER'), false, false);
              $correctanswerids = array();
              foreach ($this->getpath($thisquestion,
                      array('#', 'GRADABLE', 0, '#', 'CORRECTANSWER'), false, false) as $correctanswer) {
                  if ($correctanswer) {
                      $correctanswerids[] = $this->getpath($correctanswer,
                              array('@', 'answer_id'),
                              '', true);
                  }
              }
              $fraction = 1 / count($correctanswerids);
  
              foreach ($choices as $choice) {
                  $choicetext = $this->getpath($choice, array('#', 'TEXT', 0, '#'), '', true);
                  // Put this choice in the question object.
                  $question->answer[] = $this->cleaned_text_field($choicetext);
  
                  $choiceid = $this->getpath($choice, array('@', 'id'), '', true);
  
                  $iscorrect = in_array($choiceid, $correctanswerids);
  
                  if ($iscorrect) {
                      $question->fraction[] = $fraction;
                  } else {
                      $question->fraction[] = 0;
                  }
                  // There is never feedback specific to each choice.
                  $question->feedback[] = $this->text_field('');
              }
              $questions[] = $question;
          }
      }
code_tokens: public function process_ma ( $ xml , & $ questions ) { if ( $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_MULTIPLEANSWER' ) , false , false ) ) { $ maquestions = $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_MULTIPLEANSWER' ) , false , false ) ; } else { return ; } foreach ( $ maquestions as $ thisquestion ) { $ question = $ this -> process_common ( $ thisquestion ) ; $ correctfeedback = $ this -> getpath ( $ thisquestion , array ( '#' , 'GRADABLE' , 0 , '#' , 'FEEDBACK_WHEN_CORRECT' , 0 , '#' ) , '' , true ) ; $ incorrectfeedback = $ this -> getpath ( $ thisquestion , array ( '#' , 'GRADABLE' , 0 , '#' , 'FEEDBACK_WHEN_INCORRECT' , 0 , '#' ) , '' , true ) ; $ question -> correctfeedback = $ this -> cleaned_text_field ( $ correctfeedback ) ; // As there is no partially correct feedback we use incorrect one. $ question -> partiallycorrectfeedback = $ this -> cleaned_text_field ( $ incorrectfeedback ) ; $ question -> incorrectfeedback = $ this -> cleaned_text_field ( $ incorrectfeedback ) ; $ question -> qtype = 'multichoice' ; $ question -> defaultmark = 1 ; $ question -> single = 0 ; // More than one answers allowed. $ choices = $ this -> getpath ( $ thisquestion , array ( '#' , 'ANSWER' ) , false , false ) ; $ correctanswerids = array ( ) ; foreach ( $ this -> getpath ( $ thisquestion , array ( '#' , 'GRADABLE' , 0 , '#' , 'CORRECTANSWER' ) , false , false ) as $ correctanswer ) { if ( $ correctanswer ) { $ correctanswerids [ ] = $ this -> getpath ( $ correctanswer , array ( '@' , 'answer_id' ) , '' , true ) ; } } $ fraction = 1 / count ( $ correctanswerids ) ; foreach ( $ choices as $ choice ) { $ choicetext = $ this -> getpath ( $ choice , array ( '#' , 'TEXT' , 0 , '#' ) , '' , true ) ; // Put this choice in the question object. $ question -> answer [ ] = $ this -> cleaned_text_field ( $ choicetext ) ; $ choiceid = $ this -> getpath ( $ choice , array ( '@' , 'id' ) , '' , true ) ; $ iscorrect = in_array ( $ choiceid , $ correctanswerids ) ; if ( $ iscorrect ) { $ question -> fraction [ ] = $ fraction ; } else { $ question -> fraction [ ] = 0 ; } // There is never feedback specific to each choice. $ question -> feedback [ ] = $ this -> text_field ( '' ) ; } $ questions [ ] = $ question ; } }
docstring: Process Multiple Choice Questions With Multiple Answers
  @param array $xml the xml tree
  @param array $questions the questions already parsed
docstring_tokens: Process Multiple Choice Questions With Multiple Answers