Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 428 | Rev 430 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 428 Rev 429
Línea 314... Línea 314...
314
        e.preventDefault();
314
        e.preventDefault();
315
        objFormGenerator.editQuestion(
315
        objFormGenerator.editQuestion(
316
            $('#section').val(),
316
            $('#section').val(),
317
            $('#question').val(),
317
            $('#question').val(),
318
            $('#question-comment').val(),
318
            $('#question-comment').val(),
319
            $('#question-status').val() =='1' ? true : false
319
            $('#question-status').val() == '1' ? true : false
320
        );
320
        );
321
        renderSectionData(objFormGenerator.sections);
321
        renderSectionData(objFormGenerator.sections);
322
        $('#form-review')[0].reset();
322
        $('#form-review')[0].reset();
323
        $('#modal-review').modal('hide');
323
        $('#modal-review').modal('hide');
324
    });
324
    });
325
    /**
325
    /**
326
     * Clicked edit question
326
     * Clicked edit question
327
     */
327
     */
328
    $('body').on('click', 'button.btn-edit-review', function(e) {
328
    $('body').on('click', 'button.btn-edit-review', function(e) {
329
        e.preventDefault();
329
        e.preventDefault();
330
 
-
 
331
        e.preventDefault();
330
        e.preventDefault();
332
        var slug_section = $(this).data('section');
331
        var slug_section = $(this).data('section');
333
        var slug_question = $(this).data('question');
332
        var slug_question = $(this).data('question');
334
        var showForm = false;
333
        var showForm = false;
335
        for (i = 0; i < objFormGenerator.sections.length; i++) {
334
        for (i = 0; i < objFormGenerator.sections.length; i++) {
336
            if (slug_section == objFormGenerator.sections[i].slug_section) {
335
            if (slug_section == objFormGenerator.sections[i].slug_section) {
337
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
336
                for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
338
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
337
                    if (slug_question == objFormGenerator.sections[i].questions[j].slug_question) {
339
 
-
 
340
                        $('#form-review #section').val(objFormGenerator.sections[i].slug_section);
338
                        $('#form-review #section').val(objFormGenerator.sections[i].slug_section);
341
                        $('#form-review #question').val(objFormGenerator.sections[i].questions[j].slug_question);
339
                        $('#form-review #question').val(objFormGenerator.sections[i].questions[j].slug_question);
342
 
-
 
343
                        if(objFormGenerator.sections[i].questions[j].status) {
340
                        if (objFormGenerator.sections[i].questions[j].status) {
344
                            $('#form-review #question-status').val('1');
341
                            $('#form-review #question-status').val('1');
345
                        } else {
342
                        } else {
346
                            $('#form-review #question-status').val('0');
343
                            $('#form-review #question-status').val('0');
347
  
-
 
348
                        }
344
                        }
349
                        if(objFormGenerator.sections[i].questions[j].comment) {
345
                        if (objFormGenerator.sections[i].questions[j].comment) {
350
                            $('#form-review #question-comment').val(objFormGenerator.sections[i].questions[j].comment);
346
                            $('#form-review #question-comment').val(objFormGenerator.sections[i].questions[j].comment);
351
                        }else{
347
                        } else {
352
                            $('#form-review #question-comment').val('');   
348
                            $('#form-review #question-comment').val('');
353
                        }
349
                        }
354
                        $('#modal-review').modal('show');
350
                        $('#modal-review').modal('show');
355
                        return true;
351
                        return true;
356
                    }
352
                    }
357
                }
353
                }
358
               
-
 
359
            }
354
            }
360
        }
355
        }
361
    
-
 
362
    });
356
    });
363
    /**
357
    /**
364
     * Clicked on edit form
358
     * Clicked on edit form
365
     */
359
     */
