为什么表单变量在我的新脚本中没有值? (数组中的数组)

This is a script I've been using to score answers to a database-powered quiz:

if (isset($_POST)):
 $totalCorrect = 0;
 $answers = array(1 => 'A', 2 => 'Jupiter', 3 => 'C', 4 => 'D', 5 => 'A', 6 => 'C', 7 => 'C', 8 => 'C', 9 => 'B', 10 => array('A','B','C'));

foreach ($answers as $num => $answer):

    $question = 'q'.$num;

    if(is_array($answer) && isset($_POST[$question])){
        $ans_cnt = count($answer);
        $ans_value = (1 / $ans_cnt);

        $post_cnt = count($_POST[$question]);

        //find matches between answer array and post array
        $matches = array_intersect($answer,$_POST[$question]);
        $good_answers = count($matches);
        //Get bad answer count, which be be subtracted from overall  score
        $bad_answers  = 0;
        foreach($_POST[$question] as $post_answer):
            if(!in_array($post_answer,$answer)):
                $bad_answers++;
            endif;
        endforeach;

if($good_answers ==3 && $bad_answers==0){
$result = 1;
}else{
$result = 0;
}

        if(($post_cnt != $ans_cnt) || ($post_cnt == $ans_cnt &&  $ans_cnt != count($matches))){
            $result = $result * $ans_value;
            $totalCorrect = $totalCorrect + $result;    
        }else{            
            $totalCorrect++;        
        }


    }elseif(isset($_POST[$question]) && strtolower($_POST[$question]) === strtolower($answer)){
        $totalCorrect++;
    }
endforeach;

 $pct = round( (($totalCorrect/count($answers)) * 100), 0);
 echo $totalCorrect.' correct ('.$pct.'%)';
endif;

It works fine, but it has some limitations. For example, it won't work if a quiz has more than one question that requires a user to choose multiple answers (checkboxes). So I want to replace it with this script:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
 $qa = 'q'.$num;
 $correct = 0;
 $answers = array(1 => array('A'), 
             2 => array('Jupiter'), 
             3 => array('C'), 
             4 => array('D'), 
             5 => array('A'), 
             6 => array('C'), 
             7 => 'C', 
             8 => 'C', 
             9 => 'B', 
             10 => array('A','B','C'));
$total = count($answers);
foreach($answers as $k => $v){
 if(is_array($v)){
    if(array_diff($qa[$k], $v) == array()){
        $correct++;
    }
 } else if($qa[$k] === $v){
    $correct++;
 }
}
 $grade= ($correct/count($answers))*100;
 echo"<p>Score $grade%</p>";
}

But when I select some answers and click the Submit button, the new script produces some error messages, beginning with this:

Undefined variable: num

This is the code that produces the error:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
 $qa = 'q'.$num;

It corresponds to this line in the old script:

$question = 'q'.$num;

It looks like a simple fix, but I'm confused. I've tried a number of tricks, but nothing works.

I echoed var_dump, and the result is the same for both scripts:

var_dump: array(5) {
 ["q2"]=> string(0) ""
 ["q9"]=> string(1) "B"
 ["q10"]=> array(3) {
 [0]=> string(1) "A"
 [1]=> string(1) "B"
 [2]=>
 string(1) "C"
}
 ["PreviousURL"]=>
 string(25) "http://g1/test/gw-intro-1"
 ["user_token"]=>
 string(13) "54ee6aac475ac"
}

Can anyone tell me how to make $num accept the proper value in my new script? Or does my new script need to be completely changed? (Let me know if you want me to post some HTML.)

Note: I edited my original post to include some HTML, so you can see what the values for q$num look like...

<li id="q9">
    <div class="Question">Scientists believe the universe is:</div>
    <div class="Answer">
      <label class="Wide" for="q9-A"><div class="Radio"><input type="radio" name="q9" id="q9-A" value="A" style="display: none;"> A.  disappearing</div></label></div>
    <div class="Answer">
      <label class="Wide" for="q9-B"><div class="Radio"><input type="radio" name="q9" id="q9-B" value="B" style="display: none;"> B. expanding</div></label></div>
    <div class="Answer">
      <label class="Wide" for="q9-C"><div class="Radio"><input type="radio" name="q9" id="q9-C" value="C" style="display: none;"> C. contracting</div></label></div>
    <div class="Answer">
      <label class="Wide" for="q9-D"><div class="Radio"><input type="radio" name="q9" id="q9-D" value="D" style="display: none;"> D. becoming bipolar</div></label></div>
  </li>
  <li id="q10">
    <div class="Question">Check each item that can be found in our solar system.</div>
    <div class="Answer" style="margin-top: 5px; background: #000; color: #fff; text-align: center;">
    <label for="q10-A"><input type="checkbox" name="q10[]" id="q10-A" value="A">planet</label>
       <label for="q10-B"><input type="checkbox" name="q10[]" id="q10-B" value="B">asteroid</label>
       <label for="q10-C"><input type="checkbox" name="q10[]" id="q10-C" value="C">comet</label>
       <label for="q10-D"><input type="checkbox" name="q10[]" id="q10-D" value="D">black hole</label>
       <label for="q10-E"><input type="checkbox" name="q10[]" id="q10-E" value="E">neutrino star</label>
       <label for="q10-F"><input type="checkbox" name="q10[]" id="q10-F" value="F">quasar</label>
     </div>
      </li>

This is what the PHP for q$num looks like:

<label for="q'.$QID.'-'.$Value.'">

...where $QID (Question ID) = a numeral and $Value = a capital letter.