<?php

//$goflow='Survey Responses';
       $cutoff2=$cutoff-4;
      If ($Ascore > $cutoff){
      $warn11="<div class=success2> Current Cutoff is set to $cutoff<br> $High</div>";
      }

       If ($Ascore > $cutoff2 AND $Ascore<=$cutoff){
      $warn11="<div class=warning> Current Cutoff is set to $cutoff<br> $Medium</div>";
      }


                 If ($Ascore < $cutoff2 ){
      $warn11="<div class=warning>Current Cutoff is set to $cutoff<br> $Low</div>";
      }

      if ($bjed==3 or $bjed==2){
        $warn11='';
      }


   $survey_id55=$survey_idRT;
   if ($survey_id55<1 OR $survey_id55 ==$blink){
     $survey_id55=$survey_idR;
   }

   $goflow2[21]="Application Part I";
   $goflow2[22]="Application Part II";
   $goflow2[23]="Application Part III";
   $goflow2[24]="Application Part IV";
   $goflow2[25]="Application Part V";
   $goflow2[26]="Application Part VI";
   $goflow2[27]="Application Part VII";
   $goflow2[28]="Application Part VIII";
   if ($survey_id55>=21 AND $survey_id55<=28)  {
      $goflow=$goflow2[$survey_id55];
      $display_title="MIT Application";
   }


//   echo "surv55 -$survey_id55";

 for ($pp=1;$pp<=55; $pp++){

   $sq112ac1="SELECT * FROM $table_name77 WHERE survey_id='$survey_id55' AND surveyQ_id='$pp'  AND A_points !='0' Order by A_points DESC limit 1";
$result112ac1 = @mysql_query($sq112ac1,$connection) or die(mysql_error());
while ($row112ac1 = mysql_fetch_array($result112ac1)) {
$Avan1[0]=0;
$Avan1[$pp]=  $row112ac1['A_points'];
$pop55=$pp-1;
if ($Avan1[$pp]>$Avan1[$pop55]){
$Ppoints[$pp]=  $Avan1[$pp];
 }else {
 $Ppoints[$pp]=  $Avan1[$pop55];
 }



 } //while
          $maxpoints=$maxpoints+$Ppoints[$pp];

   //   $maxpoints=100;

 } //1st for


   $sq112ac1d="SELECT * FROM $table_name77 WHERE survey_id='$survey_id55' AND test_type='0'  AND A_points <='1'";
$result33def = @mysql_query($sq112ac1d,$connection) or die(mysql_error());
  $num33def = mysql_num_rows($result33def);

         $maxpoints=$maxpoints+$num33def;

          if ($app_id==21){

          $maxpoints=$maxpoints+4*4+4*5; //4 min x high 4 pos + 4 min x 5 points

      $sq112ac1d="SELECT * FROM $table_name102 WHERE app_id='$survey_id55' AND map_id='$map_id' ";
$resultdd = @mysql_query($sq112ac1d,$connection) or die(mysql_error());
while ($row112ddee = mysql_fetch_array($resultdd)) {
              $addpoints=  $row112ddee['van2'];
                   $Ascore =$Ascore+$addpoints;

              $addpoints=  $row112ddee['van3'];
                   $Ascore =$Ascore+$addpoints;


                          }   }


   if ($app_id==21){
       $sql2 =  "Update $table_name79 SET Ascore='$Ascore'    WHERE map_id ='$map_id'";
  $result2 = @mysql_query($sql2,$connection) or die(mysql_error());

   $sql2 =  "Update $table_name80 SET Ascore='$Ascore'    WHERE map_id ='$map_id'";
  $result2 = @mysql_query($sql2,$connection) or die(mysql_error());

   }
              if ($maxpoints>0){
                $PerT=$Ascore/$maxpoints*100;
                }else{
                  $PerT="Max Points is NA";
                }

                       $rst=1;
                      $jjjt=4;

                        $mainstry=trim($mainstry);
                         $xmainstry=trim($xmainstry);
                   $mainstry=substr($mainstry, 6);
                     $xmainstry=substr($xmainstry, 6);
                     // $xmain=substr($xmain, 1);

                     $xmainbob=substr($xmainbob, 1);
                  $ymainbob=substr($ymainbob, 1);
      include("linetest2.php");
    $plotComp="<img src=\"GoTool/survey/$fileName\" />";




      $display_blockV .="   <!--- <td colspan=3>  -->
                                $warn11
             <div class=\"box\">
    <div class=\"heading\">
      <h1><img src=\"view/image/order.png\" alt=\"\" /> $goflow</h1>
     <!---
      <div class=\"buttons\"></div> -->
    </div>
   <!--- <div class=\"content\">  --->
    Raw Score for this Application: $Ascore out of $maxpoints - $PerT% <br/><br />
           $display_blockAdmin
                                                <br/><br/>
                $plotComp  <br /> $field_cnt   <!--- Other=${graphymPTS.$rst.$jjjt} - strY - $mainstry   <br/>xmain- $xmainstry <br/> xx-bob= $xxmainbob <br /> y-bob=$yymainbob
              --->
        ";


      if($babs==100){
       $warn11='';



$display_blockV ="    <td colspan=3>
                                $warn11    <br/>
   <!---          <div class=\"box\">
    <div class=\"heading\">
      <h1><img src=\"view/image/order.png\" alt=\"\" /> $goflow</h1>

      <div class=\"buttons\"></div>
    </div> --->
    <div class=\"content\">
   <!--- Score for this Application: $Ascore <br/><br />  -->
           $display_blockAdmin
                                                <br/><br/>
             $plotComp

        ";
        }
?>
