Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 6321 Rev 6467
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') {
89
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
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') {
131
                    if (this.sections[i].questions[j].type == 'simple' || this.sections[i].questions[j].type == 'multiple' || this.sections[i].questions[j].type == 'rating-open') {
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) {
208
        this.addQuestion = function(slug_section, text, type, maxlength, multiline, range) {
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,
229
                        'options': [],
230
                        'options': [],
230
                        'answer': type=='multiple' ? [] : ''
231
                        'answer': type=='multiple' ? [] : ''
231
                    }
232
                    }
232
                    this.sections[i].questions.push(question);
233
                    this.sections[i].questions.push(question);
233
                    renderTable = true;
234
                    renderTable = true;
Línea 239... Línea 240...
239
            }
240
            }
240
        },
241
        },
241
         /**
242
         /**
242
         * Add element to question array
243
         * Add element to question array
243
         */
244
         */
244
        this.editQuestion = function(slug_section, slug_question, text, type, maxlength, multiline) {
245
        this.editQuestion = function(slug_section, slug_question, text, type, maxlength, multiline, range) {
245
            var renderTable = false;
246
            var renderTable = false;
246
            for (i = 0; i < this.sections.length; i++) {
247
            for (i = 0; i < this.sections.length; i++) {
247
                if (slug_section == this.sections[i].slug_section) {
248
                if (slug_section == this.sections[i].slug_section) {
248
                    for (j = 0; j < this.sections[i].questions.length; j++) {
249
                    for (j = 0; j < this.sections[i].questions.length; j++) {
249
                        if (slug_question == this.sections[i].questions[j].slug_question) {
250
                        if (slug_question == this.sections[i].questions[j].slug_question) {
Línea 255... Línea 256...
255
                                this.sections[i].questions[j].options = [];
256
                                this.sections[i].questions[j].options = [];
256
                            } else {
257
                            } else {
257
                                this.sections[i].questions[j].maxlength = 0;
258
                                this.sections[i].questions[j].maxlength = 0;
258
                                this.sections[i].questions[j].multiline = 0;
259
                                this.sections[i].questions[j].multiline = 0;
259
                            }
260
                            }
-
 
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 260... Línea 266...
260
 
266
 
261
                            if(type=='multiple'){
267
                            if(type=='multiple'){
262
                                this.sections[i].questions[j].answer = [];  
268
                                this.sections[i].questions[j].answer = [];  
263
                            }else{
269
                            }else{
Línea 700... Línea 706...
700
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
706
                        $.fn.showError('ERROR_QUESTIONS'.replace('%s', objFormGenerator.sections[i].name));
701
                        return false;
707
                        return false;
702
                    }
708
                    }
703
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
709
                    for (j = 0; j < objFormGenerator.sections[i].questions.length; j++) {
704
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
710
                        if (objFormGenerator.sections[i].questions[j].type == 'simple' ||
705
                            objFormGenerator.sections[i].questions[j].type == 'multiple') {
711
                            objFormGenerator.sections[i].questions[j].type == 'multiple' ||
-
 
712
                            objFormGenerator.sections[i].questions[j].type == 'rating-open') {
706
                            var questionNumber = j + 1;
713
                            var questionNumber = j + 1;
707
                            var numberCorrect = 0;
714
                            var numberCorrect = 0;
708
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
715
                            if (objFormGenerator.sections[i].questions[j].options.length == 0) {
709
                                $.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));
710
                                return false;
717
                                return false;
Línea 845... Línea 852...
845
            'question-max-length': {
852
            'question-max-length': {
846
                required: true,
853
                required: true,
847
                digits: true,
854
                digits: true,
848
                min: 0
855
                min: 0
849
            },
856
            },
-
 
857
            'question-range': {
-
 
858
                required: true,
-
 
859
                number: true,
-
 
860
                min: 1
-
 
861
            },
850
        },
862
        },
851
        highlight: function(element) {
863
        highlight: function(element) {
852
            $(element).closest('.form-group').addClass('has-error');
864
            $(element).closest('.form-group').addClass('has-error');
853
        },
865
        },
854
        unhighlight: function(element) {
866
        unhighlight: function(element) {
Línea 874... Línea 886...
874
                    $('#form-question #question-section').val(),
886
                    $('#form-question #question-section').val(),
875
                    $('#form-question #question-slug').val(),
887
                    $('#form-question #question-slug').val(),
876
                    $('#form-question #question-text').val(),
888
                    $('#form-question #question-text').val(),
877
                    $('#form-question #question-type').val(),
889
                    $('#form-question #question-type').val(),
878
                    $('#form-question #question-max-length').val(),
890
                    $('#form-question #question-max-length').val(),
879
                    $('#form-question #question-multiline').val()
891
                    $('#form-question #question-multiline').val(),
-
 
892
                    $('#form-question #question-range').val()
880
                );
893
                );
881
            } else {
894
            } else {
882
                objFormGenerator.addQuestion(
895
                objFormGenerator.addQuestion(
883
                    $('#form-question #question-section').val(),
896
                    $('#form-question #question-section').val(),
884
                    $('#form-question #question-text').val(),
897
                    $('#form-question #question-text').val(),
885
                    $('#form-question #question-type').val(),
898
                    $('#form-question #question-type').val(),
886
                    $('#form-question #question-max-length').val(),
899
                    $('#form-question #question-max-length').val(),
887
                    $('#form-question #question-multiline').val()
900
                    $('#form-question #question-multiline').val(),
-
 
901
                    $('#form-question #question-range').val()
888
                );
902
                );
889
            }
903
            }
890
            renderSectionData(objFormGenerator.sections);
904
            renderSectionData(objFormGenerator.sections);
891
            $('#modal-question').modal('hide');
905
            $('#modal-question').modal('hide');
892
            return false;
906
            return false;
Línea 1025... Línea 1039...
1025
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
1039
        $('#form-question #question-type').val($('#form-question #question-type option:first').val());
1026
        $('#form-question #question-max-length').val('0');
1040
        $('#form-question #question-max-length').val('0');
1027
        $('#form-question #question-max-length').parent().show();
1041
        $('#form-question #question-max-length').parent().show();
1028
        $('#form-question #question-multiline').val('0');
1042
        $('#form-question #question-multiline').val('0');
1029
        $('#form-question #question-multiline').parent().show();
1043
        $('#form-question #question-multiline').parent().show();
-
 
1044
        $('#form-question #question-range').val('10');
-
 
1045
        $('#form-question #question-range').parent().hide();
1030
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
1046
        $('#modal-question h4[class="modal-title"]').html('LABEL_ADD LABEL_QUESTION');
1031
        $('#modal-question').modal('show');
1047
        $('#modal-question').modal('show');
1032
    });
1048
    });
1033
    /**
1049
    /**
1034
     * Clicked edit question
1050
     * Clicked edit question
Línea 1056... Línea 1072...
1056
                            $('#form-question #question-max-length').val('0');
1072
                            $('#form-question #question-max-length').val('0');
1057
                            $('#form-question #question-max-length').parent().hide();
1073
                            $('#form-question #question-max-length').parent().hide();
1058
                            $('#form-question #question-multiline').val('0');
1074
                            $('#form-question #question-multiline').val('0');
1059
                            $('#form-question #question-multiline').parent().hide();
1075
                            $('#form-question #question-multiline').parent().hide();
1060
                        }
1076
                        }
-
 
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
                        }
1061
                        showForm = true;
1084
                        showForm = true;
1062
                        break;
1085
                        break;
1063
                    }
1086
                    }
1064
                }
1087
                }
1065
                break;
1088
                break;
Línea 1213... Línea 1236...
1213
            $('#form-question #question-max-length').val('0');
1236
            $('#form-question #question-max-length').val('0');
1214
            $('#form-question #question-max-length').parent().hide();
1237
            $('#form-question #question-max-length').parent().hide();
1215
            $('#form-question #question-multiline').val('0');
1238
            $('#form-question #question-multiline').val('0');
1216
            $('#form-question #question-multiline').parent().hide();
1239
            $('#form-question #question-multiline').parent().hide();
1217
        }
1240
        }
-
 
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
        }
1218
    });
1247
    });
1219
    /**
1248
    /**
1220
     * Clicked new Form
1249
     * Clicked new Form
1221
     */
1250
     */
1222
    $('button.btn-add-form').click(function(e) {
1251
    $('button.btn-add-form').click(function(e) {
Línea 1488... Línea 1517...
1488
                            <label for="question-type">LABEL_TYPE</label>
1517
                            <label for="question-type">LABEL_TYPE</label>
1489
                            <select name="question-type" id="question-type" class="form-control">
1518
                            <select name="question-type" id="question-type" class="form-control">
1490
                                <option value="open">LABEL_OPEN</option>
1519
                                <option value="open">LABEL_OPEN</option>
1491
                                <option value="simple">Simple</option>
1520
                                <option value="simple">Simple</option>
1492
                                <option value="multiple">Multiple</option>
1521
                                <option value="multiple">Multiple</option>
-
 
1522
                                
1493
                            </select>
1523
                            </select>
1494
                        </div>
1524
                        </div>
1495
                        <div class="form-group">
1525
                        <div class="form-group">
1496
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
1526
                            <label for="question-max-length">LABEL_MAXLENGTH</label>
1497
                            <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
1527
                            <input type="text" name="question-max-length" id="question-max-length"  class="form-control" />
Línea 1501... Línea 1531...
1501
                            <select name="question-multiline" id="question-multiline" class="form-control">
1531
                            <select name="question-multiline" id="question-multiline" class="form-control">
1502
                                <option value="1">LABEL_YES</option>
1532
                                <option value="1">LABEL_YES</option>
1503
                                <option value="0">LABEL_NOT</option>
1533
                                <option value="0">LABEL_NOT</option>
1504
                            </select>
1534
                            </select>
1505
                        </div>
1535
                        </div>
-
 
1536
                        <div class="form-group">
-
 
1537
                            <label for="question-range">LABEL_RANGE</label>
-
 
1538
                            <select name="question-range" id="question-range" class="form-control">
-
 
1539
                                <option value="10">1-10</option>
-
 
1540
                                <option value="6">1-6</option>
-
 
1541
                                <option value="5">1-5</option>
-
 
1542
                            </select>
-
 
1543
                        </div>
1506
                    </div>
1544
                    </div>
1507
                    <div class="modal-footer">
1545
                    <div class="modal-footer">
1508
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1546
                        <button type="submit" class="btn btn-primary">LABEL_SAVE</button>
1509
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1547
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">LABEL_CLOSE</button>
1510
                    </div>
1548
                    </div>
Línea 1596... Línea 1634...
1596
                                </td>
1634
                                </td>
1597
                                <td>
1635
                                <td>
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>
1636
                                    <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>
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>
1637
                                    <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 1600... Línea 1638...
1600
                                 
1638
                                 
1601
                                    {{if type == 'simple' || type=='multiple' }}
1639
                                    {{if type == 'simple' || type == 'rating-open' || type=='multiple' }}
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>
1640
                                    <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 1603... Línea 1641...
1603
                                    {{/if}}
1641
                                    {{/if}}
1604
                               
1642