Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 6276 Rev 6321
Línea 84... Línea 84...
84
                if (slug_section != this.sections[i].slug_section) {
84
                if (slug_section != this.sections[i].slug_section) {
85
                    continue;
85
                    continue;
86
                }
86
                }
87
                for (j = 0; j < this.sections[i].questions.length; j++) {
87
                for (j = 0; j < this.sections[i].questions.length; j++) {
88
                    this.sections[i].questions[j].position = j;
88
                    this.sections[i].questions[j].position = j;
89
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
89
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple') {
90
                        this.sections[i].questions[j].options.sort(function(a, b) {
90
                        this.sections[i].questions[j].options.sort(function(a, b) {
91
                            if (a.position > b.position) {
91
                            if (a.position > b.position) {
92
                                return 1;
92
                                return 1;
93
                            }
93
                            }
94
                            if (a.position < b.position) {
94
                            if (a.position < b.position) {
Línea 126... Línea 126...
126
                    }
126
                    }
127
                    return 0;
127
                    return 0;
128
                });
128
                });
129
                for (j = 0; j < this.sections[i].questions.length; j++) {
129
                for (j = 0; j < this.sections[i].questions.length; j++) {
130
                    this.sections[i].questions[j].position = j;
130
                    this.sections[i].questions[j].position = j;
131
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
131
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple') {
132
                        this.sections[i].questions[j].options.sort(function(a, b) {
132
                        this.sections[i].questions[j].options.sort(function(a, b) {
133
                            if (a.position > b.position) {
133
                            if (a.position > b.position) {
134
                                return 1;
134
                                return 1;
135
                            }
135
                            }
136
                            if (a.position < b.position) {
136
                            if (a.position < b.position) {
Línea 203... Línea 203...
203
            }
203
            }
204
        },
204
        },
205
         /**
205
         /**
206
         * Add element to question array
206
         * Add element to question array
207
         */
207
         */
208
        this.addQuestion = function(slug_section, text, type, maxlength, multiline, range) {
208
        this.addQuestion = function(slug_section, text, type, maxlength, multiline) {
209
            var d = new Date();
209
            var d = new Date();
210
            var slug_question = 'question' + d.getTime();
210
            var slug_question = 'question' + d.getTime();
211
            var position = 0;
211
            var position = 0;
212
            var renderTable = false;
212
            var renderTable = false;
213
            for (i = 0; i < this.sections.length; i++) {
213
            for (i = 0; i < this.sections.length; i++) {
Línea 224... Línea 224...
224
                        'text': text,
224
                        'text': text,
225
                        'type': type,
225
                        'type': type,
226
                        'position': position,
226
                        'position': position,
227
                        'maxlength': maxlength,
227
                        'maxlength': maxlength,
228
                        'multiline': multiline,
228
                        'multiline': multiline,
229
                        'range': range,
-
 
230
                        'options': [],
229
                        'options': [],
231
                        'answer': type=='multiple' ? [] : ''
230
                        'answer': type=='multiple' ? [] : ''
232
                    }
231
                    }
233
                    this.sections[i].questions.push(question);
232
                    this.sections[i].questions.push(question);
234
                    renderTable = true;
233
                    renderTable = true;
Línea 240... Línea 239...
240
            }
239
            }
241
        },
240
        },
242
         /**
241
         /**
243
         * Add element to question array
242
         * Add element to question array
244
         */
243
         */
245
        this.editQuestion = function(slug_section, slug_question, text, type, maxlength, multiline, range) {
244
        this.editQuestion = function(slug_section, slug_question, text, type, maxlength, multiline) {
246
            var renderTable = false;
245
            var renderTable = false;
247
            for (i = 0; i < this.sections.length; i++) {
246
            for (i = 0; i < this.sections.length; i++) {
248
                if (slug_section == this.sections[i].slug_section) {
247
                if (slug_section == this.sections[i].slug_section) {
249
                    for (j = 0; j < this.sections[i].questions.length; j++) {
248
                    for (j = 0; j < this.sections[i].questions.length; j++) {
250
                        if (slug_question == this.sections[i].questions[j].slug_question) {
249
                        if (slug_question == this.sections[i].questions[j].slug_question) {
Línea 256... Línea 255...
256
                                this.sections[i].questions[j].options = [];
255
                                this.sections[i].questions[j].options = [];
257
                            } else {
256
                            } else {
258
                                this.sections[i].questions[j].maxlength = 0;
257
                                this.sections[i].questions[j].maxlength = 0;
259
                                this.sections[i].questions[j].multiline = 0;
258
                                this.sections[i].questions[j].multiline = 0;
260
                            }
259
                            }
261
                            if (type == 'rating-range') {
-
 
262
                                this.sections[i].questions[j].range = range;
-
 
263
                            } else {
-
 
264
                                this.sections[i].questions[j].range = 0;
-
 
265
                            }
-
 
Línea 266... Línea 260...
266
 
260
 
267
                            if(type=='multiple'){
261
                            if(type=='multiple'){
268
                                this.sections[i].questions[j].answer = [];  
262
                                this.sections[i].questions[j].answer = [];  
269
                            }else{
263
                            }else{
Línea 706... Línea 700...
706
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
700
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
707
                        return false;
701
                        return false;
708
                    }
702
                    }
709
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
703
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
710
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
704
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
711
                            objFormGenerator.sections[i].questions[j].type == 'multiple' ||
705
                            objFormGenerator.sections[i].questions[j].type == 'multiple') {
712
                            objFormGenerator.sections[i].questions[j].type == 'rating-open') {
-
 
713
                            var questionNumber = j + 1;
706
                            var questionNumber = j + 1;
714
                            var numberCorrect = 0;
707
                            var numberCorrect = 0;
715
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
708
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
716
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
709
                                $.fn.showError('ERROR_OPTIONS'.replace('%s', objFormGenerator.sections[i].name).replace('%n', questionNumber));
717
                                return false;
710
                                return false;
Línea 852... Línea 845...
852
            'question-max-length': {
845
            'question-max-length': {
853
                required: true,
846
                required: true,
854
                digits: true,
847
                digits: true,
855
                min: 0
848
                min: 0
856
            },
849
            },
857
            'question-range': {
-
 
858
                required: true,
-
 
859
                number: true,
-
 
860
                min: 1
-
 
861
            },
-
 
862
        },
850
        },
863
        highlight: function(element) {
851
        highlight: function(element) {
864
            $(element).closest('.form-group').addClass('has-error');
852
            $(element).closest('.form-group').addClass('has-error');
865
        },
853
        },
866
        unhighlight: function(element) {
854
        unhighlight: function(element) {
Línea 886... Línea 874...
886
                    $('#form-question #question-section').val(),
874
                    $('#form-question #question-section').val(),
887
                    $('#form-question #question-slug').val(),
875
                    $('#form-question #question-slug').val(),
888
                    $('#form-question #question-text').val(),
876
                    $('#form-question #question-text').val(),
889
                    $('#form-question #question-type').val(),
877
                    $('#form-question #question-type').val(),
890
                    $('#form-question #question-max-length').val(),
878
                    $('#form-question #question-max-length').val(),
891
                    $('#form-question #question-multiline').val(),
879
                    $('#form-question #question-multiline').val()
892
                    $('#form-question #question-range').val()
-
 
893
                );
880
                );
894
            } else {
881
            } else {
895
                objFormGenerator.addQuestion(
882
                objFormGenerator.addQuestion(
896
                    $('#form-question #question-section').val(),
883
                    $('#form-question #question-section').val(),
897
                    $('#form-question #question-text').val(),
884
                    $('#form-question #question-text').val(),
898
                    $('#form-question #question-type').val(),
885
                    $('#form-question #question-type').val(),
899
                    $('#form-question #question-max-length').val(),
886
                    $('#form-question #question-max-length').val(),
900
                    $('#form-question #question-multiline').val(),
887
                    $('#form-question #question-multiline').val()
901
                    $('#form-question #question-range').val()
-
 
902
                );
888
                );
903
            }
889
            }
904
            renderSectionData(objFormGenerator.sections);
890
            renderSectionData(objFormGenerator.sections);
905
            $('#modal-question').modal('hide');
891
            $('#modal-question').modal('hide');
906
            return false;
892
            return false;
Línea 1039... Línea 1025...
1039
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
1025
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
1040
        $('#form-question #question-max-length').val('0');
1026
        $('#form-question #question-max-length').val('0');
1041
        $('#form-question #question-max-length').parent().show();
1027
        $('#form-question #question-max-length').parent().show();
1042
        $('#form-question #question-multiline').val('0');
1028
        $('#form-question #question-multiline').val('0');
1043
        $('#form-question #question-multiline').parent().show();
1029
        $('#form-question #question-multiline').parent().show();
1044
        $('#form-question #question-range').val('10');
-
 
1045
        $('#form-question #question-range').parent().hide();
-
 
1046
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
1030
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
1047
        $('#modal-question').modal('show');
1031
        $('#modal-question').modal('show');
1048
    });
1032
    });
1049
    /**
1033
    /**
1050
     * Clicked edit question
1034
     * Clicked edit question
Línea 1072... Línea 1056...
1072
                            $('#form-question #question-max-length').val('0');
1056
                            $('#form-question #question-max-length').val('0');
1073
                            $('#form-question #question-max-length').parent().hide();
1057
                            $('#form-question #question-max-length').parent().hide();
1074
                            $('#form-question #question-multiline').val('0');
1058
                            $('#form-question #question-multiline').val('0');
1075
                            $('#form-question #question-multiline').parent().hide();
1059
                            $('#form-question #question-multiline').parent().hide();
1076
                        }
1060
                        }
1077
                        if (objFormGenerator.sections[i].questions[j].type == 'rating-range') {
-
 
1078
                            $('#form-question #question-range').val(objFormGenerator.sections[i].questions[j].range);
-
 
1079
                            $('#form-question #question-range').parent().show();
-
 
1080
                        } else {
-
 
1081
                            $('#form-question #question-range').val('10');
-
 
1082
                            $('#form-question #question-range').parent().hide();
-
 
1083
                        }
-
 
1084
                        showForm = true;
1061
                        showForm = true;
1085
                        break;
1062
                        break;
1086
                    }
1063
                    }
1087
                }
1064
                }
1088
                break;
1065
                break;
Línea 1236... Línea 1213...
1236
            $('#form-question #question-max-length').val('0');
1213
            $('#form-question #question-max-length').val('0');
1237
            $('#form-question #question-max-length').parent().hide();
1214
            $('#form-question #question-max-length').parent().hide();
1238
            $('#form-question #question-multiline').val('0');
1215
            $('#form-question #question-multiline').val('0');
1239
            $('#form-question #question-multiline').parent().hide();
1216
            $('#form-question #question-multiline').parent().hide();
1240
        }
1217
        }
1241
        $('#form-question #question-range').val('10');
-
 
1242
        if ($('#form-question #question-type').val() == 'rating-range') {
-
 
1243
            $('#form-question #question-range').parent().show();
-
 
1244
        } else {
-
 
1245
            $('#form-question #question-range').parent().hide();
-
 
1246
        }
-
 
1247
    });
1218
    });
1248
    /**
1219
    /**
1249
     * Clicked new Form
1220
     * Clicked new Form
1250
     */
1221
     */
1251
    $('button.btn-add-form').click(function(e) {
1222
    $('button.btn-add-form').click(function(e) {
Línea 1517... Línea 1488...
1517
                            <label for="question-type">LABEL_TYPE</label>
1488
                            <label for="question-type">LABEL_TYPE</label>
1518
                            <select name="question-type" id="question-type" class="form-control">
1489
                            <select name="question-type" id="question-type" class="form-control">
1519
                                <option value="open">LABEL_OPEN</option>
1490
                                <option value="open">LABEL_OPEN</option>
1520
                                <option value="simple">Simple</option>
1491
                                <option value="simple">Simple</option>
1521
                                <option value="multiple">Multiple</option>
1492
                                <option value="multiple">Multiple</option>
1522
                                <option value="rating-open">LABEL_RATING_OPEN</option>
-
 
1523
                                <option value="rating-range">LABEL_RATING_RANGE</option>
-
 
1524
                            </select>
1493
                            </select>
1525
                        </div>
1494
                        </div>
1526
                        <div class="form-group">
1495
                        <div class="form-group">
1527
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
1496
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
1528
                            <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
1497
                            <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
Línea 1532... Línea 1501...
1532
                            <select name="question-multiline" id="question-multiline" class="form-control">
1501
                            <select name="question-multiline" id="question-multiline" class="form-control">
1533
                                <option value="1">LABEL_YES</option>
1502
                                <option value="1">LABEL_YES</option>
1534
                                <option value="0">LABEL_NOT</option>
1503
                                <option value="0">LABEL_NOT</option>
1535
                            </select>
1504
                            </select>
1536
                        </div>
1505
                        </div>
1537
                        <div class="form-group">
-
 
1538
                            <label for="question-range">LABEL_RANGE</label>
-
 
1539
                            <select name="question-range" id="question-range" class="form-control">
-
 
1540
                                <option value="10">1-10</option>
-
 
1541
                                <option value="6">1-6</option>
-
 
1542
                                <option value="5">1-5</option>
-
 
1543
                            </select>
-
 
1544
                        </div>
-
 
1545
                    </div>
1506
                    </div>
1546
                    <div class="modal-footer">
1507
                    <div class="modal-footer">
1547
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1508
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1548
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1509
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1549
                    </div>
1510
                    </div>
Línea 1630... Línea 1591...
1630
                                </td>
1591
                                </td>
1631
                                <td class="text-capitalize">
1592
                                <td class="text-capitalize">
1632
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1593
                                    {{if type == 'open'}} LABEL_OPEN {{/if}}
1633
                                    {{if type == 'simple'}} Simple {{/if}}
1594
                                    {{if type == 'simple'}} Simple {{/if}}
1634
                                    {{if type == 'multiple'}} Multiple {{/if}}
1595
                                    {{if type == 'multiple'}} Multiple {{/if}}
1635
                                    {{if type == 'rating-open'}} LABEL_RATING_OPEN {{/if}}
-
 
1636
                                    {{if type == 'rating-range'}} LABEL_RATING_RANGE {{/if}}
-
 
1637
                                </td>
1596
                                </td>
1638
                                <td>
1597
                                <td>
1639
                                    <button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>
1598
                                    <button class="btn btn-default btn-edit-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_EDIT LABEL_QUESTION"><i class="fa fa-edit" aria-hidden="true"></i> LABEL_EDIT LABEL_QUESTION</button>
1640
                                    <button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>
1599
                                    <button class="btn btn-default btn-delete-question" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_DELETE LABEL_QUESTION"><i class="fa fa-ban" aria-hidden="true"></i> LABEL_DELETE LABEL_QUESTION</button>
Línea 1641... Línea 1600...
1641
                                 
1600
                                 
1642
                                    {{if type == 'simple' || type == 'rating-open' || type=='multiple' }}
1601
                                    {{if type == 'simple' || type=='multiple' }}
1643
                                    <button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION</button>
1602
                                    <button class="btn btn-default btn-add-option" data-section="{{:slug_section}}" data-question="{{:slug_question}}" data-toggle="tooltip"  data-original-title="LABEL_ADD  LABEL_OPTION"><i class="fa fa-plus" aria-hidden="true"></i> LABEL_ADD  LABEL_OPTION</button>
Línea 1644... Línea 1603...
1644
                                    {{/if}}
1603
                                    {{/if}}
1645
                               
1604