Skip to content

Commit

Permalink
Fixed issue #9449: Label set updates clear out existing assessment va…
Browse files Browse the repository at this point in the history
…lues
  • Loading branch information
c-schmitz committed May 8, 2015
1 parent 1aa0810 commit a3f7412
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
2 changes: 2 additions & 0 deletions application/controllers/admin/labels.php
Expand Up @@ -385,6 +385,7 @@ public function ajaxSets()
$lid = Yii::app()->getRequest()->getPost('lid');
$answers = Yii::app()->getRequest()->getPost('answers');
$code = Yii::app()->getRequest()->getPost('code');
$aAssessmentValues = Yii::app()->getRequest()->getPost('assessmentvalues',array());
//Create new label set
$language = "";
foreach ($answers as $lang => $answer) {
Expand Down Expand Up @@ -414,6 +415,7 @@ public function ajaxSets()
$label->title = $ans;
$label->sortorder = $key;
$label->language = $lang;
$label->assessment_value = isset($aAssessmentValues[$key])?$aAssessmentValues[$key]:0;
if(!$label->save())
$res = 'fail';
}
Expand Down
1 change: 0 additions & 1 deletion application/controllers/admin/participantsaction.php
Expand Up @@ -763,7 +763,6 @@ function getParticipantsResults_json()
*/
function getParticipants_json($search = null)
{
// debugbreak();
$page = (int) Yii::app()->request->getPost('page');
$limit = (int) Yii::app()->request->getPost('rows');
$limit = empty($limit) ? 50:$limit; //Stop division by zero errors
Expand Down
Expand Up @@ -198,7 +198,7 @@ class="highlight"
</p>
</div>
<div id="dialog-confirm-replace" title="<?php $clang->eT('Replace label set?'); ?>" style='display:none;'>
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php $clang->eT('You are about to replace a given label set with the labels of this subquestions. Continue?'); ?></p>
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php $clang->eT("You are about to replace an existing label set with the labels of this subquestions. If the existing labels had assessment values set these will be lost!"); ?><br><?php $clang->eT("Do you want to continue?");?></p>
</div>

<div id="dialog-duplicate" title="<?php $clang->eT('Duplicate label set name'); ?>" style='display:none;'>
Expand Down
30 changes: 20 additions & 10 deletions scripts/admin/answers.js
Expand Up @@ -427,18 +427,20 @@ function lspreview()
if (lsrows[z].title==null) {
lsrows[z].title='';
}
tabbody=tabbody+'><td>'+lsrows[z].code+'</td>';
if (assessmentvisible)
tabbody=tabbody+'><td>'+lsrows[z].code+'</td><td';
if (!assessmentvisible)
{
tabbody=tabbody+'<td>'+lsrows[z].assessment_value+'</td>';
}
tabbody=tabbody+' style="display:none;"';
}
tabbody=tabbody+'>'+lsrows[z].assessment_value+'</td>';
tabbody=tabbody+'<td>'+htmlspecialchars(lsrows[z].title)+'</td></tr><tbody>';
}
tabbody=tabbody+'<thead><tr><th>'+strcode+'</th>';
if (assessmentvisible)
tabbody=tabbody+'<thead><tr><th>'+strcode+'</th><th';
if (!assessmentvisible)
{
tabbody=tabbody+'<th>'+sAssessmentValue+'</th>';
}
tabbody=tabbody+' style="display:none;"';
}
tabbody=tabbody+'>'+sAssessmentValue+'</th>';
tabbody=tabbody+'<th>'+strlabel+'</th></tr></thead></table></div>';
}
}
Expand Down Expand Up @@ -739,7 +741,8 @@ function savelabel()
{
$('#dialog-confirm-replace').dialog({
resizable: false,
height: 160,
height: 200,
width:350,
modal: true,
buttons: [{
text: ok,
Expand Down Expand Up @@ -791,6 +794,13 @@ function ajaxreqsave() {
code.push($(this).val());
});

// get assessment values for the current scale
var assessmentvalues = new Array();
$('.assessment').each(function(index) {
if($(this).attr('id').substr(-1) === scale_id)
assessmentvalues.push($(this).val());
});

answers = new Object();
languages = langs.split(';');

Expand All @@ -804,7 +814,7 @@ function ajaxreqsave() {
}


$.post(lasaveurl, { laname: $('#laname').val(), lid: lid, code: code, answers: answers, }, function(data) {
$.post(lasaveurl, { laname: $('#laname').val(), lid: lid, code: code, answers: answers, assessmentvalues:assessmentvalues }, function(data) {
$("#saveaslabel").dialog('close');
if(jQuery.parseJSON(data) == "ok")
{
Expand Down
22 changes: 19 additions & 3 deletions scripts/admin/subquestions.js
@@ -1,4 +1,19 @@
// $Id: subquestions.js 9692 2011-01-15 21:31:10Z c_schmitz $
/*
* JavaScript functions for LimeSurvey administrator
*
* This file is part of LimeSurvey
* Copyright (C) 2007-2015 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GNU/GPL License v2 or later

var labelcache=[];
$(document).ready(function(){
removeCSRFDivs();
Expand Down Expand Up @@ -639,7 +654,8 @@ function savelabel()
{
$('#dialog-confirm-replace').dialog({
resizable: false,
height: 160,
height: 230,
width:350,
modal: true,
buttons: [{
text: ok,
Expand Down Expand Up @@ -718,7 +734,7 @@ function ajaxreqsave() {
{
$("#dialog-result").html(lasuccess);
$('#dialog-result').dialog({
height: 160,
height: 200,
width: 250,
buttons: [{
text: ok,
Expand Down

0 comments on commit a3f7412

Please sign in to comment.