Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 6269 Rev 6276
Línea 307... Línea 307...
307
            }
307
            }
308
        },
308
        },
309
        /**
309
        /**
310
         * Add element to option array
310
         * Add element to option array
311
         */
311
         */
312
        this.addOption = function(slug_section, slug_question, text, correct) {
312
        this.addOption = function(slug_section, slug_question, text) {
313
            var d = new Date();
313
            var d = new Date();
314
            var slug_option = 'option' + d.getTime();
314
            var slug_option = 'option' + d.getTime();
315
            var position = 0;
315
            var position = 0;
316
            var renderTable = false;
316
            var renderTable = false;
317
            for (i = 0; i < this.sections.length; i++) {
317
            for (i = 0; i < this.sections.length; i++) {
Línea 327... Línea 327...
327
                            var option = {
327
                            var option = {
328
                                'slug_section': slug_section,
328
                                'slug_section': slug_section,
329
                                'slug_question': slug_question,
329
                                'slug_question': slug_question,
330
                                'slug_option': slug_option,
330
                                'slug_option': slug_option,
331
                                'text': text,
331
                                'text': text,
332
                                'correct': correct,
-
 
333
                                'checked': false
332
                                'checked': false
334
                            }
333
                            }
335
                            this.sections[i].questions[j].options.push(option);
334
                            this.sections[i].questions[j].options.push(option);
336
                            renderTable = true;
335
                            renderTable = true;
337
                            break;
336
                            break;
Línea 347... Línea 346...
347
            }
346
            }
348
        },
347
        },
349
        /**
348
        /**
350
         * Edit element to option array
349
         * Edit element to option array
351
         */
350
         */
352
        this.editOption = function(slug_section, slug_question, option_slug, text, correct) {
351
        this.editOption = function(slug_section, slug_question, option_slug, text) {
353
            var renderTable = false;
352
            var renderTable = false;
354
            for (i = 0; i < this.sections.length; i++) {
353
            for (i = 0; i < this.sections.length; i++) {
355
                if (slug_section == this.sections[i].slug_section) {
354
                if (slug_section == this.sections[i].slug_section) {
356
                    for (j = 0; j < this.sections[i].questions.length; j++) {
355
                    for (j = 0; j < this.sections[i].questions.length; j++) {
357
                        if (slug_question == this.sections[i].questions[j].slug_question) {
356
                        if (slug_question == this.sections[i].questions[j].slug_question) {
358
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
357
                            for (k = 0; k < this.sections[i].questions[j].options.length; k++) {
359
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
358
                                if (option_slug == this.sections[i].questions[j].options[k].slug_option) {
360
                                    this.sections[i].questions[j].options[k].text = text;
359
                                    this.sections[i].questions[j].options[k].text = text;
361
                                    this.sections[i].questions[j].options[k].correct = correct;
-
 
362
                                    renderTable = true;
360
                                    renderTable = true;
363
                                    break;
361
                                    break;
364
                                }
362
                                }
365
                            }
363
                            }
366
                        }
364
                        }
Línea 718... Línea 716...
718
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
716
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
719
                                return false;
717
                                return false;
720
                            }
718
                            }
721
                            var totalOption = 0;
719
                            var totalOption = 0;
722
                            var maxOption = 0;
720
                            var maxOption = 0;
723
                            for (k = 0; k < objFormGenerator.sections[i].questions[j].options.length; k++) {
-
 
724
                                if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
-
 
725
                                    if (objFormGenerator.sections[i].questions[j].options[k].correct == 1) {
-
 
726
                                        numberCorrect++;
-
 
727
                                    }
-
 
728
                                }
-
 
729
                            }
-
 
730
                            if (objFormGenerator.sections[i].questions[j].type == 'simple' || objFormGenerator.sections[i].questions[j].type == 'multiple') {
-
 
731
                                if (numberCorrect == 0) {
-
 
732
                                    $.fn.showError('ERROR_OPTIONS_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
-
 
733
                                    return false;
-
 
734
                                }
-
 
735
                                if (
-
 
736
                                    objFormGenerator.sections[i].questions[j].type == 'simple' && numberCorrect > 1) {
-
 
737
                                    $.fn.showError('ERROR_OPTIONS_DUPLICATE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
-
 
738
                                    return false;
-
 
739
                                }
-
 
740
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' && numberCorrect == 1) {
-
 
741
                                    $.fn.showError('ERROR_OPTIONS_ONE_CORRECT'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
-
 
742
                                    return false;
-
 
743
                                }
-
 
744
                            }
-
 
745
                        }
721
                        }
746
                    }
722
                    }
747
                }
723
                }
748
                var formContinue = parseInt($('#form-main #form-continue').val());
724
                var formContinue = parseInt($('#form-main #form-continue').val());
