|
@@ -334,7 +334,7 @@
|
334
|
334
|
</div>
|
335
|
335
|
<div class="modal-footer">
|
336
|
336
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
337
|
|
- <button type="button" class="btn btn-primary" id ="saveButton" value="Save" type="button" onclick = "saveTemplate()" >Save</button>
|
|
337
|
+ <button type="button" class="btn btn-primary" id ="saveButton" data-button-id = '' value="Save" type="button" onclick = "saveTemplate()" >Save</button>
|
338
|
338
|
|
339
|
339
|
</div>
|
340
|
340
|
</div><!-- /.modal-content -->
|
|
@@ -349,7 +349,108 @@
|
349
|
349
|
|
350
|
350
|
<!-- jQuery Sortable Tables -->
|
351
|
351
|
<script src="{{ asset('vendor/jQuerySortable/jquery-sortable-min.js') }}"></script>
|
|
352
|
+<script>
|
|
353
|
+function saveTemplate()
|
|
354
|
+{
|
|
355
|
+ //Prevent page refresh
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+ var criterionObject = new Object();
|
|
361
|
+ var criteriaArray = new Array();
|
|
362
|
+
|
|
363
|
+ var criteria = [];
|
|
364
|
+ var titles = [];
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+ var amount_of_scales =parseInt($('#number_of_scales').find(':selected').val())+2;
|
|
368
|
+ var max = parseInt($('#max_score').find(':selected').val());
|
|
369
|
+ // For each criterion in the rubric, get its value and put it into an array
|
|
370
|
+ $('tbody tr').each(function( index )
|
|
371
|
+ {
|
|
372
|
+ criteria.push($(this).data('criterion-id'));
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+ });
|
|
383
|
+
|
|
384
|
+ $('.editable').each(function(index){
|
|
385
|
+ titles.push($(this).text());
|
|
386
|
+ })
|
|
387
|
+
|
|
388
|
+ button_id = $("#saveButton").data('button-id');
|
|
389
|
+ //console.log('school', $('#select-school').find(':selected').data('school-id') );
|
|
390
|
+ //console.log('program', $('#select-program').find(':selected').data('program-id') );
|
|
391
|
+
|
|
392
|
+ if(button_id=='button-create-rubric')
|
|
393
|
+ {
|
|
394
|
+ // Create
|
|
395
|
+ $.post
|
|
396
|
+ (
|
|
397
|
+ "{{ URL::to('saveTemplate') }}",
|
|
398
|
+ {
|
|
399
|
+ name: $('#rubric-name').val(),
|
|
400
|
+
|
|
401
|
+ school_id: $('#select-school').find(':selected').data('school-id'),
|
|
402
|
+ program_id: $('#select-program').find(':selected').data('program-id'),
|
|
403
|
+ expected_percentage: $('#expected_percentage').find(':selected').val(),
|
|
404
|
+ expected_points: $('#expected_points').find(':selected').val(),
|
|
405
|
+ is_visible: $('input[name=is_visible]:checked').val(),
|
|
406
|
+ criteria : criteria,
|
|
407
|
+ //scales: scales,
|
|
408
|
+ max_score : max,
|
|
409
|
+ /*copyright : copyright,
|
|
410
|
+ notes :notes*/
|
|
411
|
+ titles: titles
|
|
412
|
+
|
|
413
|
+ },
|
|
414
|
+ function(data)
|
|
415
|
+ {
|
|
416
|
+ location.reload(true);
|
|
417
|
+ }
|
|
418
|
+ );
|
|
419
|
+ }
|
|
420
|
+ else
|
|
421
|
+ {
|
|
422
|
+ console.log('school', $('#select-school').find(':selected').data('school-id') );
|
|
423
|
+ console.log('program', $('#select-program').find(':selected').data('program-id') );
|
|
424
|
+
|
|
425
|
+ // Update database
|
|
426
|
+ $.post
|
|
427
|
+ (
|
|
428
|
+ "{{ URL::to('updateTemplate') }}",
|
|
429
|
+ {
|
|
430
|
+ id: $('#select-template').find(':selected').data('template-id'),
|
|
431
|
+ name: $('#rubric-name').val(),
|
|
432
|
+
|
|
433
|
+ school_id: $('#select-school').find(':selected').data('school-id'),
|
|
434
|
+ program_id: $('#select-program').find(':selected').data('program-id'),
|
|
435
|
+ expected_percentage: $('#expected_percentage').find(':selected').val(),
|
|
436
|
+ expected_points: $('#expected_points').find(':selected').val(),
|
|
437
|
+ is_visible: $('input[name=is_visible]:checked').val(),
|
|
438
|
+ criteria : criteria,
|
|
439
|
+ //scales: scales,
|
|
440
|
+ max_score : max,
|
|
441
|
+ /*copyright : copyright,
|
|
442
|
+ notes :notes*/
|
|
443
|
+ titles: titles
|
|
444
|
+ },
|
|
445
|
+ function(data)
|
|
446
|
+ {
|
|
447
|
+ location.reload(true);
|
|
448
|
+ }
|
|
449
|
+ );
|
|
450
|
+ }
|
352
|
451
|
|
|
452
|
+}
|
|
453
|
+ </script>
|
353
|
454
|
<!-- X-Editable js -->
|
354
|
455
|
<script src="{{ asset('vendor/xeditable/bootstrap-editable.min.js') }}"></script>
|
355
|
456
|
|
|
@@ -494,7 +595,7 @@ function addCriterion()
|
494
|
595
|
if(data.criterion.notes){
|
495
|
596
|
notes = data.criterion.notes;
|
496
|
597
|
}
|
497
|
|
-
|
|
598
|
+ objectives = JSON.stringify(objectives);
|
498
|
599
|
|
499
|
600
|
var str ='<tr data-criterion-name ="'+data.criterion.name+'" data-program-ids = "['+program_ids+']" data-assoc-objectives = '+"'"+objectives+"'"+' data-criterion-id="'+data.criterion.id+'" data-criterion-copyright="'+copyright+'" data-criterion-notes="'+notes+'" data-outcomes = "'+data.outcomes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
|
500
|
601
|
|
|
@@ -810,7 +911,9 @@ function loadTemplate()
|
810
|
911
|
var temp_criterion = data.criterion;
|
811
|
912
|
for(temp_c in temp_criterion){
|
812
|
913
|
current_criterion = temp_criterion[temp_c]
|
813
|
|
- var str = '<tr data-criterion-name = "'+current_criterion.name+'" data-criterion-id="'+temp_criterion[temp_c].criterion_id+'" data-criterion-copyright="'+temp_criterion[temp_c].copyright+'" data-criterion-notes="'+temp_criterion[temp_c].notes+'" data-outcomes = "'+temp_criterion[temp_c].outcomes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
|
|
914
|
+ objectives = JSON.stringify(current_criterion.objectives);
|
|
915
|
+
|
|
916
|
+ var str = '<tr data-assoc-objectives= '+"'"+objectives+"'"+' data-program_ids = "'+current_criterion.program_ids+'" data-criterion-name = "'+current_criterion.name+'" data-criterion-id="'+temp_criterion[temp_c].criterion_id+'" data-criterion-copyright="'+temp_criterion[temp_c].copyright+'" data-criterion-notes="'+temp_criterion[temp_c].notes+'" data-outcomes = "'+temp_criterion[temp_c].outcomes+'"><th><span class="glyphicon glyphicon-move"></span></th><td>';
|
814
|
917
|
|
815
|
918
|
var subcriteria ='';
|
816
|
919
|
if(current_criterion.subcriteria){
|
|
@@ -969,6 +1072,7 @@ function loadTemplate()
|
969
|
1072
|
);
|
970
|
1073
|
}
|
971
|
1074
|
|
|
1075
|
+
|
972
|
1076
|
// Checks whether the user wants to save a rubric with a name that already exists
|
973
|
1077
|
function nameExists()
|
974
|
1078
|
{
|
|
@@ -1198,106 +1302,7 @@ $('#button-add-criterion').on('click', function(e)
|
1198
|
1302
|
//Add new criterion
|
1199
|
1303
|
addCriterion();
|
1200
|
1304
|
});
|
1201
|
|
-function saveTemplate(button_id)
|
1202
|
|
-{
|
1203
|
|
- //Prevent page refresh
|
1204
|
|
-
|
1205
|
|
-
|
1206
|
|
-
|
1207
|
|
-
|
1208
|
|
- var criterionObject = new Object();
|
1209
|
|
- var criteriaArray = new Array();
|
1210
|
|
-
|
1211
|
|
- var criteria = [];
|
1212
|
|
- var titles = [];
|
1213
|
|
-
|
1214
|
|
-
|
1215
|
|
- var amount_of_scales =parseInt($('#number_of_scales').find(':selected').val())+2;
|
1216
|
|
- var max = parseInt($('#max_score').find(':selected').val());
|
1217
|
|
- // For each criterion in the rubric, get its value and put it into an array
|
1218
|
|
- $('tbody tr').each(function( index )
|
1219
|
|
- {
|
1220
|
|
- criteria.push($(this).data('criterion-id'));
|
1221
|
|
-
|
1222
|
|
-
|
1223
|
|
-
|
1224
|
|
-
|
1225
|
|
-
|
1226
|
|
-
|
1227
|
|
-
|
1228
|
|
-
|
1229
|
|
-
|
1230
|
|
- });
|
1231
|
|
-
|
1232
|
|
- $('.editable').each(function(index){
|
1233
|
|
- titles.push($(this).text());
|
1234
|
|
- })
|
1235
|
|
-
|
1236
|
|
-
|
1237
|
|
- //console.log('school', $('#select-school').find(':selected').data('school-id') );
|
1238
|
|
- //console.log('program', $('#select-program').find(':selected').data('program-id') );
|
1239
|
|
-
|
1240
|
|
- if($(this).attr('id')=='button-create-rubric')
|
1241
|
|
- {
|
1242
|
|
- // Create
|
1243
|
|
- $.post
|
1244
|
|
- (
|
1245
|
|
- "{{ URL::to('saveTemplate') }}",
|
1246
|
|
- {
|
1247
|
|
- name: $('#rubric-name').val(),
|
1248
|
|
-
|
1249
|
|
- school_id: $('#select-school').find(':selected').data('school-id'),
|
1250
|
|
- program_id: $('#select-program').find(':selected').data('program-id'),
|
1251
|
|
- expected_percentage: $('#expected_percentage').find(':selected').val(),
|
1252
|
|
- expected_points: $('#expected_points').find(':selected').val(),
|
1253
|
|
- is_visible: $('input[name=is_visible]:checked').val(),
|
1254
|
|
- criteria : criteria,
|
1255
|
|
- //scales: scales,
|
1256
|
|
- max_score : max,
|
1257
|
|
- /*copyright : copyright,
|
1258
|
|
- notes :notes*/
|
1259
|
|
- titles: titles
|
1260
|
|
-
|
1261
|
|
- },
|
1262
|
|
- function(data)
|
1263
|
|
- {
|
1264
|
|
- location.reload(true);
|
1265
|
|
- }
|
1266
|
|
- );
|
1267
|
|
- }
|
1268
|
|
- else
|
1269
|
|
- {
|
1270
|
|
- console.log('school', $('#select-school').find(':selected').data('school-id') );
|
1271
|
|
- console.log('program', $('#select-program').find(':selected').data('program-id') );
|
1272
|
|
-
|
1273
|
|
- // Update database
|
1274
|
|
- $.post
|
1275
|
|
- (
|
1276
|
|
- "{{ URL::to('updateTemplate') }}",
|
1277
|
|
- {
|
1278
|
|
- id: $('#select-template').find(':selected').data('template-id'),
|
1279
|
|
- name: $('#rubric-name').val(),
|
1280
|
|
-
|
1281
|
|
- school_id: $('#select-school').find(':selected').data('school-id'),
|
1282
|
|
- program_id: $('#select-program').find(':selected').data('program-id'),
|
1283
|
|
- expected_percentage: $('#expected_percentage').find(':selected').val(),
|
1284
|
|
- expected_points: $('#expected_points').find(':selected').val(),
|
1285
|
|
- is_visible: $('input[name=is_visible]:checked').val(),
|
1286
|
|
- criteria : criteria,
|
1287
|
|
- //scales: scales,
|
1288
|
|
- max_score : max,
|
1289
|
|
- /*copyright : copyright,
|
1290
|
|
- notes :notes*/
|
1291
|
|
- titles: titles
|
1292
|
|
- },
|
1293
|
|
- function(data)
|
1294
|
|
- {
|
1295
|
|
- location.reload(true);
|
1296
|
|
- }
|
1297
|
|
- );
|
1298
|
|
- }
|
1299
|
1305
|
|
1300
|
|
-}
|
1301
|
1306
|
// When the create or update buttons are clicked (.save)
|
1302
|
1307
|
$('.save').on('click', function(e)
|
1303
|
1308
|
{
|
|
@@ -1346,7 +1351,7 @@ $('.save').on('click', function(e)
|
1346
|
1351
|
$('tbody tr').each(function( index )
|
1347
|
1352
|
{
|
1348
|
1353
|
objectives = $(this).data('assoc-objectives');
|
1349
|
|
- objectives = objectives.split(',');
|
|
1354
|
+
|
1350
|
1355
|
htmlString += "<li>" +$(this).data('criterion-name');
|
1351
|
1356
|
htmlString += "<br><h5>This criterion is associated with these objectives</h5>"
|
1352
|
1357
|
htmlString +="<ul style='padding-left: 5%; list-style-position: inside'>"
|
|
@@ -1404,7 +1409,7 @@ $('.save').on('click', function(e)
|
1404
|
1409
|
}
|
1405
|
1410
|
|
1406
|
1411
|
$('#rubric-modal').modal('toggle');
|
1407
|
|
- $('#saveButton').attr('onclick','saveTemplate("'+$(this).attr('id')+'")')
|
|
1412
|
+ $('#saveButton').data('button-id',$(this).attr('id'));
|
1408
|
1413
|
|
1409
|
1414
|
|
1410
|
1415
|
});
|