src/Controller/SurveyController.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. /**
  4.  * Created by PhpStorm.
  5.  * User: C
  6.  * Date: 12/24/2018
  7.  * Time: 1:18 PM
  8.  */
  9. use App\Entity\Answers;
  10. use App\Entity\Ebook;
  11. use App\Entity\Group;
  12. use App\Entity\Pages;
  13. use App\Entity\Question;
  14. use App\Entity\Student;
  15. use App\Entity\Survey;
  16. use App\Entity\SurveySent;
  17. use App\Entity\Trainer;
  18. use App\Entity\Users;
  19. use PhpOffice\PhpSpreadsheet\Spreadsheet;
  20. use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
  21. use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
  22. use PhpParser\Node\Stmt\Else_;
  23. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  24. use Symfony\Component\HttpFoundation\Request;
  25. use Symfony\Component\HttpFoundation\Response;
  26. use Symfony\Component\HttpFoundation\ResponseHeaderBag;
  27. class SurveyController extends DefaultController
  28. {
  29.     public function userSurvey($id)
  30.     {
  31.         $entityManager $this->getDoctrine()->getManager();
  32.         $user $this->getUser();
  33.         if ($user != null) {
  34.             $survey $entityManager->getRepository(SurveySent::class)
  35.                                     ->findOneBy(
  36.                                         array(
  37.                                             'userid'   => $user->getId(),
  38.                                             'status'   => 0,
  39.                                             'surveyid' => $id
  40.                                         )
  41.                                     );
  42.             if ($survey != null) {
  43.                 $SurveyObject $entityManager->getRepository(Survey::class)
  44.                                               ->find($survey->getSurveyid());
  45.                 $currentdate  = new \DateTime();
  46.                 $question $entityManager->getRepository(Question::class)
  47.                                           ->findBy(array(
  48.                                               'type' => $SurveyObject->getType()
  49.                                           ));
  50.                 if ($SurveyObject->getEndDate() > $currentdate and $SurveyObject->getStartDate() < $currentdate) {
  51.                     return $this->render(
  52.                         'user/survey.html.twig',
  53.                         array('questions' => $question'survey' => $survey'SurveyObject' => $SurveyObject)
  54.                     );
  55.                 } else {
  56.                     return $this->redirectToRoute('home');
  57.                 }
  58.             }
  59.         }
  60.         return $this->redirectToRoute('home');
  61.     }
  62.     public function saveSurvey(Request $request)
  63.     {
  64.         $entityManager $this->getDoctrine()->getManager();
  65.         $survey $entityManager->getRepository(SurveySent::class)
  66.                                 ->findOneBy(
  67.                                     array(
  68.                                         'userid'   => $request->request->get('userId'),
  69.                                         'surveyid' => $request->request->get('surveyId'),
  70.                                     )
  71.                                 );
  72.         $survey->setStatus((int)$request->request->get('status'));
  73.         $survey->SetQ1a1((int)$request->request->get('q1a1'));
  74.         $survey->SetQ1a2((int)$request->request->get('q1a2'));
  75.         $survey->SetQ1a3((int)$request->request->get('q1a3'));
  76.         $survey->SetQ1a4((int)$request->request->get('q1a4'));
  77.         $survey->SetQ1a5((int)$request->request->get('q1a5'));
  78.         $survey->SetQ1a6((int)$request->request->get('q1a6'));
  79.         $survey->SetQ1a7((int)$request->request->get('q1a7'));
  80.         $survey->setCat1($request->request->get('cat1'));
  81.         $survey->setexp1($request->request->get('exp1'));
  82.         $survey->SetQ2a1((int)$request->request->get('q2a1'));
  83.         $survey->SetQ2a2((int)$request->request->get('q2a2'));
  84.         $survey->SetQ2a3((int)$request->request->get('q2a3'));
  85.         $survey->SetQ2a4((int)$request->request->get('q2a4'));
  86.         $survey->SetQ2a5((int)$request->request->get('q2a5'));
  87.         $survey->SetQ2a6((int)$request->request->get('q2a6'));
  88.         $survey->SetQ2a7((int)$request->request->get('q2a7'));
  89.         $survey->setCat2($request->request->get('cat2'));
  90.         $survey->setexp2($request->request->get('exp2'));
  91.         $survey->SetQ3a1((int)$request->request->get('q3a1'));
  92.         $survey->SetQ3a2((int)$request->request->get('q3a2'));
  93.         $survey->SetQ3a3((int)$request->request->get('q3a3'));
  94.         $survey->SetQ3a4((int)$request->request->get('q3a4'));
  95.         $survey->SetQ3a5((int)$request->request->get('q3a5'));
  96.         $survey->SetQ3a6((int)$request->request->get('q3a6'));
  97.         $survey->SetQ3a7((int)$request->request->get('q3a7'));
  98.         $survey->setCat3($request->request->get('cat3'));
  99.         $survey->setexp3($request->request->get('exp3'));
  100.         if ($request->request->has('q4a1')) {
  101.             $survey->SetQ4a1((int)$request->request->get('q4a1'));
  102.             $survey->SetQ4a2((int)$request->request->get('q4a2'));
  103.             $survey->SetQ4a3((int)$request->request->get('q4a3'));
  104.             $survey->SetQ4a4((int)$request->request->get('q4a4'));
  105.             $survey->SetQ4a5((int)$request->request->get('q4a5'));
  106.             $survey->SetQ4a6((int)$request->request->get('q4a6'));
  107.             $survey->SetQ4a7((int)$request->request->get('q4a7'));
  108.             $survey->setCat4($request->request->get('cat4'));
  109.             $survey->setexp4($request->request->get('exp4'));
  110.             $survey->SetQ5a1((int)$request->request->get('q5a1'));
  111.             $survey->SetQ5a2((int)$request->request->get('q5a2'));
  112.             $survey->SetQ5a3((int)$request->request->get('q5a3'));
  113.             $survey->SetQ5a4((int)$request->request->get('q5a4'));
  114.             $survey->SetQ5a5((int)$request->request->get('q5a5'));
  115.             $survey->SetQ5a6((int)$request->request->get('q5a6'));
  116.             $survey->SetQ5a7((int)$request->request->get('q5a7'));
  117.             $survey->setCat5($request->request->get('cat5'));
  118.             $survey->setexp5($request->request->get('exp5'));
  119.             $survey->SetQ6a1((int)$request->request->get('q6a1'));
  120.             $survey->SetQ6a2((int)$request->request->get('q6a2'));
  121.             $survey->SetQ6a3((int)$request->request->get('q6a3'));
  122.             $survey->SetQ6a4((int)$request->request->get('q6a4'));
  123.             $survey->SetQ6a5((int)$request->request->get('q6a5'));
  124.             $survey->SetQ6a6((int)$request->request->get('q6a6'));
  125.             $survey->SetQ6a7((int)$request->request->get('q6a7'));
  126.             $survey->setCat6($request->request->get('cat6'));
  127.             $survey->setexp6($request->request->get('exp6'));
  128.             $survey->SetQ7a1((int)$request->request->get('q7a1'));
  129.             $survey->SetQ7a2((int)$request->request->get('q7a2'));
  130.             $survey->SetQ7a3((int)$request->request->get('q7a3'));
  131.             $survey->SetQ7a4((int)$request->request->get('q7a4'));
  132.             $survey->SetQ7a5((int)$request->request->get('q7a5'));
  133.             $survey->SetQ7a6((int)$request->request->get('q7a6'));
  134.             $survey->SetQ7a7((int)$request->request->get('q7a7'));
  135.             $survey->setCat7($request->request->get('cat7'));
  136.             $survey->setexp7($request->request->get('exp7'));
  137.             $survey->SetQ8a1((int)$request->request->get('q8a1'));
  138.             $survey->SetQ8a2((int)$request->request->get('q8a2'));
  139.             $survey->SetQ8a3((int)$request->request->get('q8a3'));
  140.             $survey->SetQ8a4((int)$request->request->get('q8a4'));
  141.             $survey->SetQ8a5((int)$request->request->get('q8a5'));
  142.             $survey->SetQ8a6((int)$request->request->get('q8a6'));
  143.             $survey->SetQ8a7((int)$request->request->get('q8a7'));
  144.             $survey->setCat8($request->request->get('cat8'));
  145.             $survey->setExp8($request->request->get('exp8'));
  146.         }
  147.         $survey->setComment($request->request->get('cat9'));
  148.         $entityManager->persist($survey);
  149.         $entityManager->flush();
  150.         return new Response('success'200);
  151.     }
  152.     public function generateReport($id)
  153.     {
  154.         $entityManager $this->getDoctrine()->getManager();
  155.         $survey $entityManager->getRepository(Survey::class)
  156.                                 ->find($id);
  157.         $questions $entityManager->getRepository(Question::class)
  158.                                    ->findBy(array('type' => $survey->getType()));
  159.         $j         count($questions);
  160.         $spreadsheet = new Spreadsheet();
  161.         $sheet       $spreadsheet->getActiveSheet();
  162.         $sheet->setTitle('reordered');
  163.         $sheet->mergeCells("B1:H1");
  164.         $sheet->mergeCells("L1:Q1");
  165.         $sheet->mergeCells("V1:AB1");
  166.         if ($j 3) {
  167.             $sheet->mergeCells("AF1:AL1");
  168.             $sheet->mergeCells("AP1:AV1");
  169.             $sheet->mergeCells("AZ1:BF1");
  170.             $sheet->mergeCells("BJ1:BP1");
  171.             $sheet->mergeCells("BT1:BZ1");
  172.         }
  173.         if ($j 3) {
  174.             $sheet->setCellValue('B1''Decision Making    ');
  175.             $sheet->setCellValue('L1''Conflict Management    ');
  176.             $sheet->setCellValue('V1''Strategy Setting    ');
  177.             $sheet->setCellValue('AF1''Authority');
  178.             $sheet->setCellValue('AP1''Advocacy    ');
  179.             $sheet->setCellValue('AZ1''Coordination');
  180.             $sheet->setCellValue('BJ1''Critique & Feedback');
  181.             $sheet->setCellValue('BT1''Accountability    ');
  182.         } else {
  183.             $sheet->setCellValue('B1''Decision Making    ');
  184.             $sheet->setCellValue('L1''Conflict Management    ');
  185.             $sheet->setCellValue('V1''Critique & Feedback    ');
  186.         }
  187.         $sheet->setCellValue('A2''ID');
  188.         $sheet->setCellValue('B2''Opp');
  189.         $sheet->setCellValue('C2''1,1');
  190.         $sheet->setCellValue('D2''1,9');
  191.         $sheet->setCellValue('E2''5,5');
  192.         $sheet->setCellValue('F2''9,1');
  193.         $sheet->setCellValue('G2''PAT');
  194.         $sheet->setCellValue('H2''9,9');
  195.         $sheet->setCellValue('I2''High');
  196.         $sheet->setCellValue('J2''Low');
  197.         $sheet->setCellValue('K2''Total Percent Q1');
  198.         $sheet->setCellValue('L2''Opp');
  199.         $sheet->setCellValue('M2''1,1');
  200.         $sheet->setCellValue('N2''1,9');
  201.         $sheet->setCellValue('O2''5,5');
  202.         $sheet->setCellValue('P2''9,1');
  203.         $sheet->setCellValue('Q2''PAT');
  204.         $sheet->setCellValue('R2''9,9');
  205.         $sheet->setCellValue('S2''High');
  206.         $sheet->setCellValue('T2''Low');
  207.         $sheet->setCellValue('U2''Total Percent Q2');
  208.         $sheet->setCellValue('V2''Opp');
  209.         $sheet->setCellValue('W2''1,1');
  210.         $sheet->setCellValue('X2''1,9');
  211.         $sheet->setCellValue('Y2''5,5');
  212.         $sheet->setCellValue('Z2''9,1');
  213.         $sheet->setCellValue('AA2''PAT');
  214.         $sheet->setCellValue('AB2''9,9');
  215.         $sheet->setCellValue('AC2''High');
  216.         $sheet->setCellValue('AD2''Low');
  217.         $sheet->setCellValue('AE2''Total Percent Q3');
  218.         if ($j 3) {
  219.             $sheet->setCellValue('AF2''Opp');
  220.             $sheet->setCellValue('AG2''1,1');
  221.             $sheet->setCellValue('AH2''1,9');
  222.             $sheet->setCellValue('AI2''5,5');
  223.             $sheet->setCellValue('AJ2''9,1');
  224.             $sheet->setCellValue('AK2''PAT');
  225.             $sheet->setCellValue('AL2''9,9');
  226.             $sheet->setCellValue('AM2''High');
  227.             $sheet->setCellValue('AN2''Low');
  228.             $sheet->setCellValue('AO2''Total Percent Q4');
  229.             $sheet->setCellValue('AP2''Opp');
  230.             $sheet->setCellValue('AQ2''1,1');
  231.             $sheet->setCellValue('AR2''1,9');
  232.             $sheet->setCellValue('AS2''5,5');
  233.             $sheet->setCellValue('AT2''9,1');
  234.             $sheet->setCellValue('AU2''PAT');
  235.             $sheet->setCellValue('AV2''9,9');
  236.             $sheet->setCellValue('AW2''High');
  237.             $sheet->setCellValue('AX2''Low');
  238.             $sheet->setCellValue('AY2''Total Percent Q5');
  239.             $sheet->setCellValue('AZ2''Opp');
  240.             $sheet->setCellValue('BA2''1,1');
  241.             $sheet->setCellValue('BB2''1,9');
  242.             $sheet->setCellValue('BC2''5,5');
  243.             $sheet->setCellValue('BD2''9,1');
  244.             $sheet->setCellValue('BE2''PAT');
  245.             $sheet->setCellValue('BF2''9,9');
  246.             $sheet->setCellValue('BG2''High');
  247.             $sheet->setCellValue('BH2''Low');
  248.             $sheet->setCellValue('BI2''Total Percent Q6');
  249.             $sheet->setCellValue('BJ2''Opp');
  250.             $sheet->setCellValue('BK2''1,1');
  251.             $sheet->setCellValue('BL2''1,9');
  252.             $sheet->setCellValue('BM2''5,5');
  253.             $sheet->setCellValue('BN2''9,1');
  254.             $sheet->setCellValue('BO2''PAT');
  255.             $sheet->setCellValue('BP2''9,9');
  256.             $sheet->setCellValue('BQ2''High');
  257.             $sheet->setCellValue('BR2''Low');
  258.             $sheet->setCellValue('BS2''Total Percent Q7');
  259.             $sheet->setCellValue('BT2''Opp');
  260.             $sheet->setCellValue('BU2''1,1');
  261.             $sheet->setCellValue('BV2''1,9');
  262.             $sheet->setCellValue('BW2''5,5');
  263.             $sheet->setCellValue('BX2''9,1');
  264.             $sheet->setCellValue('BY2''PAT');
  265.             $sheet->setCellValue('BZ2''9,9');
  266.             $sheet->setCellValue('CA2''High');
  267.             $sheet->setCellValue('CB2''Low');
  268.             $sheet->setCellValue('CC2''Total Percent Q8');
  269.         }
  270.         $reorderingArray[] = array();
  271.         $j                 0;
  272.         foreach ($questions as $question) {
  273.             $i 0;
  274.             $j++;
  275.             foreach ($question->getAnswers() as $answer) {
  276.                 $i++;
  277.                 if ($j == 1) {
  278.                     if (trim($answer->getDescription()) == 'OPP') {
  279.                         $reorderingArray['q' $j 'a' $i] = 'B';
  280.                     } elseif (trim($answer->getDescription()) == '1,1') {
  281.                         $reorderingArray['q' $j 'a' $i] = 'C';
  282.                     } elseif (trim($answer->getDescription()) == '1,9') {
  283.                         $reorderingArray['q' $j 'a' $i] = 'D';
  284.                     } elseif (trim($answer->getDescription()) == '5,5') {
  285.                         $reorderingArray['q' $j 'a' $i] = 'E';
  286.                     } elseif (trim($answer->getDescription()) == '9,1') {
  287.                         $reorderingArray['q' $j 'a' $i] = 'F';
  288.                     } elseif (trim($answer->getDescription()) == 'PAT') {
  289.                         $reorderingArray['q' $j 'a' $i] = 'G';
  290.                     } elseif (trim($answer->getDescription()) == '9,9') {
  291.                         $reorderingArray['q' $j 'a' $i] = 'H';
  292.                     }
  293.                 } else {
  294.                     if ($j == 2) {
  295.                         if (trim($answer->getDescription()) == 'OPP') {
  296.                             $reorderingArray['q' $j 'a' $i] = 'L';
  297.                         } elseif (trim($answer->getDescription()) == '1,1') {
  298.                             $reorderingArray['q' $j 'a' $i] = 'M';
  299.                         } elseif (trim($answer->getDescription()) == '1,9') {
  300.                             $reorderingArray['q' $j 'a' $i] = 'N';
  301.                         } elseif (trim($answer->getDescription()) == '5,5') {
  302.                             $reorderingArray['q' $j 'a' $i] = 'O';
  303.                         } elseif (trim($answer->getDescription()) == '9,1') {
  304.                             $reorderingArray['q' $j 'a' $i] = 'P';
  305.                         } elseif (trim($answer->getDescription()) == 'PAT') {
  306.                             $reorderingArray['q' $j 'a' $i] = 'Q';
  307.                         } elseif (trim($answer->getDescription()) == '9,9') {
  308.                             $reorderingArray['q' $j 'a' $i] = 'R';
  309.                         }
  310.                     } else {
  311.                         if ($j == 3) {
  312.                             if (trim($answer->getDescription()) == 'OPP') {
  313.                                 $reorderingArray['q' $j 'a' $i] = 'V';
  314.                             } elseif (trim($answer->getDescription()) == '1,1') {
  315.                                 $reorderingArray['q' $j 'a' $i] = 'W';
  316.                             } elseif (trim($answer->getDescription()) == '1,9') {
  317.                                 $reorderingArray['q' $j 'a' $i] = 'X';
  318.                             } elseif (trim($answer->getDescription()) == '5,5') {
  319.                                 $reorderingArray['q' $j 'a' $i] = 'Y';
  320.                             } elseif (trim($answer->getDescription()) == '9,1') {
  321.                                 $reorderingArray['q' $j 'a' $i] = 'Z';
  322.                             } elseif (trim($answer->getDescription()) == 'PAT') {
  323.                                 $reorderingArray['q' $j 'a' $i] = 'AA';
  324.                             } elseif (trim($answer->getDescription()) == '9,9') {
  325.                                 $reorderingArray['q' $j 'a' $i] = 'AB';
  326.                             }
  327.                         } else {
  328.                             if ($j == 4) {
  329.                                 if (trim($answer->getDescription()) == 'OPP') {
  330.                                     $reorderingArray['q' $j 'a' $i] = 'AF';
  331.                                 } elseif (trim($answer->getDescription()) == '1,1') {
  332.                                     $reorderingArray['q' $j 'a' $i] = 'AG';
  333.                                 } elseif (trim($answer->getDescription()) == '1,9') {
  334.                                     $reorderingArray['q' $j 'a' $i] = 'AH';
  335.                                 } elseif (trim($answer->getDescription()) == '5,5') {
  336.                                     $reorderingArray['q' $j 'a' $i] = 'AI';
  337.                                 } elseif (trim($answer->getDescription()) == '9,1') {
  338.                                     $reorderingArray['q' $j 'a' $i] = 'AJ';
  339.                                 } elseif (trim($answer->getDescription()) == 'PAT') {
  340.                                     $reorderingArray['q' $j 'a' $i] = 'AK';
  341.                                 } elseif (trim($answer->getDescription()) == '9,9') {
  342.                                     $reorderingArray['q' $j 'a' $i] = 'AL';
  343.                                 }
  344.                             } else {
  345.                                 if ($j == 5) {
  346.                                     if (trim($answer->getDescription()) == 'OPP') {
  347.                                         $reorderingArray['q' $j 'a' $i] = 'AP';
  348.                                     } elseif (trim($answer->getDescription()) == '1,1') {
  349.                                         $reorderingArray['q' $j 'a' $i] = 'AQ';
  350.                                     } elseif (trim($answer->getDescription()) == '1,9') {
  351.                                         $reorderingArray['q' $j 'a' $i] = 'AR';
  352.                                     } elseif (trim($answer->getDescription()) == '5,5') {
  353.                                         $reorderingArray['q' $j 'a' $i] = 'AS';
  354.                                     } elseif (trim($answer->getDescription()) == '9,1') {
  355.                                         $reorderingArray['q' $j 'a' $i] = 'AT';
  356.                                     } elseif (trim($answer->getDescription()) == 'PAT') {
  357.                                         $reorderingArray['q' $j 'a' $i] = 'AU';
  358.                                     } elseif (trim($answer->getDescription()) == '9,9') {
  359.                                         $reorderingArray['q' $j 'a' $i] = 'AV';
  360.                                     }
  361.                                 } else {
  362.                                     if ($j == 6) {
  363.                                         if (trim($answer->getDescription()) == 'OPP') {
  364.                                             $reorderingArray['q' $j 'a' $i] = 'AZ';
  365.                                         } elseif (trim($answer->getDescription()) == '1,1') {
  366.                                             $reorderingArray['q' $j 'a' $i] = 'BA';
  367.                                         } elseif (trim($answer->getDescription()) == '1,9') {
  368.                                             $reorderingArray['q' $j 'a' $i] = 'BB';
  369.                                         } elseif (trim($answer->getDescription()) == '5,5') {
  370.                                             $reorderingArray['q' $j 'a' $i] = 'BC';
  371.                                         } elseif (trim($answer->getDescription()) == '9,1') {
  372.                                             $reorderingArray['q' $j 'a' $i] = 'BD';
  373.                                         } elseif (trim($answer->getDescription()) == 'PAT') {
  374.                                             $reorderingArray['q' $j 'a' $i] = 'BE';
  375.                                         } elseif (trim($answer->getDescription()) == '9,9') {
  376.                                             $reorderingArray['q' $j 'a' $i] = 'BF';
  377.                                         }
  378.                                     } else {
  379.                                         if ($j == 7) {
  380.                                             if (trim($answer->getDescription()) == 'OPP') {
  381.                                                 $reorderingArray['q' $j 'a' $i] = 'BJ';
  382.                                             } elseif (trim($answer->getDescription()) == '1,1') {
  383.                                                 $reorderingArray['q' $j 'a' $i] = 'BK';
  384.                                             } elseif (trim($answer->getDescription()) == '1,9') {
  385.                                                 $reorderingArray['q' $j 'a' $i] = 'BL';
  386.                                             } elseif (trim($answer->getDescription()) == '5,5') {
  387.                                                 $reorderingArray['q' $j 'a' $i] = 'BM';
  388.                                             } elseif (trim($answer->getDescription()) == '9,1') {
  389.                                                 $reorderingArray['q' $j 'a' $i] = 'BN';
  390.                                             } elseif (trim($answer->getDescription()) == 'PAT') {
  391.                                                 $reorderingArray['q' $j 'a' $i] = 'BO';
  392.                                             } elseif (trim($answer->getDescription()) == '9,9') {
  393.                                                 $reorderingArray['q' $j 'a' $i] = 'BP';
  394.                                             }
  395.                                         } else {
  396.                                             if ($j == 8) {
  397.                                                 if (trim($answer->getDescription()) == 'OPP') {
  398.                                                     $reorderingArray['q' $j 'a' $i] = 'BT';
  399.                                                 } elseif (trim($answer->getDescription()) == '1,1') {
  400.                                                     $reorderingArray['q' $j 'a' $i] = 'BU';
  401.                                                 } elseif (trim($answer->getDescription()) == '1,9') {
  402.                                                     $reorderingArray['q' $j 'a' $i] = 'BV';
  403.                                                 } elseif (trim($answer->getDescription()) == '5,5') {
  404.                                                     $reorderingArray['q' $j 'a' $i] = 'BW';
  405.                                                 } elseif (trim($answer->getDescription()) == '9,1') {
  406.                                                     $reorderingArray['q' $j 'a' $i] = 'BX';
  407.                                                 } elseif (trim($answer->getDescription()) == 'PAT') {
  408.                                                     $reorderingArray['q' $j 'a' $i] = 'BY';
  409.                                                 } elseif (trim($answer->getDescription()) == '9,9') {
  410.                                                     $reorderingArray['q' $j 'a' $i] = 'BZ';
  411.                                                 }
  412.                                             }
  413.                                         }
  414.                                     }
  415.                                 }
  416.                             }
  417.                         }
  418.                     }
  419.                 }
  420.             }
  421.         }
  422.         $conn $entityManager->getConnection();
  423.         $sql  'SELECT * FROM `student_survey`,users,team,student WHERE users.id=student.id and student.team_id=team.id and student_id= users.id and survey_id= :survey_id';
  424.         $stmt $conn->prepare($sql);
  425.         $stmt->execute(['survey_id' => $id]);
  426.         $data       $stmt->fetchAll();
  427.         $rowNB      3;
  428.         $avarageROW = array();
  429.         foreach ($data as $student) {
  430.             $q1Answers = array(
  431.                 $student['q1a1'],
  432.                 $student['q1a2'],
  433.                 $student['q1a3'],
  434.                 $student['q1a4'],
  435.                 $student['q1a5'],
  436.                 $student['q1a6'],
  437.                 $student['q1a7'],
  438.             );
  439.             if (array_sum($q1Answers) == 100) {
  440.                 $avarageROW['q1a1'][] = $student['q1a1'];
  441.                 $avarageROW['q1a2'][] = $student['q1a2'];
  442.                 $avarageROW['q1a3'][] = $student['q1a3'];
  443.                 $avarageROW['q1a4'][] = $student['q1a4'];
  444.                 $avarageROW['q1a5'][] = $student['q1a5'];
  445.                 $avarageROW['q1a6'][] = $student['q1a6'];
  446.                 $avarageROW['q1a7'][] = $student['q1a7'];
  447.                 $avarageROW['q1L'][]  = min($q1Answers);
  448.                 $avarageROW['q1H'][] = max($q1Answers);
  449.                 $sheet->setCellValue('I' $rowNBmax($q1Answers));
  450.                 $sheet->setCellValue('J' $rowNBmin($q1Answers));
  451.                 $sheet->setCellValue('K' $rowNBarray_sum($q1Answers));
  452.                 $sheet->setCellValue($reorderingArray['q1a1'] . $rowNB$student['q1a1']);
  453.                 $sheet->setCellValue($reorderingArray['q1a2'] . $rowNB$student['q1a2']);
  454.                 $sheet->setCellValue($reorderingArray['q1a3'] . $rowNB$student['q1a3']);
  455.                 $sheet->setCellValue($reorderingArray['q1a4'] . $rowNB$student['q1a4']);
  456.                 $sheet->setCellValue($reorderingArray['q1a5'] . $rowNB$student['q1a5']);
  457.                 $sheet->setCellValue($reorderingArray['q1a6'] . $rowNB$student['q1a6']);
  458.                 $sheet->setCellValue($reorderingArray['q1a7'] . $rowNB$student['q1a7']);
  459.             }
  460.             $q2Answers = array(
  461.                 $student['q2a1'],
  462.                 $student['q2a2'],
  463.                 $student['q2a3'],
  464.                 $student['q2a4'],
  465.                 $student['q2a5'],
  466.                 $student['q2a6'],
  467.                 $student['q2a7'],
  468.             );
  469.             if (array_sum($q2Answers) == 100) {
  470.                 $avarageROW['q2a1'][] = $student['q2a1'];
  471.                 $avarageROW['q2a2'][] = $student['q2a2'];
  472.                 $avarageROW['q2a3'][] = $student['q2a3'];
  473.                 $avarageROW['q2a4'][] = $student['q2a4'];
  474.                 $avarageROW['q2a5'][] = $student['q2a5'];
  475.                 $avarageROW['q2a6'][] = $student['q2a6'];
  476.                 $avarageROW['q2a7'][] = $student['q2a7'];
  477.                 $avarageROW['q2H'][]  = max($q2Answers);
  478.                 $avarageROW['q2L'][]  = min($q2Answers);
  479.                 $sheet->setCellValue('S' $rowNBmax($q2Answers));
  480.                 $sheet->setCellValue('T' $rowNBmin($q2Answers));
  481.                 $sheet->setCellValue('u' $rowNBarray_sum($q2Answers));
  482.                 $sheet->setCellValue($reorderingArray['q2a1'] . $rowNB$student['q2a1']);
  483.                 $sheet->setCellValue($reorderingArray['q2a2'] . $rowNB$student['q2a2']);
  484.                 $sheet->setCellValue($reorderingArray['q2a3'] . $rowNB$student['q2a3']);
  485.                 $sheet->setCellValue($reorderingArray['q2a4'] . $rowNB$student['q2a4']);
  486.                 $sheet->setCellValue($reorderingArray['q2a5'] . $rowNB$student['q2a5']);
  487.                 $sheet->setCellValue($reorderingArray['q2a6'] . $rowNB$student['q2a6']);
  488.                 $sheet->setCellValue($reorderingArray['q2a7'] . $rowNB$student['q2a7']);
  489.             }
  490.             $q3Answers = array(
  491.                 $student['q3a1'],
  492.                 $student['q3a2'],
  493.                 $student['q3a3'],
  494.                 $student['q3a4'],
  495.                 $student['q3a5'],
  496.                 $student['q3a6'],
  497.                 $student['q3a7'],
  498.             );
  499.             if (array_sum($q3Answers) == 100) {
  500.                 $avarageROW['q3a1'][] = $student['q3a1'];
  501.                 $avarageROW['q3a2'][] = $student['q3a2'];
  502.                 $avarageROW['q3a3'][] = $student['q3a3'];
  503.                 $avarageROW['q3a4'][] = $student['q3a4'];
  504.                 $avarageROW['q3a5'][] = $student['q3a5'];
  505.                 $avarageROW['q3a6'][] = $student['q3a6'];
  506.                 $avarageROW['q3a7'][] = $student['q3a7'];
  507.                 $avarageROW['q3H'][]  = max($q3Answers);
  508.                 $avarageROW['q3L'][]  = min($q3Answers);
  509.                 $sheet->setCellValue('AC' $rowNBmax($q3Answers));
  510.                 $sheet->setCellValue('AD' $rowNBmin($q3Answers));
  511.                 $sheet->setCellValue('AE' $rowNBarray_sum($q3Answers));
  512.                 $sheet->setCellValue($reorderingArray['q3a1'] . $rowNB$student['q3a1']);
  513.                 $sheet->setCellValue($reorderingArray['q3a2'] . $rowNB$student['q3a2']);
  514.                 $sheet->setCellValue($reorderingArray['q3a3'] . $rowNB$student['q3a3']);
  515.                 $sheet->setCellValue($reorderingArray['q3a4'] . $rowNB$student['q3a4']);
  516.                 $sheet->setCellValue($reorderingArray['q3a5'] . $rowNB$student['q3a5']);
  517.                 $sheet->setCellValue($reorderingArray['q3a6'] . $rowNB$student['q3a6']);
  518.                 $sheet->setCellValue($reorderingArray['q3a7'] . $rowNB$student['q3a7']);
  519.             }
  520.             if ($j 3) {
  521.                 $q4Answers = array(
  522.                     $student['q4a1'],
  523.                     $student['q4a2'],
  524.                     $student['q4a3'],
  525.                     $student['q4a4'],
  526.                     $student['q4a5'],
  527.                     $student['q4a6'],
  528.                     $student['q4a7'],
  529.                 );
  530.                 if (array_sum($q4Answers) == 100) {
  531.                     $avarageROW['q4a1'][] = $student['q4a1'];
  532.                     $avarageROW['q4a2'][] = $student['q4a2'];
  533.                     $avarageROW['q4a3'][] = $student['q4a3'];
  534.                     $avarageROW['q4a4'][] = $student['q4a4'];
  535.                     $avarageROW['q4a5'][] = $student['q4a5'];
  536.                     $avarageROW['q4a6'][] = $student['q4a6'];
  537.                     $avarageROW['q4a7'][] = $student['q4a7'];
  538.                     $avarageROW['q4H'][]  = max($q4Answers);
  539.                     $avarageROW['q4L'][]  = min($q4Answers);
  540.                     $sheet->setCellValue('AM' $rowNBmax($q4Answers));
  541.                     $sheet->setCellValue('AN' $rowNBmin($q4Answers));
  542.                     $sheet->setCellValue('AO' $rowNBarray_sum($q4Answers));
  543.                     $sheet->setCellValue($reorderingArray['q4a1'] . $rowNB$student['q4a1']);
  544.                     $sheet->setCellValue($reorderingArray['q4a2'] . $rowNB$student['q4a2']);
  545.                     $sheet->setCellValue($reorderingArray['q4a3'] . $rowNB$student['q4a3']);
  546.                     $sheet->setCellValue($reorderingArray['q4a4'] . $rowNB$student['q4a4']);
  547.                     $sheet->setCellValue($reorderingArray['q4a5'] . $rowNB$student['q4a5']);
  548.                     $sheet->setCellValue($reorderingArray['q4a6'] . $rowNB$student['q4a6']);
  549.                     $sheet->setCellValue($reorderingArray['q4a7'] . $rowNB$student['q4a7']);
  550.                 }
  551.                 $q5Answers = array(
  552.                     $student['q5a1'],
  553.                     $student['q5a2'],
  554.                     $student['q5a3'],
  555.                     $student['q5a4'],
  556.                     $student['q5a5'],
  557.                     $student['q5a6'],
  558.                     $student['q5a7'],
  559.                 );
  560.                 if (array_sum($q5Answers) == 100) {
  561.                     $avarageROW['q5a1'][] = $student['q5a1'];
  562.                     $avarageROW['q5a2'][] = $student['q5a2'];
  563.                     $avarageROW['q5a3'][] = $student['q5a3'];
  564.                     $avarageROW['q5a4'][] = $student['q5a4'];
  565.                     $avarageROW['q5a5'][] = $student['q5a5'];
  566.                     $avarageROW['q5a6'][] = $student['q5a6'];
  567.                     $avarageROW['q5a7'][] = $student['q5a7'];
  568.                     $avarageROW['q5H'][]  = max($q5Answers);
  569.                     $avarageROW['q5L'][]  = min($q5Answers);
  570.                     $sheet->setCellValue('AW' $rowNBmax($q5Answers));
  571.                     $sheet->setCellValue('AX' $rowNBmin($q5Answers));
  572.                     $sheet->setCellValue('AY' $rowNBarray_sum($q5Answers));
  573.                     $sheet->setCellValue($reorderingArray['q5a1'] . $rowNB$student['q5a1']);
  574.                     $sheet->setCellValue($reorderingArray['q5a2'] . $rowNB$student['q5a2']);
  575.                     $sheet->setCellValue($reorderingArray['q5a3'] . $rowNB$student['q5a3']);
  576.                     $sheet->setCellValue($reorderingArray['q5a4'] . $rowNB$student['q5a4']);
  577.                     $sheet->setCellValue($reorderingArray['q5a5'] . $rowNB$student['q5a5']);
  578.                     $sheet->setCellValue($reorderingArray['q5a6'] . $rowNB$student['q5a6']);
  579.                     $sheet->setCellValue($reorderingArray['q5a7'] . $rowNB$student['q5a7']);
  580.                 }
  581.                 $q6Answers = array(
  582.                     $student['q6a1'],
  583.                     $student['q6a2'],
  584.                     $student['q6a3'],
  585.                     $student['q6a4'],
  586.                     $student['q6a5'],
  587.                     $student['q6a6'],
  588.                     $student['q6a7'],
  589.                 );
  590.                 if (array_sum($q6Answers) == 100) {
  591.                     $avarageROW['q6a1'][] = $student['q6a1'];
  592.                     $avarageROW['q6a2'][] = $student['q6a2'];
  593.                     $avarageROW['q6a3'][] = $student['q6a3'];
  594.                     $avarageROW['q6a4'][] = $student['q6a4'];
  595.                     $avarageROW['q6a5'][] = $student['q6a5'];
  596.                     $avarageROW['q6a6'][] = $student['q6a6'];
  597.                     $avarageROW['q6a7'][] = $student['q6a7'];
  598.                     $avarageROW['q6H'][]  = max($q6Answers);
  599.                     $avarageROW['q6L'][]  = min($q6Answers);
  600.                     $sheet->setCellValue('BG' $rowNBmax($q6Answers));
  601.                     $sheet->setCellValue('BH' $rowNBmin($q6Answers));
  602.                     $sheet->setCellValue('BI' $rowNBarray_sum($q6Answers));
  603.                     $sheet->setCellValue($reorderingArray['q6a1'] . $rowNB$student['q6a1']);
  604.                     $sheet->setCellValue($reorderingArray['q6a2'] . $rowNB$student['q6a2']);
  605.                     $sheet->setCellValue($reorderingArray['q6a3'] . $rowNB$student['q6a3']);
  606.                     $sheet->setCellValue($reorderingArray['q6a4'] . $rowNB$student['q6a4']);
  607.                     $sheet->setCellValue($reorderingArray['q6a5'] . $rowNB$student['q6a5']);
  608.                     $sheet->setCellValue($reorderingArray['q6a6'] . $rowNB$student['q6a6']);
  609.                     $sheet->setCellValue($reorderingArray['q6a7'] . $rowNB$student['q6a7']);
  610.                 }
  611.                 $q7Answers = array(
  612.                     $student['q7a1'],
  613.                     $student['q7a2'],
  614.                     $student['q7a3'],
  615.                     $student['q7a4'],
  616.                     $student['q7a5'],
  617.                     $student['q7a6'],
  618.                     $student['q7a7'],
  619.                 );
  620.                 if (array_sum($q7Answers) == 100) {
  621.                     $avarageROW['q7a1'][] = $student['q7a1'];
  622.                     $avarageROW['q7a2'][] = $student['q7a2'];
  623.                     $avarageROW['q7a3'][] = $student['q7a3'];
  624.                     $avarageROW['q7a4'][] = $student['q7a4'];
  625.                     $avarageROW['q7a5'][] = $student['q7a5'];
  626.                     $avarageROW['q7a6'][] = $student['q7a6'];
  627.                     $avarageROW['q7a7'][] = $student['q7a7'];
  628.                     $avarageROW['q7H'][]  = max($q7Answers);
  629.                     $avarageROW['q7L'][]  = min($q7Answers);
  630.                     $sheet->setCellValue('BQ' $rowNBmax($q7Answers));
  631.                     $sheet->setCellValue('BR' $rowNBmin($q7Answers));
  632.                     $sheet->setCellValue('BS' $rowNBarray_sum($q7Answers));
  633.                     $sheet->setCellValue($reorderingArray['q7a1'] . $rowNB$student['q7a1']);
  634.                     $sheet->setCellValue($reorderingArray['q7a2'] . $rowNB$student['q7a2']);
  635.                     $sheet->setCellValue($reorderingArray['q7a3'] . $rowNB$student['q7a3']);
  636.                     $sheet->setCellValue($reorderingArray['q7a4'] . $rowNB$student['q7a4']);
  637.                     $sheet->setCellValue($reorderingArray['q7a5'] . $rowNB$student['q7a5']);
  638.                     $sheet->setCellValue($reorderingArray['q7a6'] . $rowNB$student['q7a6']);
  639.                     $sheet->setCellValue($reorderingArray['q7a7'] . $rowNB$student['q7a7']);
  640.                 }
  641.                 $q8Answers = array(
  642.                     $student['q8a1'],
  643.                     $student['q8a2'],
  644.                     $student['q8a3'],
  645.                     $student['q8a4'],
  646.                     $student['q8a5'],
  647.                     $student['q8a6'],
  648.                     $student['q8a7'],
  649.                 );
  650.                 if (array_sum($q8Answers) == 100) {
  651.                     $avarageROW['q8a1'][] = $student['q8a1'];
  652.                     $avarageROW['q8a2'][] = $student['q8a2'];
  653.                     $avarageROW['q8a3'][] = $student['q8a3'];
  654.                     $avarageROW['q8a4'][] = $student['q8a4'];
  655.                     $avarageROW['q8a5'][] = $student['q8a5'];
  656.                     $avarageROW['q8a6'][] = $student['q8a6'];
  657.                     $avarageROW['q8a7'][] = $student['q8a7'];
  658.                     $avarageROW['q8H'][] = max($q8Answers);
  659.                     $avarageROW['q8L'][] = min($q8Answers);
  660.                     $sheet->setCellValue('CA' $rowNBmax($q8Answers));
  661.                     $sheet->setCellValue('CB' $rowNBmin($q8Answers));
  662.                     $sheet->setCellValue('CC' $rowNBarray_sum($q8Answers));
  663.                     $sheet->setCellValue($reorderingArray['q8a1'] . $rowNB$student['q8a1']);
  664.                     $sheet->setCellValue($reorderingArray['q8a2'] . $rowNB$student['q8a2']);
  665.                     $sheet->setCellValue($reorderingArray['q8a3'] . $rowNB$student['q8a3']);
  666.                     $sheet->setCellValue($reorderingArray['q8a4'] . $rowNB$student['q8a4']);
  667.                     $sheet->setCellValue($reorderingArray['q8a5'] . $rowNB$student['q8a5']);
  668.                     $sheet->setCellValue($reorderingArray['q8a6'] . $rowNB$student['q8a6']);
  669.                     $sheet->setCellValue($reorderingArray['q8a7'] . $rowNB$student['q8a7']);
  670.                 }
  671.             }
  672.             $sheet->setCellValue('CD' $rowNB$student['username']);
  673.             $sheet->setCellValue('CE' $rowNB$student['first_name']);
  674.             $rowNB++;
  675.         }
  676.         $sheet->mergeCells("B" $rowNB ":H" $rowNB "");
  677.         $sheet->mergeCells("L" $rowNB ":Q" $rowNB "");
  678.         $sheet->mergeCells("V" $rowNB ":AB" $rowNB "");
  679.         if ($j 3) {
  680.             $sheet->mergeCells("AF" $rowNB ":AL" $rowNB "");
  681.             $sheet->mergeCells("AP" $rowNB ":AV" $rowNB "");
  682.             $sheet->mergeCells("AZ" $rowNB ":BF" $rowNB "");
  683.             $sheet->mergeCells("BJ" $rowNB ":BP" $rowNB "");
  684.             $sheet->mergeCells("BT" $rowNB ":BZ" $rowNB "");
  685.         }
  686.         if ($j 3) {
  687.             $sheet->setCellValue('B' $rowNB '''Decision Making    ');
  688.             $sheet->setCellValue('L' $rowNB '''Conflict Management    ');
  689.             $sheet->setCellValue('V' $rowNB '''Strategy Setting    ');
  690.             $sheet->setCellValue('AF' $rowNB '''Authority');
  691.             $sheet->setCellValue('AP' $rowNB '''Advocacy    ');
  692.             $sheet->setCellValue('AZ' $rowNB '''Coordination');
  693.             $sheet->setCellValue('BJ' $rowNB '''Critique & Feedback');
  694.             $sheet->setCellValue('BT' $rowNB '''Accountability    ');
  695.         } else {
  696.             $sheet->setCellValue('B' $rowNB '''Decision Making    ');
  697.             $sheet->setCellValue('L' $rowNB '''Conflict Management    ');
  698.             $sheet->setCellValue('V' $rowNB '''Critique & Feedback    ');
  699.         }
  700.         $rowNB++;
  701.         $sheet->setCellValue('A' $rowNB '''ID');
  702.         $sheet->setCellValue('B' $rowNB '''Opp');
  703.         $sheet->setCellValue('C' $rowNB '''1,1');
  704.         $sheet->setCellValue('D' $rowNB '''1,9');
  705.         $sheet->setCellValue('E' $rowNB '''5,5');
  706.         $sheet->setCellValue('F' $rowNB '''9,1');
  707.         $sheet->setCellValue('G' $rowNB '''PAT');
  708.         $sheet->setCellValue('H' $rowNB '''9,9');
  709.         $sheet->setCellValue('I' $rowNB '''High');
  710.         $sheet->setCellValue('J' $rowNB '''Low');
  711.         $sheet->setCellValue('K' $rowNB '''Total Percent Q1');
  712.         $sheet->setCellValue('L' $rowNB '''Opp');
  713.         $sheet->setCellValue('M' $rowNB '''1,1');
  714.         $sheet->setCellValue('N' $rowNB '''1,9');
  715.         $sheet->setCellValue('O' $rowNB '''5,5');
  716.         $sheet->setCellValue('P' $rowNB '''9,1');
  717.         $sheet->setCellValue('Q' $rowNB '''PAT');
  718.         $sheet->setCellValue('R' $rowNB '''9,9');
  719.         $sheet->setCellValue('S' $rowNB '''High');
  720.         $sheet->setCellValue('T' $rowNB '''Low');
  721.         $sheet->setCellValue('U' $rowNB '''Total Percent Q2');
  722.         $sheet->setCellValue('V' $rowNB '''Opp');
  723.         $sheet->setCellValue('W' $rowNB '''1,1');
  724.         $sheet->setCellValue('X' $rowNB '''1,9');
  725.         $sheet->setCellValue('Y' $rowNB '''5,5');
  726.         $sheet->setCellValue('Z' $rowNB '''9,1');
  727.         $sheet->setCellValue('AA' $rowNB '''PAT');
  728.         $sheet->setCellValue('AB' $rowNB '''9,9');
  729.         $sheet->setCellValue('AC' $rowNB '''High');
  730.         $sheet->setCellValue('AD' $rowNB '''Low');
  731.         $sheet->setCellValue('AE' $rowNB '''Total Percent Q3');
  732.         if ($j 3) {
  733.             $sheet->setCellValue('AF' $rowNB '''Opp');
  734.             $sheet->setCellValue('AG' $rowNB '''1,1');
  735.             $sheet->setCellValue('AH' $rowNB '''1,9');
  736.             $sheet->setCellValue('AI' $rowNB '''5,5');
  737.             $sheet->setCellValue('AJ' $rowNB '''9,1');
  738.             $sheet->setCellValue('AK' $rowNB '''PAT');
  739.             $sheet->setCellValue('AL' $rowNB '''9,9');
  740.             $sheet->setCellValue('AM' $rowNB '''High');
  741.             $sheet->setCellValue('AN' $rowNB '''Low');
  742.             $sheet->setCellValue('AO' $rowNB '''Total Percent Q4');
  743.             $sheet->setCellValue('AP' $rowNB '''Opp');
  744.             $sheet->setCellValue('AQ' $rowNB '''1,1');
  745.             $sheet->setCellValue('AR' $rowNB '''1,9');
  746.             $sheet->setCellValue('AS' $rowNB '''5,5');
  747.             $sheet->setCellValue('AT' $rowNB '''9,1');
  748.             $sheet->setCellValue('AU' $rowNB '''PAT');
  749.             $sheet->setCellValue('AV' $rowNB '''9,9');
  750.             $sheet->setCellValue('AW' $rowNB '''High');
  751.             $sheet->setCellValue('AX' $rowNB '''Low');
  752.             $sheet->setCellValue('AY' $rowNB '''Total Percent Q5');
  753.             $sheet->setCellValue('AZ' $rowNB '''Opp');
  754.             $sheet->setCellValue('BA' $rowNB '''1,1');
  755.             $sheet->setCellValue('BB' $rowNB '''1,9');
  756.             $sheet->setCellValue('BC' $rowNB '''5,5');
  757.             $sheet->setCellValue('BD' $rowNB '''9,1');
  758.             $sheet->setCellValue('BE' $rowNB '''PAT');
  759.             $sheet->setCellValue('BF' $rowNB '''9,9');
  760.             $sheet->setCellValue('BG' $rowNB '''High');
  761.             $sheet->setCellValue('BH' $rowNB '''Low');
  762.             $sheet->setCellValue('BI' $rowNB '''Total Percent Q6');
  763.             $sheet->setCellValue('BJ' $rowNB '''Opp');
  764.             $sheet->setCellValue('BK' $rowNB '''1,1');
  765.             $sheet->setCellValue('BL' $rowNB '''1,9');
  766.             $sheet->setCellValue('BM' $rowNB '''5,5');
  767.             $sheet->setCellValue('BN' $rowNB '''9,1');
  768.             $sheet->setCellValue('BO' $rowNB '''PAT');
  769.             $sheet->setCellValue('BP' $rowNB '''9,9');
  770.             $sheet->setCellValue('BQ' $rowNB '''High');
  771.             $sheet->setCellValue('BR' $rowNB '''Low');
  772.             $sheet->setCellValue('BS' $rowNB '''Total Percent Q7');
  773.             $sheet->setCellValue('BT' $rowNB '''Opp');
  774.             $sheet->setCellValue('BU' $rowNB '''1,1');
  775.             $sheet->setCellValue('BV' $rowNB '''1,9');
  776.             $sheet->setCellValue('BW' $rowNB '''5,5');
  777.             $sheet->setCellValue('BX' $rowNB '''9,1');
  778.             $sheet->setCellValue('BY' $rowNB '''PAT');
  779.             $sheet->setCellValue('BZ' $rowNB '''9,9');
  780.             $sheet->setCellValue('CA' $rowNB '''High');
  781.             $sheet->setCellValue('CB' $rowNB '''Low');
  782.             $sheet->setCellValue('CC' $rowNB '''Total Percent Q8');
  783.         }
  784.         $rowNB++;
  785.         if (!empty($avarageROW)) {
  786. //        $sheet->setCellValue('I' . $rowNB, array_sum($avarageROW['q1H']) / count($avarageROW['q1H']));
  787. //        $sheet->setCellValue('J' . $rowNB, array_sum($avarageROW['q1L']) / count($avarageROW['q1L']));
  788.             $sheet->setCellValue('I' $rowNBmax($avarageROW['q1H']));
  789.             $sheet->setCellValue('J' $rowNBmin($avarageROW['q1L']));
  790.             $sheet->setCellValue($reorderingArray['q1a1'] . $rowNBarray_sum($avarageROW['q1a1']) / count($avarageROW['q1a1']));
  791.             $sheet->setCellValue($reorderingArray['q1a2'] . $rowNBarray_sum($avarageROW['q1a2']) / count($avarageROW['q1a2']));
  792.             $sheet->setCellValue($reorderingArray['q1a3'] . $rowNBarray_sum($avarageROW['q1a3']) / count($avarageROW['q1a3']));
  793.             $sheet->setCellValue($reorderingArray['q1a4'] . $rowNBarray_sum($avarageROW['q1a4']) / count($avarageROW['q1a4']));
  794.             $sheet->setCellValue($reorderingArray['q1a5'] . $rowNBarray_sum($avarageROW['q1a5']) / count($avarageROW['q1a5']));
  795.             $sheet->setCellValue($reorderingArray['q1a6'] . $rowNBarray_sum($avarageROW['q1a6']) / count($avarageROW['q1a6']));
  796.             $sheet->setCellValue($reorderingArray['q1a7'] . $rowNBarray_sum($avarageROW['q1a7']) / count($avarageROW['q1a7']));
  797. //        $sheet->setCellValue('S' . $rowNB, array_sum($avarageROW['q2H']) / count($avarageROW['q2H']));
  798. //        $sheet->setCellValue('T' . $rowNB, array_sum($avarageROW['q2L']) / count($avarageROW['q2L']));
  799.             $sheet->setCellValue('S' $rowNBmax($avarageROW['q2H']));
  800.             $sheet->setCellValue('T' $rowNBmin($avarageROW['q2L']));
  801.             $sheet->setCellValue($reorderingArray['q2a1'] . $rowNBarray_sum($avarageROW['q2a1']) / count($avarageROW['q2a1']));
  802.             $sheet->setCellValue($reorderingArray['q2a2'] . $rowNBarray_sum($avarageROW['q2a2']) / count($avarageROW['q2a2']));
  803.             $sheet->setCellValue($reorderingArray['q2a3'] . $rowNBarray_sum($avarageROW['q2a3']) / count($avarageROW['q2a3']));
  804.             $sheet->setCellValue($reorderingArray['q2a4'] . $rowNBarray_sum($avarageROW['q2a4']) / count($avarageROW['q2a4']));
  805.             $sheet->setCellValue($reorderingArray['q2a5'] . $rowNBarray_sum($avarageROW['q2a5']) / count($avarageROW['q2a5']));
  806.             $sheet->setCellValue($reorderingArray['q2a6'] . $rowNBarray_sum($avarageROW['q2a6']) / count($avarageROW['q2a6']));
  807.             $sheet->setCellValue($reorderingArray['q2a7'] . $rowNBarray_sum($avarageROW['q2a7']) / count($avarageROW['q2a7']));
  808. //        $sheet->setCellValue('AC' . $rowNB, array_sum($avarageROW['q3H']) / count($avarageROW['q3H']));
  809. //        $sheet->setCellValue('AD' . $rowNB, array_sum($avarageROW['q3L']) / count($avarageROW['q3L']));
  810.             $sheet->setCellValue('AC' $rowNBmax($avarageROW['q3H']));
  811.             $sheet->setCellValue('AD' $rowNBmin($avarageROW['q3L']));
  812.             $sheet->setCellValue($reorderingArray['q3a1'] . $rowNBarray_sum($avarageROW['q3a1']) / count($avarageROW['q3a1']));
  813.             $sheet->setCellValue($reorderingArray['q3a2'] . $rowNBarray_sum($avarageROW['q3a2']) / count($avarageROW['q3a2']));
  814.             $sheet->setCellValue($reorderingArray['q3a3'] . $rowNBarray_sum($avarageROW['q3a3']) / count($avarageROW['q3a3']));
  815.             $sheet->setCellValue($reorderingArray['q3a4'] . $rowNBarray_sum($avarageROW['q3a4']) / count($avarageROW['q3a4']));
  816.             $sheet->setCellValue($reorderingArray['q3a5'] . $rowNBarray_sum($avarageROW['q3a5']) / count($avarageROW['q3a5']));
  817.             $sheet->setCellValue($reorderingArray['q3a6'] . $rowNBarray_sum($avarageROW['q3a6']) / count($avarageROW['q3a6']));
  818.             $sheet->setCellValue($reorderingArray['q3a7'] . $rowNBarray_sum($avarageROW['q3a7']) / count($avarageROW['q3a7']));
  819.             if (isset($avarageROW['q4H'])) {
  820. //        $sheet->setCellValue('AM' . $rowNB, array_sum($avarageROW['q4H']) / count($avarageROW['q4H']));
  821. //        $sheet->setCellValue('AN' . $rowNB, array_sum($avarageROW['q4L']) / count($avarageROW['q4L']));
  822.                 $sheet->setCellValue('AM' $rowNBmax($avarageROW['q4H']));
  823.                 $sheet->setCellValue('AN' $rowNBmin($avarageROW['q4L']));
  824.                 $sheet->setCellValue($reorderingArray['q4a1'] . $rowNBarray_sum($avarageROW['q4a1']) / count($avarageROW['q4a1']));
  825.                 $sheet->setCellValue($reorderingArray['q4a2'] . $rowNBarray_sum($avarageROW['q4a2']) / count($avarageROW['q4a2']));
  826.                 $sheet->setCellValue($reorderingArray['q4a3'] . $rowNBarray_sum($avarageROW['q4a3']) / count($avarageROW['q4a3']));
  827.                 $sheet->setCellValue($reorderingArray['q4a4'] . $rowNBarray_sum($avarageROW['q4a4']) / count($avarageROW['q4a4']));
  828.                 $sheet->setCellValue($reorderingArray['q4a5'] . $rowNBarray_sum($avarageROW['q4a5']) / count($avarageROW['q4a5']));
  829.                 $sheet->setCellValue($reorderingArray['q4a6'] . $rowNBarray_sum($avarageROW['q4a6']) / count($avarageROW['q4a6']));
  830.                 $sheet->setCellValue($reorderingArray['q4a7'] . $rowNBarray_sum($avarageROW['q4a7']) / count($avarageROW['q4a7']));
  831. //        $sheet->setCellValue('AW' . $rowNB, array_sum($avarageROW['q5H']) / count($avarageROW['q5H']));
  832. //        $sheet->setCellValue('AX' . $rowNB, array_sum($avarageROW['q5L']) / count($avarageROW['q5L']));
  833.                 $sheet->setCellValue('AW' $rowNBmax($avarageROW['q5H']));
  834.                 $sheet->setCellValue('AX' $rowNBmin($avarageROW['q5L']));
  835.                 $sheet->setCellValue($reorderingArray['q5a1'] . $rowNBarray_sum($avarageROW['q5a1']) / count($avarageROW['q5a1']));
  836.                 $sheet->setCellValue($reorderingArray['q5a2'] . $rowNBarray_sum($avarageROW['q5a2']) / count($avarageROW['q5a2']));
  837.                 $sheet->setCellValue($reorderingArray['q5a3'] . $rowNBarray_sum($avarageROW['q5a3']) / count($avarageROW['q5a3']));
  838.                 $sheet->setCellValue($reorderingArray['q5a4'] . $rowNBarray_sum($avarageROW['q5a4']) / count($avarageROW['q5a4']));
  839.                 $sheet->setCellValue($reorderingArray['q5a5'] . $rowNBarray_sum($avarageROW['q5a5']) / count($avarageROW['q5a5']));
  840.                 $sheet->setCellValue($reorderingArray['q5a6'] . $rowNBarray_sum($avarageROW['q5a6']) / count($avarageROW['q5a6']));
  841.                 $sheet->setCellValue($reorderingArray['q5a7'] . $rowNBarray_sum($avarageROW['q5a7']) / count($avarageROW['q5a7']));
  842. //        $sheet->setCellValue('BG' . $rowNB, array_sum($avarageROW['q6H']) / count($avarageROW['q6H']));
  843. //        $sheet->setCellValue('BH' . $rowNB, array_sum($avarageROW['q6L']) / count($avarageROW['q6L']));
  844.                 $sheet->setCellValue('BG' $rowNBmax($avarageROW['q6H']));
  845.                 $sheet->setCellValue('BH' $rowNBmin($avarageROW['q6L']));
  846.                 $sheet->setCellValue($reorderingArray['q6a1'] . $rowNBarray_sum($avarageROW['q6a1']) / count($avarageROW['q6a1']));
  847.                 $sheet->setCellValue($reorderingArray['q6a2'] . $rowNBarray_sum($avarageROW['q6a2']) / count($avarageROW['q6a2']));
  848.                 $sheet->setCellValue($reorderingArray['q6a3'] . $rowNBarray_sum($avarageROW['q6a3']) / count($avarageROW['q6a3']));
  849.                 $sheet->setCellValue($reorderingArray['q6a4'] . $rowNBarray_sum($avarageROW['q6a4']) / count($avarageROW['q6a4']));
  850.                 $sheet->setCellValue($reorderingArray['q6a5'] . $rowNBarray_sum($avarageROW['q6a5']) / count($avarageROW['q6a5']));
  851.                 $sheet->setCellValue($reorderingArray['q6a6'] . $rowNBarray_sum($avarageROW['q6a6']) / count($avarageROW['q6a6']));
  852.                 $sheet->setCellValue($reorderingArray['q6a7'] . $rowNBarray_sum($avarageROW['q6a7']) / count($avarageROW['q6a7']));
  853. //        $sheet->setCellValue('BQ' . $rowNB, array_sum($avarageROW['q7H']) / count($avarageROW['q7H']));
  854. //        $sheet->setCellValue('BR' . $rowNB, array_sum($avarageROW['q7L']) / count($avarageROW['q7L']));
  855.                 $sheet->setCellValue('BQ' $rowNBmax($avarageROW['q7H']));
  856.                 $sheet->setCellValue('BR' $rowNBmin($avarageROW['q7L']));
  857.                 $sheet->setCellValue($reorderingArray['q7a1'] . $rowNBarray_sum($avarageROW['q7a1']) / count($avarageROW['q7a1']));
  858.                 $sheet->setCellValue($reorderingArray['q7a2'] . $rowNBarray_sum($avarageROW['q7a2']) / count($avarageROW['q7a2']));
  859.                 $sheet->setCellValue($reorderingArray['q7a3'] . $rowNBarray_sum($avarageROW['q7a3']) / count($avarageROW['q7a3']));
  860.                 $sheet->setCellValue($reorderingArray['q7a4'] . $rowNBarray_sum($avarageROW['q7a4']) / count($avarageROW['q7a4']));
  861.                 $sheet->setCellValue($reorderingArray['q7a5'] . $rowNBarray_sum($avarageROW['q7a5']) / count($avarageROW['q7a5']));
  862.                 $sheet->setCellValue($reorderingArray['q7a6'] . $rowNBarray_sum($avarageROW['q7a6']) / count($avarageROW['q7a6']));
  863.                 $sheet->setCellValue($reorderingArray['q7a7'] . $rowNBarray_sum($avarageROW['q7a7']) / count($avarageROW['q7a7']));
  864. //        $sheet->setCellValue('CA' . $rowNB, array_sum($avarageROW['q8H']) / count($avarageROW['q8H']));
  865. //        $sheet->setCellValue('CB' . $rowNB, array_sum($avarageROW['q8L']) / count($avarageROW['q8L']));
  866.                 $sheet->setCellValue('CA' $rowNBmax($avarageROW['q8H']));
  867.                 $sheet->setCellValue('CB' $rowNBmin($avarageROW['q8L']));
  868.                 $sheet->setCellValue($reorderingArray['q8a1'] . $rowNBarray_sum($avarageROW['q8a1']) / count($avarageROW['q8a1']));
  869.                 $sheet->setCellValue($reorderingArray['q8a2'] . $rowNBarray_sum($avarageROW['q8a2']) / count($avarageROW['q8a2']));
  870.                 $sheet->setCellValue($reorderingArray['q8a3'] . $rowNBarray_sum($avarageROW['q8a3']) / count($avarageROW['q8a3']));
  871.                 $sheet->setCellValue($reorderingArray['q8a4'] . $rowNBarray_sum($avarageROW['q8a4']) / count($avarageROW['q8a4']));
  872.                 $sheet->setCellValue($reorderingArray['q8a5'] . $rowNBarray_sum($avarageROW['q8a5']) / count($avarageROW['q8a5']));
  873.                 $sheet->setCellValue($reorderingArray['q8a6'] . $rowNBarray_sum($avarageROW['q8a6']) / count($avarageROW['q8a6']));
  874.                 $sheet->setCellValue($reorderingArray['q8a7'] . $rowNBarray_sum($avarageROW['q8a7']) / count($avarageROW['q8a7']));
  875.             }
  876.         }
  877.         $reorderedSheet = new Worksheet($spreadsheet'comments');
  878.         $rowNB          1;
  879.         if ($j 3) {
  880.             $reorderedSheet->setCellValue('B' $rowNB'Decision Making Impact ');
  881.             $reorderedSheet->setCellValue('A' $rowNB'Decision Making Examples ');
  882.             $reorderedSheet->setCellValue('D' $rowNB'Conflict Resolution Impact ');
  883.             $reorderedSheet->setCellValue('C' $rowNB'Conflict Management Examples');
  884.             $reorderedSheet->setCellValue('F' $rowNB'Goals & Objective Impact ');
  885.             $reorderedSheet->setCellValue('E' $rowNB'Goals & Objective Example ');
  886.             $reorderedSheet->setCellValue('H' $rowNB'Authority Impact ');
  887.             $reorderedSheet->setCellValue('G' $rowNB'Authority Examples');
  888.             $reorderedSheet->setCellValue('J' $rowNB'Advocacy Impact');
  889.             $reorderedSheet->setCellValue('I' $rowNB'Advocacy Examples ');
  890.             $reorderedSheet->setCellValue('L' $rowNB'Coordination Impact ');
  891.             $reorderedSheet->setCellValue('K' $rowNB'Coordination Examples ');
  892.             $reorderedSheet->setCellValue('N' $rowNB'Critique & Feedback Impact ');
  893.             $reorderedSheet->setCellValue('M' $rowNB'Critique & Feedback Examples ');
  894.             $reorderedSheet->setCellValue('P' $rowNB'Accountability Impact ');
  895.             $reorderedSheet->setCellValue('O' $rowNB'Accountability Examples ');
  896.         } else {
  897.             $reorderedSheet->setCellValue('B' $rowNB'Decision Making Impact ');
  898.             $reorderedSheet->setCellValue('A' $rowNB'Decision Making Examples ');
  899.             $reorderedSheet->setCellValue('D' $rowNB'Conflict Resolution Impact ');
  900.             $reorderedSheet->setCellValue('C' $rowNB'Conflict Management Examples');
  901.             $reorderedSheet->setCellValue('F' $rowNB'Critique & Feedback Impact  ');
  902.             $reorderedSheet->setCellValue('E' $rowNB'Critique & Feedback Examples');
  903.         }
  904.         $rowNB++;
  905.         foreach ($data as $student) {
  906.             $reorderedSheet->setCellValue('B' $rowNB$student['exp1']);
  907.             $reorderedSheet->setCellValue('A' $rowNB$student['cat1']);
  908.             $reorderedSheet->setCellValue('D' $rowNB$student['exp2']);
  909.             $reorderedSheet->setCellValue('C' $rowNB$student['cat2']);
  910.             $reorderedSheet->setCellValue('F' $rowNB$student['exp3']);
  911.             $reorderedSheet->setCellValue('E' $rowNB$student['cat3']);
  912.             if ($j 3) {
  913.                 $reorderedSheet->setCellValue('H' $rowNB$student['exp4']);
  914.                 $reorderedSheet->setCellValue('G' $rowNB$student['cat4']);
  915.                 $reorderedSheet->setCellValue('J' $rowNB$student['exp5']);
  916.                 $reorderedSheet->setCellValue('I' $rowNB$student['cat5']);
  917.                 $reorderedSheet->setCellValue('L' $rowNB$student['exp6']);
  918.                 $reorderedSheet->setCellValue('K' $rowNB$student['cat6']);
  919.                 $reorderedSheet->setCellValue('N' $rowNB$student['exp7']);
  920.                 $reorderedSheet->setCellValue('M' $rowNB$student['cat7']);
  921.                 $reorderedSheet->setCellValue('P' $rowNB$student['exp8']);
  922.                 $reorderedSheet->setCellValue('O' $rowNB$student['cat8']);
  923.             }
  924.             $reorderedSheet->setCellValue('Q' $rowNB$student['username']);
  925.             $reorderedSheet->setCellValue('R' $rowNB$student['first_name']);
  926.             $rowNB++;
  927.         }
  928.         $spreadsheet->addSheet($reorderedSheet1);
  929.         $conn $entityManager->getConnection();
  930.         $sql  'SELECT DISTINCT (team.id) ,team.name FROM `student_survey`,users,team,student WHERE users.id=student.id and student.team_id=team.id and student_id= users.id and survey_id= :survey_id';
  931.         $stmt $conn->prepare($sql);
  932.         $stmt->execute(['survey_id' => $id]);
  933.         $teams      $stmt->fetchAll();
  934.         $sheetIndex 1;
  935.         foreach ($teams as $team) {
  936.             $sheetIndex++;
  937.             $teanSheet $this->addTeamSheet($id$team$spreadsheet$survey);
  938.             $spreadsheet->addSheet($teanSheet$sheetIndex);
  939.         }
  940.         $writer = new Xlsx($spreadsheet);
  941.         $truncatedName = (mb_strlen($survey->getName()) > 25) ? mb_substr($survey->getName(), 025) : $survey->getName();
  942.         // Create a Temporary file in the system
  943.         $fileName  $truncatedName '.xlsx';
  944.         $temp_file tempnam(sys_get_temp_dir(), $fileName);
  945.         // Create the excel file in the tmp directory of the system
  946.         $writer->save($temp_file);
  947.         // Return the excel file as an attachment
  948.         return $this->file($temp_file$fileNameResponseHeaderBag::DISPOSITION_INLINE);
  949.     }
  950.     public function addTeamSheet($surveyID$team$spreadsheet$survey)
  951.     {
  952.         $entityManager $this->getDoctrine()->getManager();
  953. //        $truncatedName = (strlen( $team['name']) > 25) ? substr( $team['name'], 0, 25)  : $team['name'];
  954.         $truncatedName = (mb_strlen($team['name']) > 25) ? mb_substr($team['name'], 025) : $team['name'];
  955.         $questions     $entityManager->getRepository(Question::class)
  956.                                        ->findBy(array('type' => $survey->getType()));
  957.         $j         count($questions);
  958.         $teamSheet = new Worksheet($spreadsheet$truncatedName);
  959.         $teamSheet->mergeCells("B1:H1");
  960.         $teamSheet->mergeCells("L1:Q1");
  961.         $teamSheet->mergeCells("V1:AB1");
  962.         if ($j 3) {
  963.             $teamSheet->mergeCells("AF1:AL1");
  964.             $teamSheet->mergeCells("AP1:AV1");
  965.             $teamSheet->mergeCells("AZ1:BF1");
  966.             $teamSheet->mergeCells("BJ1:BP1");
  967.             $teamSheet->mergeCells("BT1:BZ1");
  968.         }
  969.         if ($j 3) {
  970.             $teamSheet->setCellValue('B1''Decision Making    ');
  971.             $teamSheet->setCellValue('L1''Conflict Management    ');
  972.             $teamSheet->setCellValue('V1''Strategy Setting    ');
  973.             $teamSheet->setCellValue('AF1''Authority');
  974.             $teamSheet->setCellValue('AP1''Advocacy    ');
  975.             $teamSheet->setCellValue('AZ1''Coordination');
  976.             $teamSheet->setCellValue('BJ1''Critique & Feedback');
  977.             $teamSheet->setCellValue('BT1''Accountability    ');
  978.         } else {
  979.             $teamSheet->setCellValue('B1''Decision Making    ');
  980.             $teamSheet->setCellValue('L1''Conflict Management    ');
  981.             $teamSheet->setCellValue('V1''Critique & Feedback');
  982.         }
  983.         $teamSheet->setCellValue('A2''ID');
  984.         $teamSheet->setCellValue('B2''Opp');
  985.         $teamSheet->setCellValue('C2''1,1');
  986.         $teamSheet->setCellValue('D2''1,9');
  987.         $teamSheet->setCellValue('E2''5,5');
  988.         $teamSheet->setCellValue('F2''9,1');
  989.         $teamSheet->setCellValue('G2''PAT');
  990.         $teamSheet->setCellValue('H2''9,9');
  991.         $teamSheet->setCellValue('I2''High');
  992.         $teamSheet->setCellValue('J2''Low');
  993.         $teamSheet->setCellValue('K2''Total Percent Q1');
  994.         $teamSheet->setCellValue('L2''Opp');
  995.         $teamSheet->setCellValue('M2''1,1');
  996.         $teamSheet->setCellValue('N2''1,9');
  997.         $teamSheet->setCellValue('O2''5,5');
  998.         $teamSheet->setCellValue('P2''9,1');
  999.         $teamSheet->setCellValue('Q2''PAT');
  1000.         $teamSheet->setCellValue('R2''9,9');
  1001.         $teamSheet->setCellValue('S2''High');
  1002.         $teamSheet->setCellValue('T2''Low');
  1003.         $teamSheet->setCellValue('U2''Total Percent Q2');
  1004.         $teamSheet->setCellValue('V2''Opp');
  1005.         $teamSheet->setCellValue('W2''1,1');
  1006.         $teamSheet->setCellValue('X2''1,9');
  1007.         $teamSheet->setCellValue('Y2''5,5');
  1008.         $teamSheet->setCellValue('Z2''9,1');
  1009.         $teamSheet->setCellValue('AA2''PAT');
  1010.         $teamSheet->setCellValue('AB2''9,9');
  1011.         $teamSheet->setCellValue('AC2''High');
  1012.         $teamSheet->setCellValue('AD2''Low');
  1013.         $teamSheet->setCellValue('AE2''Total Percent Q3');
  1014.         if ($j 3) {
  1015.             $teamSheet->setCellValue('AF2''Opp');
  1016.             $teamSheet->setCellValue('AG2''1,1');
  1017.             $teamSheet->setCellValue('AH2''1,9');
  1018.             $teamSheet->setCellValue('AI2''5,5');
  1019.             $teamSheet->setCellValue('AJ2''9,1');
  1020.             $teamSheet->setCellValue('AK2''PAT');
  1021.             $teamSheet->setCellValue('AL2''9,9');
  1022.             $teamSheet->setCellValue('AM2''High');
  1023.             $teamSheet->setCellValue('AN2''Low');
  1024.             $teamSheet->setCellValue('AO2''Total Percent Q4');
  1025.             $teamSheet->setCellValue('AP2''Opp');
  1026.             $teamSheet->setCellValue('AQ2''1,1');
  1027.             $teamSheet->setCellValue('AR2''1,9');
  1028.             $teamSheet->setCellValue('AS2''5,5');
  1029.             $teamSheet->setCellValue('AT2''9,1');
  1030.             $teamSheet->setCellValue('AU2''PAT');
  1031.             $teamSheet->setCellValue('AV2''9,9');
  1032.             $teamSheet->setCellValue('AW2''High');
  1033.             $teamSheet->setCellValue('AX2''Low');
  1034.             $teamSheet->setCellValue('AY2''Total Percent Q5');
  1035.             $teamSheet->setCellValue('AZ2''Opp');
  1036.             $teamSheet->setCellValue('BA2''1,1');
  1037.             $teamSheet->setCellValue('BB2''1,9');
  1038.             $teamSheet->setCellValue('BC2''5,5');
  1039.             $teamSheet->setCellValue('BD2''9,1');
  1040.             $teamSheet->setCellValue('BE2''PAT');
  1041.             $teamSheet->setCellValue('BF2''9,9');
  1042.             $teamSheet->setCellValue('BG2''High');
  1043.             $teamSheet->setCellValue('BH2''Low');
  1044.             $teamSheet->setCellValue('BI2''Total Percent Q6');
  1045.             $teamSheet->setCellValue('BJ2''Opp');
  1046.             $teamSheet->setCellValue('BK2''1,1');
  1047.             $teamSheet->setCellValue('BL2''1,9');
  1048.             $teamSheet->setCellValue('BM2''5,5');
  1049.             $teamSheet->setCellValue('BN2''9,1');
  1050.             $teamSheet->setCellValue('BO2''PAT');
  1051.             $teamSheet->setCellValue('BP2''9,9');
  1052.             $teamSheet->setCellValue('BQ2''High');
  1053.             $teamSheet->setCellValue('BR2''Low');
  1054.             $teamSheet->setCellValue('BS2''Total Percent Q7');
  1055.             $teamSheet->setCellValue('BT2''Opp');
  1056.             $teamSheet->setCellValue('BU2''1,1');
  1057.             $teamSheet->setCellValue('BV2''1,9');
  1058.             $teamSheet->setCellValue('BW2''5,5');
  1059.             $teamSheet->setCellValue('BX2''9,1');
  1060.             $teamSheet->setCellValue('BY2''PAT');
  1061.             $teamSheet->setCellValue('BZ2''9,9');
  1062.             $teamSheet->setCellValue('CA2''High');
  1063.             $teamSheet->setCellValue('CB2''Low');
  1064.             $teamSheet->setCellValue('CC2''Total Percent Q8');
  1065.         }
  1066.         $reorderingArray[] = array();
  1067.         $j                 0;
  1068.         foreach ($questions as $question) {
  1069.             $i 0;
  1070.             $j++;
  1071.             foreach ($question->getAnswers() as $answer) {
  1072.                 $i++;
  1073.                 if ($j == 1) {
  1074.                     if (trim($answer->getDescription()) == 'OPP') {
  1075.                         $reorderingArray['q' $j 'a' $i] = 'B';
  1076.                     } elseif (trim($answer->getDescription()) == '1,1') {
  1077.                         $reorderingArray['q' $j 'a' $i] = 'C';
  1078.                     } elseif (trim($answer->getDescription()) == '1,9') {
  1079.                         $reorderingArray['q' $j 'a' $i] = 'D';
  1080.                     } elseif (trim($answer->getDescription()) == '5,5') {
  1081.                         $reorderingArray['q' $j 'a' $i] = 'E';
  1082.                     } elseif (trim($answer->getDescription()) == '9,1') {
  1083.                         $reorderingArray['q' $j 'a' $i] = 'F';
  1084.                     } elseif (trim($answer->getDescription()) == 'PAT') {
  1085.                         $reorderingArray['q' $j 'a' $i] = 'G';
  1086.                     } elseif (trim($answer->getDescription()) == '9,9') {
  1087.                         $reorderingArray['q' $j 'a' $i] = 'H';
  1088.                     }
  1089.                 } else {
  1090.                     if ($j == 2) {
  1091.                         if (trim($answer->getDescription()) == 'OPP') {
  1092.                             $reorderingArray['q' $j 'a' $i] = 'L';
  1093.                         } elseif (trim($answer->getDescription()) == '1,1') {
  1094.                             $reorderingArray['q' $j 'a' $i] = 'M';
  1095.                         } elseif (trim($answer->getDescription()) == '1,9') {
  1096.                             $reorderingArray['q' $j 'a' $i] = 'N';
  1097.                         } elseif (trim($answer->getDescription()) == '5,5') {
  1098.                             $reorderingArray['q' $j 'a' $i] = 'O';
  1099.                         } elseif (trim($answer->getDescription()) == '9,1') {
  1100.                             $reorderingArray['q' $j 'a' $i] = 'P';
  1101.                         } elseif (trim($answer->getDescription()) == 'PAT') {
  1102.                             $reorderingArray['q' $j 'a' $i] = 'Q';
  1103.                         } elseif (trim($answer->getDescription()) == '9,9') {
  1104.                             $reorderingArray['q' $j 'a' $i] = 'R';
  1105.                         }
  1106.                     } else {
  1107.                         if ($j == 3) {
  1108.                             if (trim($answer->getDescription()) == 'OPP') {
  1109.                                 $reorderingArray['q' $j 'a' $i] = 'V';
  1110.                             } elseif (trim($answer->getDescription()) == '1,1') {
  1111.                                 $reorderingArray['q' $j 'a' $i] = 'W';
  1112.                             } elseif (trim($answer->getDescription()) == '1,9') {
  1113.                                 $reorderingArray['q' $j 'a' $i] = 'X';
  1114.                             } elseif (trim($answer->getDescription()) == '5,5') {
  1115.                                 $reorderingArray['q' $j 'a' $i] = 'Y';
  1116.                             } elseif (trim($answer->getDescription()) == '9,1') {
  1117.                                 $reorderingArray['q' $j 'a' $i] = 'Z';
  1118.                             } elseif (trim($answer->getDescription()) == 'PAT') {
  1119.                                 $reorderingArray['q' $j 'a' $i] = 'AA';
  1120.                             } elseif (trim($answer->getDescription()) == '9,9') {
  1121.                                 $reorderingArray['q' $j 'a' $i] = 'AB';
  1122.                             }
  1123.                         } else {
  1124.                             if ($j == 4) {
  1125.                                 if (trim($answer->getDescription()) == 'OPP') {
  1126.                                     $reorderingArray['q' $j 'a' $i] = 'AF';
  1127.                                 } elseif (trim($answer->getDescription()) == '1,1') {
  1128.                                     $reorderingArray['q' $j 'a' $i] = 'AG';
  1129.                                 } elseif (trim($answer->getDescription()) == '1,9') {
  1130.                                     $reorderingArray['q' $j 'a' $i] = 'AH';
  1131.                                 } elseif (trim($answer->getDescription()) == '5,5') {
  1132.                                     $reorderingArray['q' $j 'a' $i] = 'AI';
  1133.                                 } elseif (trim($answer->getDescription()) == '9,1') {
  1134.                                     $reorderingArray['q' $j 'a' $i] = 'AJ';
  1135.                                 } elseif (trim($answer->getDescription()) == 'PAT') {
  1136.                                     $reorderingArray['q' $j 'a' $i] = 'AK';
  1137.                                 } elseif (trim($answer->getDescription()) == '9,9') {
  1138.                                     $reorderingArray['q' $j 'a' $i] = 'AL';
  1139.                                 }
  1140.                             } else {
  1141.                                 if ($j == 5) {
  1142.                                     if (trim($answer->getDescription()) == 'OPP') {
  1143.                                         $reorderingArray['q' $j 'a' $i] = 'AP';
  1144.                                     } elseif (trim($answer->getDescription()) == '1,1') {
  1145.                                         $reorderingArray['q' $j 'a' $i] = 'AQ';
  1146.                                     } elseif (trim($answer->getDescription()) == '1,9') {
  1147.                                         $reorderingArray['q' $j 'a' $i] = 'AR';
  1148.                                     } elseif (trim($answer->getDescription()) == '5,5') {
  1149.                                         $reorderingArray['q' $j 'a' $i] = 'AS';
  1150.                                     } elseif (trim($answer->getDescription()) == '9,1') {
  1151.                                         $reorderingArray['q' $j 'a' $i] = 'AT';
  1152.                                     } elseif (trim($answer->getDescription()) == 'PAT') {
  1153.                                         $reorderingArray['q' $j 'a' $i] = 'AU';
  1154.                                     } elseif (trim($answer->getDescription()) == '9,9') {
  1155.                                         $reorderingArray['q' $j 'a' $i] = 'AV';
  1156.                                     }
  1157.                                 } else {
  1158.                                     if ($j == 6) {
  1159.                                         if (trim($answer->getDescription()) == 'OPP') {
  1160.                                             $reorderingArray['q' $j 'a' $i] = 'AZ';
  1161.                                         } elseif (trim($answer->getDescription()) == '1,1') {
  1162.                                             $reorderingArray['q' $j 'a' $i] = 'BA';
  1163.                                         } elseif (trim($answer->getDescription()) == '1,9') {
  1164.                                             $reorderingArray['q' $j 'a' $i] = 'BB';
  1165.                                         } elseif (trim($answer->getDescription()) == '5,5') {
  1166.                                             $reorderingArray['q' $j 'a' $i] = 'BC';
  1167.                                         } elseif (trim($answer->getDescription()) == '9,1') {
  1168.                                             $reorderingArray['q' $j 'a' $i] = 'BD';
  1169.                                         } elseif (trim($answer->getDescription()) == 'PAT') {
  1170.                                             $reorderingArray['q' $j 'a' $i] = 'BE';
  1171.                                         } elseif (trim($answer->getDescription()) == '9,9') {
  1172.                                             $reorderingArray['q' $j 'a' $i] = 'BF';
  1173.                                         }
  1174.                                     } else {
  1175.                                         if ($j == 7) {
  1176.                                             if (trim($answer->getDescription()) == 'OPP') {
  1177.                                                 $reorderingArray['q' $j 'a' $i] = 'BJ';
  1178.                                             } elseif (trim($answer->getDescription()) == '1,1') {
  1179.                                                 $reorderingArray['q' $j 'a' $i] = 'BK';
  1180.                                             } elseif (trim($answer->getDescription()) == '1,9') {
  1181.                                                 $reorderingArray['q' $j 'a' $i] = 'BL';
  1182.                                             } elseif (trim($answer->getDescription()) == '5,5') {
  1183.                                                 $reorderingArray['q' $j 'a' $i] = 'BM';
  1184.                                             } elseif (trim($answer->getDescription()) == '9,1') {
  1185.                                                 $reorderingArray['q' $j 'a' $i] = 'BN';
  1186.                                             } elseif (trim($answer->getDescription()) == 'PAT') {
  1187.                                                 $reorderingArray['q' $j 'a' $i] = 'BO';
  1188.                                             } elseif (trim($answer->getDescription()) == '9,9') {
  1189.                                                 $reorderingArray['q' $j 'a' $i] = 'BP';
  1190.                                             }
  1191.                                         } else {
  1192.                                             if ($j == 8) {
  1193.                                                 if (trim($answer->getDescription()) == 'OPP') {
  1194.                                                     $reorderingArray['q' $j 'a' $i] = 'BT';
  1195.                                                 } elseif (trim($answer->getDescription()) == '1,1') {
  1196.                                                     $reorderingArray['q' $j 'a' $i] = 'BU';
  1197.                                                 } elseif (trim($answer->getDescription()) == '1,9') {
  1198.                                                     $reorderingArray['q' $j 'a' $i] = 'BV';
  1199.                                                 } elseif (trim($answer->getDescription()) == '5,5') {
  1200.                                                     $reorderingArray['q' $j 'a' $i] = 'BW';
  1201.                                                 } elseif (trim($answer->getDescription()) == '9,1') {
  1202.                                                     $reorderingArray['q' $j 'a' $i] = 'BX';
  1203.                                                 } elseif (trim($answer->getDescription()) == 'PAT') {
  1204.                                                     $reorderingArray['q' $j 'a' $i] = 'BY';
  1205.                                                 } elseif (trim($answer->getDescription()) == '9,9') {
  1206.                                                     $reorderingArray['q' $j 'a' $i] = 'BZ';
  1207.                                                 }
  1208.                                             }
  1209.                                         }
  1210.                                     }
  1211.                                 }
  1212.                             }
  1213.                         }
  1214.                     }
  1215.                 }
  1216.             }
  1217.         }
  1218.         $conn $entityManager->getConnection();
  1219.         $sql  'SELECT * FROM `student_survey`,users,team,student WHERE users.id=student.id and student.team_id=team.id and student_id= users.id and survey_id= :survey_id and team.id = :team_id';
  1220.         $stmt $conn->prepare($sql);
  1221.         $stmt->execute(['survey_id' => $surveyID'team_id' => $team['id']]);
  1222.         $data       $stmt->fetchAll();
  1223.         $rowNB      3;
  1224.         $avarageROW = array();
  1225.         foreach ($data as $student) {
  1226.             $q1Answers = array(
  1227.                 $student['q1a1'],
  1228.                 $student['q1a2'],
  1229.                 $student['q1a3'],
  1230.                 $student['q1a4'],
  1231.                 $student['q1a5'],
  1232.                 $student['q1a6'],
  1233.                 $student['q1a7'],
  1234.             );
  1235.             if (array_sum($q1Answers) == 100) {
  1236.                 $avarageROW['q1a1'][] = $student['q1a1'];
  1237.                 $avarageROW['q1a2'][] = $student['q1a2'];
  1238.                 $avarageROW['q1a3'][] = $student['q1a3'];
  1239.                 $avarageROW['q1a4'][] = $student['q1a4'];
  1240.                 $avarageROW['q1a5'][] = $student['q1a5'];
  1241.                 $avarageROW['q1a6'][] = $student['q1a6'];
  1242.                 $avarageROW['q1a7'][] = $student['q1a7'];
  1243.                 $avarageROW['q1L'][]  = min($q1Answers);
  1244.                 $avarageROW['q1H'][] = max($q1Answers);
  1245.                 $teamSheet->setCellValue('I' $rowNBmax($q1Answers));
  1246.                 $teamSheet->setCellValue('J' $rowNBmin($q1Answers));
  1247.                 $teamSheet->setCellValue('K' $rowNBarray_sum($q1Answers));
  1248.                 $teamSheet->setCellValue($reorderingArray['q1a1'] . $rowNB$student['q1a1']);
  1249.                 $teamSheet->setCellValue($reorderingArray['q1a2'] . $rowNB$student['q1a2']);
  1250.                 $teamSheet->setCellValue($reorderingArray['q1a3'] . $rowNB$student['q1a3']);
  1251.                 $teamSheet->setCellValue($reorderingArray['q1a4'] . $rowNB$student['q1a4']);
  1252.                 $teamSheet->setCellValue($reorderingArray['q1a5'] . $rowNB$student['q1a5']);
  1253.                 $teamSheet->setCellValue($reorderingArray['q1a6'] . $rowNB$student['q1a6']);
  1254.                 $teamSheet->setCellValue($reorderingArray['q1a7'] . $rowNB$student['q1a7']);
  1255.             }
  1256.             $q2Answers = array(
  1257.                 $student['q2a1'],
  1258.                 $student['q2a2'],
  1259.                 $student['q2a3'],
  1260.                 $student['q2a4'],
  1261.                 $student['q2a5'],
  1262.                 $student['q2a6'],
  1263.                 $student['q2a7'],
  1264.             );
  1265.             if (array_sum($q2Answers) == 100) {
  1266.                 $avarageROW['q2a1'][] = $student['q2a1'];
  1267.                 $avarageROW['q2a2'][] = $student['q2a2'];
  1268.                 $avarageROW['q2a3'][] = $student['q2a3'];
  1269.                 $avarageROW['q2a4'][] = $student['q2a4'];
  1270.                 $avarageROW['q2a5'][] = $student['q2a5'];
  1271.                 $avarageROW['q2a6'][] = $student['q2a6'];
  1272.                 $avarageROW['q2a7'][] = $student['q2a7'];
  1273.                 $avarageROW['q2H'][]  = max($q2Answers);
  1274.                 $avarageROW['q2L'][]  = min($q2Answers);
  1275.                 $teamSheet->setCellValue('S' $rowNBmax($q2Answers));
  1276.                 $teamSheet->setCellValue('T' $rowNBmin($q2Answers));
  1277.                 $teamSheet->setCellValue('u' $rowNBarray_sum($q2Answers));
  1278.                 $teamSheet->setCellValue($reorderingArray['q2a1'] . $rowNB$student['q2a1']);
  1279.                 $teamSheet->setCellValue($reorderingArray['q2a2'] . $rowNB$student['q2a2']);
  1280.                 $teamSheet->setCellValue($reorderingArray['q2a3'] . $rowNB$student['q2a3']);
  1281.                 $teamSheet->setCellValue($reorderingArray['q2a4'] . $rowNB$student['q2a4']);
  1282.                 $teamSheet->setCellValue($reorderingArray['q2a5'] . $rowNB$student['q2a5']);
  1283.                 $teamSheet->setCellValue($reorderingArray['q2a6'] . $rowNB$student['q2a6']);
  1284.                 $teamSheet->setCellValue($reorderingArray['q2a7'] . $rowNB$student['q2a7']);
  1285.             }
  1286.             $q3Answers = array(
  1287.                 $student['q3a1'],
  1288.                 $student['q3a2'],
  1289.                 $student['q3a3'],
  1290.                 $student['q3a4'],
  1291.                 $student['q3a5'],
  1292.                 $student['q3a6'],
  1293.                 $student['q3a7'],
  1294.             );
  1295.             if (array_sum($q3Answers) == 100) {
  1296.                 $avarageROW['q3a1'][] = $student['q3a1'];
  1297.                 $avarageROW['q3a2'][] = $student['q3a2'];
  1298.                 $avarageROW['q3a3'][] = $student['q3a3'];
  1299.                 $avarageROW['q3a4'][] = $student['q3a4'];
  1300.                 $avarageROW['q3a5'][] = $student['q3a5'];
  1301.                 $avarageROW['q3a6'][] = $student['q3a6'];
  1302.                 $avarageROW['q3a7'][] = $student['q3a7'];
  1303.                 $avarageROW['q3H'][]  = max($q3Answers);
  1304.                 $avarageROW['q3L'][]  = min($q3Answers);
  1305.                 $teamSheet->setCellValue('AC' $rowNBmax($q3Answers));
  1306.                 $teamSheet->setCellValue('AD' $rowNBmin($q3Answers));
  1307.                 $teamSheet->setCellValue('AE' $rowNBarray_sum($q3Answers));
  1308.                 $teamSheet->setCellValue($reorderingArray['q3a1'] . $rowNB$student['q3a1']);
  1309.                 $teamSheet->setCellValue($reorderingArray['q3a2'] . $rowNB$student['q3a2']);
  1310.                 $teamSheet->setCellValue($reorderingArray['q3a3'] . $rowNB$student['q3a3']);
  1311.                 $teamSheet->setCellValue($reorderingArray['q3a4'] . $rowNB$student['q3a4']);
  1312.                 $teamSheet->setCellValue($reorderingArray['q3a5'] . $rowNB$student['q3a5']);
  1313.                 $teamSheet->setCellValue($reorderingArray['q3a6'] . $rowNB$student['q3a6']);
  1314.                 $teamSheet->setCellValue($reorderingArray['q3a7'] . $rowNB$student['q3a7']);
  1315.             }
  1316.             if ($j 3) {
  1317.                 $q4Answers = array(
  1318.                     $student['q4a1'],
  1319.                     $student['q4a2'],
  1320.                     $student['q4a3'],
  1321.                     $student['q4a4'],
  1322.                     $student['q4a5'],
  1323.                     $student['q4a6'],
  1324.                     $student['q4a7'],
  1325.                 );
  1326.                 if (array_sum($q4Answers) == 100) {
  1327.                     $avarageROW['q4a1'][] = $student['q4a1'];
  1328.                     $avarageROW['q4a2'][] = $student['q4a2'];
  1329.                     $avarageROW['q4a3'][] = $student['q4a3'];
  1330.                     $avarageROW['q4a4'][] = $student['q4a4'];
  1331.                     $avarageROW['q4a5'][] = $student['q4a5'];
  1332.                     $avarageROW['q4a6'][] = $student['q4a6'];
  1333.                     $avarageROW['q4a7'][] = $student['q4a7'];
  1334.                     $avarageROW['q4H'][]  = max($q4Answers);
  1335.                     $avarageROW['q4L'][]  = min($q4Answers);
  1336.                     $teamSheet->setCellValue('AM' $rowNBmax($q4Answers));
  1337.                     $teamSheet->setCellValue('AN' $rowNBmin($q4Answers));
  1338.                     $teamSheet->setCellValue('AO' $rowNBarray_sum($q4Answers));
  1339.                     $teamSheet->setCellValue($reorderingArray['q4a1'] . $rowNB$student['q4a1']);
  1340.                     $teamSheet->setCellValue($reorderingArray['q4a2'] . $rowNB$student['q4a2']);
  1341.                     $teamSheet->setCellValue($reorderingArray['q4a3'] . $rowNB$student['q4a3']);
  1342.                     $teamSheet->setCellValue($reorderingArray['q4a4'] . $rowNB$student['q4a4']);
  1343.                     $teamSheet->setCellValue($reorderingArray['q4a5'] . $rowNB$student['q4a5']);
  1344.                     $teamSheet->setCellValue($reorderingArray['q4a6'] . $rowNB$student['q4a6']);
  1345.                     $teamSheet->setCellValue($reorderingArray['q4a7'] . $rowNB$student['q4a7']);
  1346.                 }
  1347.                 $q5Answers = array(
  1348.                     $student['q5a1'],
  1349.                     $student['q5a2'],
  1350.                     $student['q5a3'],
  1351.                     $student['q5a4'],
  1352.                     $student['q5a5'],
  1353.                     $student['q5a6'],
  1354.                     $student['q5a7'],
  1355.                 );
  1356.                 if (array_sum($q5Answers) == 100) {
  1357.                     $avarageROW['q5a1'][] = $student['q5a1'];
  1358.                     $avarageROW['q5a2'][] = $student['q5a2'];
  1359.                     $avarageROW['q5a3'][] = $student['q5a3'];
  1360.                     $avarageROW['q5a4'][] = $student['q5a4'];
  1361.                     $avarageROW['q5a5'][] = $student['q5a5'];
  1362.                     $avarageROW['q5a6'][] = $student['q5a6'];
  1363.                     $avarageROW['q5a7'][] = $student['q5a7'];
  1364.                     $avarageROW['q5H'][]  = max($q5Answers);
  1365.                     $avarageROW['q5L'][]  = min($q5Answers);
  1366.                     $teamSheet->setCellValue('AW' $rowNBmax($q5Answers));
  1367.                     $teamSheet->setCellValue('AX' $rowNBmin($q5Answers));
  1368.                     $teamSheet->setCellValue('AY' $rowNBarray_sum($q5Answers));
  1369.                     $teamSheet->setCellValue($reorderingArray['q5a1'] . $rowNB$student['q5a1']);
  1370.                     $teamSheet->setCellValue($reorderingArray['q5a2'] . $rowNB$student['q5a2']);
  1371.                     $teamSheet->setCellValue($reorderingArray['q5a3'] . $rowNB$student['q5a3']);
  1372.                     $teamSheet->setCellValue($reorderingArray['q5a4'] . $rowNB$student['q5a4']);
  1373.                     $teamSheet->setCellValue($reorderingArray['q5a5'] . $rowNB$student['q5a5']);
  1374.                     $teamSheet->setCellValue($reorderingArray['q5a6'] . $rowNB$student['q5a6']);
  1375.                     $teamSheet->setCellValue($reorderingArray['q5a7'] . $rowNB$student['q5a7']);
  1376.                 }
  1377.                 $q6Answers = array(
  1378.                     $student['q6a1'],
  1379.                     $student['q6a2'],
  1380.                     $student['q6a3'],
  1381.                     $student['q6a4'],
  1382.                     $student['q6a5'],
  1383.                     $student['q6a6'],
  1384.                     $student['q6a7'],
  1385.                 );
  1386.                 if (array_sum($q6Answers) == 100) {
  1387.                     $avarageROW['q6a1'][] = $student['q6a1'];
  1388.                     $avarageROW['q6a2'][] = $student['q6a2'];
  1389.                     $avarageROW['q6a3'][] = $student['q6a3'];
  1390.                     $avarageROW['q6a4'][] = $student['q6a4'];
  1391.                     $avarageROW['q6a5'][] = $student['q6a5'];
  1392.                     $avarageROW['q6a6'][] = $student['q6a6'];
  1393.                     $avarageROW['q6a7'][] = $student['q6a7'];
  1394.                     $avarageROW['q6H'][]  = max($q6Answers);
  1395.                     $avarageROW['q6L'][]  = min($q6Answers);
  1396.                     $teamSheet->setCellValue('BG' $rowNBmax($q6Answers));
  1397.                     $teamSheet->setCellValue('BH' $rowNBmin($q6Answers));
  1398.                     $teamSheet->setCellValue('BI' $rowNBarray_sum($q6Answers));
  1399.                     $teamSheet->setCellValue($reorderingArray['q6a1'] . $rowNB$student['q6a1']);
  1400.                     $teamSheet->setCellValue($reorderingArray['q6a2'] . $rowNB$student['q6a2']);
  1401.                     $teamSheet->setCellValue($reorderingArray['q6a3'] . $rowNB$student['q6a3']);
  1402.                     $teamSheet->setCellValue($reorderingArray['q6a4'] . $rowNB$student['q6a4']);
  1403.                     $teamSheet->setCellValue($reorderingArray['q6a5'] . $rowNB$student['q6a5']);
  1404.                     $teamSheet->setCellValue($reorderingArray['q6a6'] . $rowNB$student['q6a6']);
  1405.                     $teamSheet->setCellValue($reorderingArray['q6a7'] . $rowNB$student['q6a7']);
  1406.                 }
  1407.                 $q7Answers = array(
  1408.                     $student['q7a1'],
  1409.                     $student['q7a2'],
  1410.                     $student['q7a3'],
  1411.                     $student['q7a4'],
  1412.                     $student['q7a5'],
  1413.                     $student['q7a6'],
  1414.                     $student['q7a7'],
  1415.                 );
  1416.                 if (array_sum($q7Answers) == 100) {
  1417.                     $avarageROW['q7a1'][] = $student['q7a1'];
  1418.                     $avarageROW['q7a2'][] = $student['q7a2'];
  1419.                     $avarageROW['q7a3'][] = $student['q7a3'];
  1420.                     $avarageROW['q7a4'][] = $student['q7a4'];
  1421.                     $avarageROW['q7a5'][] = $student['q7a5'];
  1422.                     $avarageROW['q7a6'][] = $student['q7a6'];
  1423.                     $avarageROW['q7a7'][] = $student['q7a7'];
  1424.                     $avarageROW['q7H'][]  = max($q7Answers);
  1425.                     $avarageROW['q7L'][]  = min($q7Answers);
  1426.                     $teamSheet->setCellValue('BQ' $rowNBmax($q7Answers));
  1427.                     $teamSheet->setCellValue('BR' $rowNBmin($q7Answers));
  1428.                     $teamSheet->setCellValue('BS' $rowNBarray_sum($q7Answers));
  1429.                     $teamSheet->setCellValue($reorderingArray['q7a1'] . $rowNB$student['q7a1']);
  1430.                     $teamSheet->setCellValue($reorderingArray['q7a2'] . $rowNB$student['q7a2']);
  1431.                     $teamSheet->setCellValue($reorderingArray['q7a3'] . $rowNB$student['q7a3']);
  1432.                     $teamSheet->setCellValue($reorderingArray['q7a4'] . $rowNB$student['q7a4']);
  1433.                     $teamSheet->setCellValue($reorderingArray['q7a5'] . $rowNB$student['q7a5']);
  1434.                     $teamSheet->setCellValue($reorderingArray['q7a6'] . $rowNB$student['q7a6']);
  1435.                     $teamSheet->setCellValue($reorderingArray['q7a7'] . $rowNB$student['q7a7']);
  1436.                 }
  1437.                 $q8Answers = array(
  1438.                     $student['q8a1'],
  1439.                     $student['q8a2'],
  1440.                     $student['q8a3'],
  1441.                     $student['q8a4'],
  1442.                     $student['q8a5'],
  1443.                     $student['q8a6'],
  1444.                     $student['q8a7'],
  1445.                 );
  1446.                 if (array_sum($q8Answers) == 100) {
  1447.                     $avarageROW['q8a1'][] = $student['q8a1'];
  1448.                     $avarageROW['q8a2'][] = $student['q8a2'];
  1449.                     $avarageROW['q8a3'][] = $student['q8a3'];
  1450.                     $avarageROW['q8a4'][] = $student['q8a4'];
  1451.                     $avarageROW['q8a5'][] = $student['q8a5'];
  1452.                     $avarageROW['q8a6'][] = $student['q8a6'];
  1453.                     $avarageROW['q8a7'][] = $student['q8a7'];
  1454.                     $avarageROW['q8H'][] = max($q8Answers);
  1455.                     $avarageROW['q8L'][] = min($q8Answers);
  1456.                     $teamSheet->setCellValue('CA' $rowNBmax($q8Answers));
  1457.                     $teamSheet->setCellValue('CB' $rowNBmin($q8Answers));
  1458.                     $teamSheet->setCellValue('CC' $rowNBarray_sum($q8Answers));
  1459.                     $teamSheet->setCellValue($reorderingArray['q8a1'] . $rowNB$student['q8a1']);
  1460.                     $teamSheet->setCellValue($reorderingArray['q8a2'] . $rowNB$student['q8a2']);
  1461.                     $teamSheet->setCellValue($reorderingArray['q8a3'] . $rowNB$student['q8a3']);
  1462.                     $teamSheet->setCellValue($reorderingArray['q8a4'] . $rowNB$student['q8a4']);
  1463.                     $teamSheet->setCellValue($reorderingArray['q8a5'] . $rowNB$student['q8a5']);
  1464.                     $teamSheet->setCellValue($reorderingArray['q8a6'] . $rowNB$student['q8a6']);
  1465.                     $teamSheet->setCellValue($reorderingArray['q8a7'] . $rowNB$student['q8a7']);
  1466.                 }
  1467.             }
  1468.             $teamSheet->setCellValue('CD' $rowNB$student['username']);
  1469.             $teamSheet->setCellValue('CE' $rowNB$student['first_name']);
  1470.             $rowNB++;
  1471.         }
  1472.         $teamSheet->mergeCells("B" $rowNB ":H" $rowNB "");
  1473.         $teamSheet->mergeCells("L" $rowNB ":Q" $rowNB "");
  1474.         $teamSheet->mergeCells("V" $rowNB ":AB" $rowNB "");
  1475.         $teamSheet->mergeCells("AF" $rowNB ":AL" $rowNB "");
  1476.         $teamSheet->mergeCells("AP" $rowNB ":AV" $rowNB "");
  1477.         $teamSheet->mergeCells("AZ" $rowNB ":BF" $rowNB "");
  1478.         $teamSheet->mergeCells("BJ" $rowNB ":BP" $rowNB "");
  1479.         $teamSheet->mergeCells("BT" $rowNB ":BZ" $rowNB "");
  1480.         if ($j 3) {
  1481.             $teamSheet->setCellValue('B' $rowNB '''Decision Making    ');
  1482.             $teamSheet->setCellValue('L' $rowNB '''Conflict Management    ');
  1483.             $teamSheet->setCellValue('V' $rowNB '''Strategy Setting    ');
  1484.             $teamSheet->setCellValue('AF' $rowNB '''Authority');
  1485.             $teamSheet->setCellValue('AP' $rowNB '''Advocacy    ');
  1486.             $teamSheet->setCellValue('AZ' $rowNB '''Coordination');
  1487.             $teamSheet->setCellValue('BJ' $rowNB '''Critique & Feedback');
  1488.             $teamSheet->setCellValue('BT' $rowNB '''Accountability    ');
  1489.         } else {
  1490.             $teamSheet->setCellValue('B' $rowNB '''Decision Making    ');
  1491.             $teamSheet->setCellValue('L' $rowNB '''Conflict Management    ');
  1492.             $teamSheet->setCellValue('V' $rowNB '''Critique & Feedback    ');
  1493.         }
  1494.         $rowNB++;
  1495.         $teamSheet->setCellValue('A' $rowNB '''ID');
  1496.         $teamSheet->setCellValue('B' $rowNB '''Opp');
  1497.         $teamSheet->setCellValue('C' $rowNB '''1,1');
  1498.         $teamSheet->setCellValue('D' $rowNB '''1,9');
  1499.         $teamSheet->setCellValue('E' $rowNB '''5,5');
  1500.         $teamSheet->setCellValue('F' $rowNB '''9,1');
  1501.         $teamSheet->setCellValue('G' $rowNB '''PAT');
  1502.         $teamSheet->setCellValue('H' $rowNB '''9,9');
  1503.         $teamSheet->setCellValue('I' $rowNB '''High');
  1504.         $teamSheet->setCellValue('J' $rowNB '''Low');
  1505.         $teamSheet->setCellValue('K' $rowNB '''Total Percent Q1');
  1506.         $teamSheet->setCellValue('L' $rowNB '''Opp');
  1507.         $teamSheet->setCellValue('M' $rowNB '''1,1');
  1508.         $teamSheet->setCellValue('N' $rowNB '''1,9');
  1509.         $teamSheet->setCellValue('O' $rowNB '''5,5');
  1510.         $teamSheet->setCellValue('P' $rowNB '''9,1');
  1511.         $teamSheet->setCellValue('Q' $rowNB '''PAT');
  1512.         $teamSheet->setCellValue('R' $rowNB '''9,9');
  1513.         $teamSheet->setCellValue('S' $rowNB '''High');
  1514.         $teamSheet->setCellValue('T' $rowNB '''Low');
  1515.         $teamSheet->setCellValue('U' $rowNB '''Total Percent Q2');
  1516.         $teamSheet->setCellValue('V' $rowNB '''Opp');
  1517.         $teamSheet->setCellValue('W' $rowNB '''1,1');
  1518.         $teamSheet->setCellValue('X' $rowNB '''1,9');
  1519.         $teamSheet->setCellValue('Y' $rowNB '''5,5');
  1520.         $teamSheet->setCellValue('Z' $rowNB '''9,1');
  1521.         $teamSheet->setCellValue('AA' $rowNB '''PAT');
  1522.         $teamSheet->setCellValue('AB' $rowNB '''9,9');
  1523.         $teamSheet->setCellValue('AC' $rowNB '''High');
  1524.         $teamSheet->setCellValue('AD' $rowNB '''Low');
  1525.         $teamSheet->setCellValue('AE' $rowNB '''Total Percent Q3');
  1526.         if ($j 3) {
  1527.             $teamSheet->setCellValue('AF' $rowNB '''Opp');
  1528.             $teamSheet->setCellValue('AG' $rowNB '''1,1');
  1529.             $teamSheet->setCellValue('AH' $rowNB '''1,9');
  1530.             $teamSheet->setCellValue('AI' $rowNB '''5,5');
  1531.             $teamSheet->setCellValue('AJ' $rowNB '''9,1');
  1532.             $teamSheet->setCellValue('AK' $rowNB '''PAT');
  1533.             $teamSheet->setCellValue('AL' $rowNB '''9,9');
  1534.             $teamSheet->setCellValue('AM' $rowNB '''High');
  1535.             $teamSheet->setCellValue('AN' $rowNB '''Low');
  1536.             $teamSheet->setCellValue('AO' $rowNB '''Total Percent Q4');
  1537.             $teamSheet->setCellValue('AP' $rowNB '''Opp');
  1538.             $teamSheet->setCellValue('AQ' $rowNB '''1,1');
  1539.             $teamSheet->setCellValue('AR' $rowNB '''1,9');
  1540.             $teamSheet->setCellValue('AS' $rowNB '''5,5');
  1541.             $teamSheet->setCellValue('AT' $rowNB '''9,1');
  1542.             $teamSheet->setCellValue('AU' $rowNB '''PAT');
  1543.             $teamSheet->setCellValue('AV' $rowNB '''9,9');
  1544.             $teamSheet->setCellValue('AW' $rowNB '''High');
  1545.             $teamSheet->setCellValue('AX' $rowNB '''Low');
  1546.             $teamSheet->setCellValue('AY' $rowNB '''Total Percent Q5');
  1547.             $teamSheet->setCellValue('AZ' $rowNB '''Opp');
  1548.             $teamSheet->setCellValue('BA' $rowNB '''1,1');
  1549.             $teamSheet->setCellValue('BB' $rowNB '''1,9');
  1550.             $teamSheet->setCellValue('BC' $rowNB '''5,5');
  1551.             $teamSheet->setCellValue('BD' $rowNB '''9,1');
  1552.             $teamSheet->setCellValue('BE' $rowNB '''PAT');
  1553.             $teamSheet->setCellValue('BF' $rowNB '''9,9');
  1554.             $teamSheet->setCellValue('BG' $rowNB '''High');
  1555.             $teamSheet->setCellValue('BH' $rowNB '''Low');
  1556.             $teamSheet->setCellValue('BI' $rowNB '''Total Percent Q6');
  1557.             $teamSheet->setCellValue('BJ' $rowNB '''Opp');
  1558.             $teamSheet->setCellValue('BK' $rowNB '''1,1');
  1559.             $teamSheet->setCellValue('BL' $rowNB '''1,9');
  1560.             $teamSheet->setCellValue('BM' $rowNB '''5,5');
  1561.             $teamSheet->setCellValue('BN' $rowNB '''9,1');
  1562.             $teamSheet->setCellValue('BO' $rowNB '''PAT');
  1563.             $teamSheet->setCellValue('BP' $rowNB '''9,9');
  1564.             $teamSheet->setCellValue('BQ' $rowNB '''High');
  1565.             $teamSheet->setCellValue('BR' $rowNB '''Low');
  1566.             $teamSheet->setCellValue('BS' $rowNB '''Total Percent Q7');
  1567.             $teamSheet->setCellValue('BT' $rowNB '''Opp');
  1568.             $teamSheet->setCellValue('BU' $rowNB '''1,1');
  1569.             $teamSheet->setCellValue('BV' $rowNB '''1,9');
  1570.             $teamSheet->setCellValue('BW' $rowNB '''5,5');
  1571.             $teamSheet->setCellValue('BX' $rowNB '''9,1');
  1572.             $teamSheet->setCellValue('BY' $rowNB '''PAT');
  1573.             $teamSheet->setCellValue('BZ' $rowNB '''9,9');
  1574.             $teamSheet->setCellValue('CA' $rowNB '''High');
  1575.             $teamSheet->setCellValue('CB' $rowNB '''Low');
  1576.             $teamSheet->setCellValue('CC' $rowNB '''Total Percent Q8');
  1577.         }
  1578.         $rowNB++;
  1579.         if (isset($avarageROW['q1H'])) {
  1580.             //        $teamSheet->setCellValue('I' . $rowNB, array_sum($avarageROW['q1H']) / count($avarageROW['q1H']));
  1581. //        $teamSheet->setCellValue('J' . $rowNB, array_sum($avarageROW['q1L']) / count($avarageROW['q1L']));
  1582.             $teamSheet->setCellValue('I' $rowNBmax($avarageROW['q1H']));
  1583.             $teamSheet->setCellValue('J' $rowNBmin($avarageROW['q1L']));
  1584.             $teamSheet->setCellValue($reorderingArray['q1a1'] . $rowNBarray_sum($avarageROW['q1a1']) / count($avarageROW['q1a1']));
  1585.             $teamSheet->setCellValue($reorderingArray['q1a2'] . $rowNBarray_sum($avarageROW['q1a2']) / count($avarageROW['q1a2']));
  1586.             $teamSheet->setCellValue($reorderingArray['q1a3'] . $rowNBarray_sum($avarageROW['q1a3']) / count($avarageROW['q1a3']));
  1587.             $teamSheet->setCellValue($reorderingArray['q1a4'] . $rowNBarray_sum($avarageROW['q1a4']) / count($avarageROW['q1a4']));
  1588.             $teamSheet->setCellValue($reorderingArray['q1a5'] . $rowNBarray_sum($avarageROW['q1a5']) / count($avarageROW['q1a5']));
  1589.             $teamSheet->setCellValue($reorderingArray['q1a6'] . $rowNBarray_sum($avarageROW['q1a6']) / count($avarageROW['q1a6']));
  1590.             $teamSheet->setCellValue($reorderingArray['q1a7'] . $rowNBarray_sum($avarageROW['q1a7']) / count($avarageROW['q1a7']));
  1591.         }
  1592.         if (isset($avarageROW['q2H'])) {
  1593. //        $teamSheet->setCellValue('S' . $rowNB, array_sum($avarageROW['q2H']) / count($avarageROW['q2H']));
  1594. //        $teamSheet->setCellValue('T' . $rowNB, array_sum($avarageROW['q2L']) / count($avarageROW['q2L']));
  1595.             $teamSheet->setCellValue('S' $rowNBmax($avarageROW['q2H']));
  1596.             $teamSheet->setCellValue('T' $rowNBmin($avarageROW['q2L']));
  1597.             $teamSheet->setCellValue($reorderingArray['q2a1'] . $rowNBarray_sum($avarageROW['q2a1']) / count($avarageROW['q2a1']));
  1598.             $teamSheet->setCellValue($reorderingArray['q2a2'] . $rowNBarray_sum($avarageROW['q2a2']) / count($avarageROW['q2a2']));
  1599.             $teamSheet->setCellValue($reorderingArray['q2a3'] . $rowNBarray_sum($avarageROW['q2a3']) / count($avarageROW['q2a3']));
  1600.             $teamSheet->setCellValue($reorderingArray['q2a4'] . $rowNBarray_sum($avarageROW['q2a4']) / count($avarageROW['q2a4']));
  1601.             $teamSheet->setCellValue($reorderingArray['q2a5'] . $rowNBarray_sum($avarageROW['q2a5']) / count($avarageROW['q2a5']));
  1602.             $teamSheet->setCellValue($reorderingArray['q2a6'] . $rowNBarray_sum($avarageROW['q2a6']) / count($avarageROW['q2a6']));
  1603.             $teamSheet->setCellValue($reorderingArray['q2a7'] . $rowNBarray_sum($avarageROW['q2a7']) / count($avarageROW['q2a7']));
  1604.         }
  1605.         if (isset($avarageROW['q3H'])) {
  1606. //        $teamSheet->setCellValue('AC' . $rowNB, array_sum($avarageROW['q3H']) / count($avarageROW['q3H']));
  1607. //        $teamSheet->setCellValue('AD' . $rowNB, array_sum($avarageROW['q3L']) / count($avarageROW['q3L']));
  1608.             $teamSheet->setCellValue('AC' $rowNBmax($avarageROW['q3H']));
  1609.             $teamSheet->setCellValue('AD' $rowNBmin($avarageROW['q3L']));
  1610.             $teamSheet->setCellValue($reorderingArray['q3a1'] . $rowNBarray_sum($avarageROW['q3a1']) / count($avarageROW['q3a1']));
  1611.             $teamSheet->setCellValue($reorderingArray['q3a2'] . $rowNBarray_sum($avarageROW['q3a2']) / count($avarageROW['q3a2']));
  1612.             $teamSheet->setCellValue($reorderingArray['q3a3'] . $rowNBarray_sum($avarageROW['q3a3']) / count($avarageROW['q3a3']));
  1613.             $teamSheet->setCellValue($reorderingArray['q3a4'] . $rowNBarray_sum($avarageROW['q3a4']) / count($avarageROW['q3a4']));
  1614.             $teamSheet->setCellValue($reorderingArray['q3a5'] . $rowNBarray_sum($avarageROW['q3a5']) / count($avarageROW['q3a5']));
  1615.             $teamSheet->setCellValue($reorderingArray['q3a6'] . $rowNBarray_sum($avarageROW['q3a6']) / count($avarageROW['q3a6']));
  1616.             $teamSheet->setCellValue($reorderingArray['q3a7'] . $rowNBarray_sum($avarageROW['q3a7']) / count($avarageROW['q3a7']));
  1617.         }
  1618.         if (isset($avarageROW['q4H'])) {
  1619. //        $teamSheet->setCellValue('AM' . $rowNB, array_sum($avarageROW['q4H']) / count($avarageROW['q4H']));
  1620. //        $teamSheet->setCellValue('AN' . $rowNB, array_sum($avarageROW['q4L']) / count($avarageROW['q4L']));
  1621.             $teamSheet->setCellValue('AM' $rowNBmax($avarageROW['q4H']));
  1622.             $teamSheet->setCellValue('AN' $rowNBmin($avarageROW['q4L']));
  1623.             $teamSheet->setCellValue($reorderingArray['q4a1'] . $rowNBarray_sum($avarageROW['q4a1']) / count($avarageROW['q4a1']));
  1624.             $teamSheet->setCellValue($reorderingArray['q4a2'] . $rowNBarray_sum($avarageROW['q4a2']) / count($avarageROW['q4a2']));
  1625.             $teamSheet->setCellValue($reorderingArray['q4a3'] . $rowNBarray_sum($avarageROW['q4a3']) / count($avarageROW['q4a3']));
  1626.             $teamSheet->setCellValue($reorderingArray['q4a4'] . $rowNBarray_sum($avarageROW['q4a4']) / count($avarageROW['q4a4']));
  1627.             $teamSheet->setCellValue($reorderingArray['q4a5'] . $rowNBarray_sum($avarageROW['q4a5']) / count($avarageROW['q4a5']));
  1628.             $teamSheet->setCellValue($reorderingArray['q4a6'] . $rowNBarray_sum($avarageROW['q4a6']) / count($avarageROW['q4a6']));
  1629.             $teamSheet->setCellValue($reorderingArray['q4a7'] . $rowNBarray_sum($avarageROW['q4a7']) / count($avarageROW['q4a7']));
  1630.         }
  1631.         if (isset($avarageROW['q5H'])) {
  1632. //        $teamSheet->setCellValue('AW' . $rowNB, array_sum($avarageROW['q5H']) / count($avarageROW['q5H']));
  1633. //        $teamSheet->setCellValue('AX' . $rowNB, array_sum($avarageROW['q5L']) / count($avarageROW['q5L']));
  1634.             $teamSheet->setCellValue('AW' $rowNBmax($avarageROW['q5H']));
  1635.             $teamSheet->setCellValue('AX' $rowNBmin($avarageROW['q5L']));
  1636.             $teamSheet->setCellValue($reorderingArray['q5a1'] . $rowNBarray_sum($avarageROW['q5a1']) / count($avarageROW['q5a1']));
  1637.             $teamSheet->setCellValue($reorderingArray['q5a2'] . $rowNBarray_sum($avarageROW['q5a2']) / count($avarageROW['q5a2']));
  1638.             $teamSheet->setCellValue($reorderingArray['q5a3'] . $rowNBarray_sum($avarageROW['q5a3']) / count($avarageROW['q5a3']));
  1639.             $teamSheet->setCellValue($reorderingArray['q5a4'] . $rowNBarray_sum($avarageROW['q5a4']) / count($avarageROW['q5a4']));
  1640.             $teamSheet->setCellValue($reorderingArray['q5a5'] . $rowNBarray_sum($avarageROW['q5a5']) / count($avarageROW['q5a5']));
  1641.             $teamSheet->setCellValue($reorderingArray['q5a6'] . $rowNBarray_sum($avarageROW['q5a6']) / count($avarageROW['q5a6']));
  1642.             $teamSheet->setCellValue($reorderingArray['q5a7'] . $rowNBarray_sum($avarageROW['q5a7']) / count($avarageROW['q5a7']));
  1643.         }
  1644.         if (isset($avarageROW['q6H'])) {
  1645. //        $teamSheet->setCellValue('BG' . $rowNB, array_sum($avarageROW['q6H']) / count($avarageROW['q6H']));
  1646. //        $teamSheet->setCellValue('BH' . $rowNB, array_sum($avarageROW['q6L']) / count($avarageROW['q6L']));
  1647.             $teamSheet->setCellValue('BG' $rowNBmax($avarageROW['q6H']));
  1648.             $teamSheet->setCellValue('BH' $rowNBmin($avarageROW['q6L']));
  1649.             $teamSheet->setCellValue($reorderingArray['q6a1'] . $rowNBarray_sum($avarageROW['q6a1']) / count($avarageROW['q6a1']));
  1650.             $teamSheet->setCellValue($reorderingArray['q6a2'] . $rowNBarray_sum($avarageROW['q6a2']) / count($avarageROW['q6a2']));
  1651.             $teamSheet->setCellValue($reorderingArray['q6a3'] . $rowNBarray_sum($avarageROW['q6a3']) / count($avarageROW['q6a3']));
  1652.             $teamSheet->setCellValue($reorderingArray['q6a4'] . $rowNBarray_sum($avarageROW['q6a4']) / count($avarageROW['q6a4']));
  1653.             $teamSheet->setCellValue($reorderingArray['q6a5'] . $rowNBarray_sum($avarageROW['q6a5']) / count($avarageROW['q6a5']));
  1654.             $teamSheet->setCellValue($reorderingArray['q6a6'] . $rowNBarray_sum($avarageROW['q6a6']) / count($avarageROW['q6a6']));
  1655.             $teamSheet->setCellValue($reorderingArray['q6a7'] . $rowNBarray_sum($avarageROW['q6a7']) / count($avarageROW['q6a7']));
  1656.         }
  1657.         if (isset($avarageROW['q7H'])) {
  1658. //        $teamSheet->setCellValue('BQ' . $rowNB, array_sum($avarageROW['q7H']) / count($avarageROW['q7H']));
  1659. //        $teamSheet->setCellValue('BR' . $rowNB, array_sum($avarageROW['q7L']) / count($avarageROW['q7L']));
  1660.             $teamSheet->setCellValue('BQ' $rowNBmax($avarageROW['q7H']));
  1661.             $teamSheet->setCellValue('BR' $rowNBmin($avarageROW['q7L']));
  1662.             $teamSheet->setCellValue($reorderingArray['q7a1'] . $rowNBarray_sum($avarageROW['q7a1']) / count($avarageROW['q7a1']));
  1663.             $teamSheet->setCellValue($reorderingArray['q7a2'] . $rowNBarray_sum($avarageROW['q7a2']) / count($avarageROW['q7a2']));
  1664.             $teamSheet->setCellValue($reorderingArray['q7a3'] . $rowNBarray_sum($avarageROW['q7a3']) / count($avarageROW['q7a3']));
  1665.             $teamSheet->setCellValue($reorderingArray['q7a4'] . $rowNBarray_sum($avarageROW['q7a4']) / count($avarageROW['q7a4']));
  1666.             $teamSheet->setCellValue($reorderingArray['q7a5'] . $rowNBarray_sum($avarageROW['q7a5']) / count($avarageROW['q7a5']));
  1667.             $teamSheet->setCellValue($reorderingArray['q7a6'] . $rowNBarray_sum($avarageROW['q7a6']) / count($avarageROW['q7a6']));
  1668.             $teamSheet->setCellValue($reorderingArray['q7a7'] . $rowNBarray_sum($avarageROW['q7a7']) / count($avarageROW['q7a7']));
  1669.         }
  1670.         if (isset($avarageROW['q8H'])) {
  1671. //        $teamSheet->setCellValue('CA' . $rowNB, array_sum($avarageROW['q8H']) / count($avarageROW['q8H']));
  1672. //        $teamSheet->setCellValue('CB' . $rowNB, array_sum($avarageROW['q8L']) / count($avarageROW['q8L']));
  1673.             $teamSheet->setCellValue('CA' $rowNBmax($avarageROW['q8H']));
  1674.             $teamSheet->setCellValue('CB' $rowNBmin($avarageROW['q8L']));
  1675.             $teamSheet->setCellValue($reorderingArray['q8a1'] . $rowNBarray_sum($avarageROW['q8a1']) / count($avarageROW['q8a1']));
  1676.             $teamSheet->setCellValue($reorderingArray['q8a2'] . $rowNBarray_sum($avarageROW['q8a2']) / count($avarageROW['q8a2']));
  1677.             $teamSheet->setCellValue($reorderingArray['q8a3'] . $rowNBarray_sum($avarageROW['q8a3']) / count($avarageROW['q8a3']));
  1678.             $teamSheet->setCellValue($reorderingArray['q8a4'] . $rowNBarray_sum($avarageROW['q8a4']) / count($avarageROW['q8a4']));
  1679.             $teamSheet->setCellValue($reorderingArray['q8a5'] . $rowNBarray_sum($avarageROW['q8a5']) / count($avarageROW['q8a5']));
  1680.             $teamSheet->setCellValue($reorderingArray['q8a6'] . $rowNBarray_sum($avarageROW['q8a6']) / count($avarageROW['q8a6']));
  1681.             $teamSheet->setCellValue($reorderingArray['q8a7'] . $rowNBarray_sum($avarageROW['q8a7']) / count($avarageROW['q8a7']));
  1682.         }
  1683.         return $teamSheet;
  1684.     }
  1685. }