749
                var data = {
725
                var data = {
Línea 973... Línea 949...
973
            if ($('#form-option #option-slug').val()) {
949
            if ($('#form-option #option-slug').val()) {
974
                objFormGenerator.editOption(
950
                objFormGenerator.editOption(
975
                    $('#form-option #option-section').val(),
951
                    $('#form-option #option-section').val(),
976
                    $('#form-option #option-question').val(),
952
                    $('#form-option #option-question').val(),
977
                    $('#form-option #option-slug').val(),
953
                    $('#form-option #option-slug').val(),
978
                    $('#form-option #option-text').val(),
954
                    $('#form-option #option-text').val()                  
979
                    $('#form-option #option-correct').val()
-
 
980
                );
955
                );
981
            } else {
956
            } else {
982
                objFormGenerator.addOption(
957
                objFormGenerator.addOption(
983
                    $('#form-option #option-section').val(),
958
                    $('#form-option #option-section').val(),
984
                    $('#form-option #option-question').val(),
959
                    $('#form-option #option-question').val(),
985
                    $('#form-option #option-text').val(),
960
                    $('#form-option #option-text').val()
986
                    $('#form-option #option-correct').val()
-
 
987
                );
961
                );
988
            }
962
            }
989
            renderSectionData(objFormGenerator.sections);
963
            renderSectionData(objFormGenerator.sections);
990
            $('#modal-option').modal('hide');
964
            $('#modal-option').modal('hide');
991
            return false;
965
            return false;
Línea 1162... Línea 1136...
1162
                        $('#form-option #option-question').val(slug_question);
1136
                        $('#form-option #option-question').val(slug_question);
1163
                        $('#form-option #option-slug').val('');
1137
                        $('#form-option #option-slug').val('');
1164
                        CKEDITOR.instances['option-text'].setData('', function() {
1138
                        CKEDITOR.instances['option-text'].setData('', function() {
1165
                            editor.focus();
1139
                            editor.focus();
1166
                        });
1140
                        });
1167
                        $('#form-option #option-correct').val('0');
-
 
1168
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
1169
                            $('#form-option #option-correct').parent().hide();
-
 
1170
                        } else {
-
 
1171
                            $('#form-option #option-correct').parent().show();
-
 
1172
                        }
-
 
-
 
1141
                       
1173
                        renderSectionData(objFormGenerator.sections);
1142
                        renderSectionData(objFormGenerator.sections);
1174
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
1143
                        $('#modal-option h4[class="modal-title"]').html('LABEL_ADD LABEL_OPTION');
1175
                        $('#modal-option').modal('show');
1144
                        $('#modal-option').modal('show');
1176
                        return true;
1145
                        return true;
1177
                    }
1146
                    }
Línea 1200... Línea 1169...
1200
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
1169
                                $('#form-option #option-slug').val(objFormGenerator.sections[i].questions[j].options[k].slug_option);
1201
                                CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].questions[j].options[k].text,
1170
                                CKEDITOR.instances['option-text'].setData(objFormGenerator.sections[i].questions[j].options[k].text,
1202
                                    function() {
1171
                                    function() {
1203
                                        editor.focus();
1172
                                        editor.focus();
1204
                                    });
1173
                                    });
1205
                                $('#form-option #option-correct').val(objFormGenerator.sections[i].questions[j].options[k].correct);
-
 
1206
                                if (objFormGenerator.sections[i].questions[j].type == 'multiple' || objFormGenerator.sections[i].questions[j].type == 'simple') {
-
 
1207
                                    $('#form-option #option-correct').parent().show();
-
 
1208
                                } else {
-
 
1209
                                    $('#form-option #option-correct').parent().hide();
-
 
1210
                                }
-
 
1211
                                showForm = true;
1174
                                showForm = true;
1212
                                break;
1175
                                break;
1213
                            }
1176
                            }
1214
                        }
1177
                        }
1215
                    }
1178
                    }
Línea 1610... Línea 1573...
1610
                        <div class="form-group">
1573
                        <div class="form-group">
1611
                            <label for="option-text">LABEL_TEXT</label>
1574
                            <label for="option-text">LABEL_TEXT</label>
1612
                            <!--  ckeditor -->
1575
                            <!--  ckeditor -->
1613
                            <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
1576
                            <textarea  name="option-text" id="option-text" rows="5" class="ckeditor form-control"></textarea>
1614
                        </div>
1577
                        </div>
1615
                        <div class="form-group">
-
 
1616
                            <label for="option-correct">LABEL_ANSWER_CORRECT</label>
-
 
1617
                            <select name="option-correct" id="option-correct" class="form-control">
-
 
1618
                                <option value="1">LABEL_YES</option>
-
 
1619
                                <option value="0">LABEL_NOT</option>
-
 
1620
                            </select>
-
 
1621
                        </div>
-
 
1622
                    </div>
1578
                    </div>
1623
                    <div class="modal-footer">
1579
                    <div class="modal-footer">
1624
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1580
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1625
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1581
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1626
                    </div>
1582
                    </div>
Línea 1698... Línea 1654...
1698
                                <td>
1654
                                <td>
Línea 1699... Línea 1655...
1699
 
1655
 
1700
                                    {{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open'  }}
1656
                                    {{if ~getType( slug_section, slug_question) == 'multiple' || ~getType( slug_section, slug_question) == 'rating-open'  }}
1701
                                    {{/if}}
1657
                                    {{/if}}
1702
                                </td>
-
 
1703
                                <td class="text-left">
-
 
1704
                                    {{if ~getType( slug_section, slug_question) != 'rating-open'}}
-
 
1705
                                    {{if correct == 1}}
-
 
1706
                                    <font color="green">LABEL_CORRECT</font>
-
 
1707
                                    {{/if}}
-
 
1708
                                    {{if correct == 0}}
-
 
1709
                                    <font color="red">LABEL_FAIL</font>
-
 
1710
                                    {{/if}}
-
 
1711
                                    {{/if}}
-
 
1712
                                </td>
1658
                                </td>
1713
                                <td>
1659
                                <td>
1714
                                    <button class="btn btn-default btn-edit-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button>
1660
                                    <button class="btn btn-default btn-edit-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_OPTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_OPTION</button>
1715
                                    <button class="btn btn-default btn-delete-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button>
1661
                                    <button class="btn btn-default btn-delete-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-slug="{{:slug_option}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_OPTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_OPTION</button>
1716
                                </td>
1662
                                </td>