366
    $('body').on('click', 'button.btn-edit-form', function(e) {
360
    $('body').on('click', 'button.btn-edit-form', function(e) {
Línea 454... Línea 448...
454
        status = type == 'multiple' ?
448
        status = type == 'multiple' ?
455
            options.filter((opt) => answer.includes(opt.slug_option) && opt.correct == '1') :
449
            options.filter((opt) => answer.includes(opt.slug_option) && opt.correct == '1') :
456
            options.filter((opt) => opt.slug_option == answer && opt.correct == '1');
450
            options.filter((opt) => opt.slug_option == answer && opt.correct == '1');
457
        return status.length != 0 ? '<font color="green">LABEL_CORRECT</font>' : '<font color="red">LABEL_FAIL</red>';
451
        return status.length != 0 ? '<font color="green">LABEL_CORRECT</font>' : '<font color="red">LABEL_FAIL</red>';
458
    }
452
    }
-
 
453
    const getPtos = (options, answer, type, value, question_ptos) => {
-
 
454
        let ptos = 0;
-
 
455
        if (type == "open" || type == "rating-open" || type == "rating-range") {
-
 
456
                ptos = question_ptos ? question_ptos : 0;
-
 
457
        } else {
-
 
458
            if (type == 'multiple') {
-
 
459
                options.map((opt) => {
-
 
460
                    if (answer.includes(opt.slug_option)) {
-
 
461
                        ptos += opt.value;
-
 
462
                    }
-
 
463
                })
-
 
464
            } else {
-
 
465
                options.map((opt) => {
-
 
466
                    if (opt.slug_option == answer) {
-
 
467
                        ptos = opt.value;
-
 
468
                    }
-
 
469
                });
-
 
470
            }
-
 
471
        }
-
 
472
        return ptos + '/' + value;
-
 
473
    }
459
    /**
474
    /**
460
     * Remove Html Tags
475
     * Remove Html Tags
461
     */
476
     */
462
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
477
    const removeTags = (str) => str.toString().replace(/(<([^>]+)>)/ig, '')
463
    /**
478
    /**
464
     * Render Sections data
479
     * Render Sections data
465
     */
480
     */
466
    const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
481
    const renderSectionData = (data) => $("#rows").html($("#sectionTemplate").render(data, {
467
        removeTags: removeTags,
482
        removeTags: removeTags,
468
        getAnswer: getAnswer,
483
        getAnswer: getAnswer,
469
        getStatus: getStatus
484
        getStatus: getStatus,
-
 
485
        getPtos: getPtos
470
    }));
486
    }));
471
    /**
487
    /**
472
     * Clear Div Section data 
488
     * Clear Div Section data 
473
     */
489
     */
474
    const clearSectionData = () => $("#rows").html('');
490
    const clearSectionData = () => $("#rows").html('');
Línea 627... Línea 643...
627
                  <tr class="tr-question">
643
                  <tr class="tr-question">
628
                     <td class="text-left">{{:~removeTags(text)}} </td>
644
                     <td class="text-left">{{:~removeTags(text)}} </td>
629
                     <td>{{:~getAnswer(type,options,answer)}}</td>
645
                     <td>{{:~getAnswer(type,options,answer)}}</td>
630
                     <td>
646
                     <td>
631
                        {{if type == 'simple'  || type=='multiple' }}
647
                        {{if type == 'simple'  || type=='multiple' }}
632
                        {{:~getStatus( options,answer,type)}}
648
                        {{:~getStatus(options,answer,type)}}
633
                        {{else}}
649
                        {{else}}
Línea 634... Línea 650...
634
 
650
 
635
                        {{if status}}
651
                        {{if status}}
636
                                    <font color="green">LABEL_CORRECT</font>
652
                                    <font color="green">LABEL_CORRECT</font>
Línea 640... Línea 656...
640
 
656
 
Línea 641... Línea 657...
641
 
657
 
-
 
658
                        {{/if}}
642
                        {{/if}}
659
                        
-
 
660
                     </td>
643
                        
661
                     <td>
644
                     </td>
662
                     {{:~getPtos(options,answer,type, value, question_ptos)}}/ 
Línea 645... Línea 663...
645
                     <td><font color="red">{{:value}}</font></td>
663
               </td>