Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 438 Rev 439
Línea 147... Línea 147...
147
            $('[data-toggle="tooltip"]').tooltip();
147
            $('[data-toggle="tooltip"]').tooltip();
148
        };
148
        };
149
    /**
149
    /**
150
     * Add element to question array
150
     * Add element to question array
151
     */
151
     */
152
    this.editQuestion = function(slug_section, slug_question, comment, status) {
152
    this.editQuestion = function(slug_section, slug_question, comment, question_value, status) {
153
        var renderTable = false;
153
        var renderTable = false;
154
        for (i = 0; i < this.sections.length; i++) {
154
        for (i = 0; i < this.sections.length; i++) {
155
            if (slug_section == this.sections[i].slug_section) {
155
            if (slug_section == this.sections[i].slug_section) {
156
                for (j = 0; j < this.sections[i].questions.length; j++) {
156
                for (j = 0; j < this.sections[i].questions.length; j++) {
157
                    if (slug_question == this.sections[i].questions[j].slug_question) {
157
                    if (slug_question == this.sections[i].questions[j].slug_question) {
Línea 311... Línea 311...
311
    /**
311
    /**
312
     * Clicked edit question
312
     * Clicked edit question
313
     */
313
     */
314
    $('body').on('click', 'button.btn-add-review', function(e) {
314
    $('body').on('click', 'button.btn-add-review', function(e) {
315
        e.preventDefault();
315
        e.preventDefault();
316
        console.log($('#question-value').val());
-
 
317
        if($('#question-value').val()==''){
316
        if ($('#question-value').val() == '') {
318
            $.fn.showError('ERROR_ENTER_VALUE');
317
            $.fn.showError('ERROR_ENTER_VALUE');
319
            return false;
318
            return false;
320
        }else{
319
        } else {
321
        objFormGenerator.editQuestion(
320
            objFormGenerator.editQuestion(
322
            $('#section').val(),
321
                $('#section').val(),
323
            $('#question').val(),
322
                $('#question').val(),
324
            $('#question-comment').val(),
323
                $('#question-comment').val(),
325
            $('#question-value').val(),
324
                $('#question-value').val(),
326
            $('#question-status').val() == '1' ? true : false
325
                $('#question-status').val() == '1' ? true : false
327
        );
326
            );
328
        renderSectionData(objFormGenerator.sections);
327
            renderSectionData(objFormGenerator.sections);
329
        $('#form-review')[0].reset();
328
            $('#form-review')[0].reset();
330
        $('#modal-review').modal('hide');
329
            $('#modal-review').modal('hide');
331
    }
330
        }
332
    });
331
    });
333
    /**
332
    /**
334
     * Clicked edit question
333
     * Clicked edit question
335
     */
334
     */
336
    $('body').on('click', 'button.btn-edit-review', function(e) {
335
    $('body').on('click', 'button.btn-edit-review', function(e) {
Línea 353... Línea 352...
353
                        if (objFormGenerator.sections[i].questions[j].comment) {
352
                        if (objFormGenerator.sections[i].questions[j].comment) {
354
                            $('#form-review #question-comment').val(objFormGenerator.sections[i].questions[j].comment);
353
                            $('#form-review #question-comment').val(objFormGenerator.sections[i].questions[j].comment);
355
                        } else {
354
                        } else {
356
                            $('#form-review #question-comment').val('');
355
                            $('#form-review #question-comment').val('');
357
                        }
356
                        }
358
 
-
 
359
                        if (objFormGenerator.sections[i].questions[j].question_value) {
357
                        if (objFormGenerator.sections[i].questions[j].question_value) {
360
                            $('#form-review #question-value').val(objFormGenerator.sections[i].questions[j].question_value);
358
                            $('#form-review #question-value').val(objFormGenerator.sections[i].questions[j].question_value);
361
                        } else {
359
                        } else {
362
                            $('#form-review #question-value').val(0);
360
                            $('#form-review #question-value').val(0);
363
                        }
361
                        }
Línea 465... Línea 463...
465
        return status.length != 0 ? '<font color="green">LABEL_CORRECT</font>' : '<font color="red">LABEL_FAIL</red>';
463
        return status.length != 0 ? '<font color="green">LABEL_CORRECT</font>' : '<font color="red">LABEL_FAIL</red>';
466
    }
464
    }
467
    const getPtos = (options, answer, type, value, question_ptos) => {
465
    const getPtos = (options, answer, type, value, question_ptos) => {
468
        let ptos = 0;
466
        let ptos = 0;
469
        if (type == "open" || type == "rating-open" || type == "rating-range") {
467
        if (type == "open" || type == "rating-open" || type == "rating-range") {
470
                ptos = question_ptos ? question_ptos : 0;
468
            ptos = question_ptos ? question_ptos : 0;
471
        } else {
469
        } else {
472
            if (type == 'multiple') {
470
            if (type == 'multiple') {
473
                options.map((opt) => {
471
                options.map((opt) => {
474
                    if (answer.includes(opt.slug_option)) {
472
                    if (answer.includes(opt.slug_option)) {
475
                        ptos += parseInt(opt.value);
473
                        ptos += parseInt(opt.value);