Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7031 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 7031 Rev 7032
Línea 553... Línea 553...
553
    {
553
    {
554
        $tmpName = tempnam(sys_get_temp_dir(), 'data');
554
        $tmpName = tempnam(sys_get_temp_dir(), 'data');
555
        $tmp = fopen($tmpName, 'w');
555
        $tmp = fopen($tmpName, 'w');
556
        $sections = json_decode($surveyForm->content, true);
556
        $sections = json_decode($surveyForm->content, true);
Línea 557... Línea -...
557
 
-
 
558
        // fputcsv($tmp, ['Pregunta 1', '']);
-
 
559
        // fputcsv($tmp, ['Opcion 1', 2]);
-
 
560
        // fputcsv($tmp, ['Opcion 2', 3]);
-
 
561
        // fputcsv($tmp, ['Opcion 3', 5]);
-
 
562
 
-
 
563
        // fputcsv($tmp, ['Pregunta 2', '']);
-
 
564
        // fputcsv($tmp, ['Opcion 1', 4]);
-
 
565
        // fputcsv($tmp, ['Opcion 2', 7]);
-
 
566
        // fputcsv($tmp, ['Opcion 3', 1]);
-
 
567
 
557
 
568
        $allTests = array_map(
558
        $allTests = array_map(
569
            function($response) {
559
            function($response) {
570
                return json_decode($response->content, true);
560
                return json_decode($response->content, true);
571
            },
561
            },
Línea 617... Línea 607...
617
 
607
 
618
                }
608
                }
619
            }
609
            }
Línea 620... Línea -...
620
        }
-
 
621
 
-
 
622
        $countSection = 0;
610
        }
623
 
-
 
624
        for ($i = 0; $i < count($sections); $i++) {
-
 
625
            if ($countSection > 1) {
-
 
626
                $countSection = 0;
-
 
627
               
611
 
Línea 628... Línea 612...
628
            }
612
        for ($i = 0; $i < count($sections); $i++) {
629
            $section = $sections[$i];
-
 
630
        
-
 
631
            foreach ($section['questions'] as $question) {
613
            $section = $sections[$i];
632
                fputcsv($tmp, [strip_tags($question['text']), '']);
614
        
633
                
-
 
-
 
615
            foreach ($section['questions'] as $question) {
634
                switch ($question['type']) {
616
                switch ($question['type']) {
635
                        case 'simple':
617
                    case 'simple':
636
 
618
                        fputcsv($tmp, [strip_tags($question['text']), '']);
637
                            foreach($question['options'] as $option) {
-
 
638
                                fputcsv($tmp, [strip_tags($option['text']), round($averages[$question['slug_question']][$option['slug_option']], 2) . '%']);
-
 
Línea 639... Línea 619...
639
                            }
619
                        foreach($question['options'] as $option) {
Línea -... Línea 620...
-
 
620
                            fputcsv($tmp, [strip_tags($option['text']), round($averages[$question['slug_question']][$option['slug_option']], 2) . '%']);
-
 
621
                        }
640
 
622
 
641
                            break;
623
                        break;
642
 
624
 
Línea 643... Línea 625...
643
                        case 'multiple':
625
                    case 'multiple':
644
 
626
                        fputcsv($tmp, [strip_tags($question['text']), '']);
645
                            foreach($question['options'] as $option) {
-
 
646
                                fputcsv($tmp, [strip_tags($option['text']), $averages[$question['slug_question']][$option['slug_option']]]);
627
                        foreach($question['options'] as $option) {
Línea 647... Línea 628...
647
                            }
628
                            fputcsv($tmp, [strip_tags($option['text']), $averages[$question['slug_question']][$option['slug_option']]]);