본문 바로가기

대외활동/TNS Internship

100129 TNS Korea Internship (34/53)

728x90

1. 

IncAny(qid, getPrecodeSet)

qid에 getPrecodeSet이라는 set에 들어있는 프리코드 중 하나라도 체크되었을 경우 true를
하나도 없을 경우 false를 돌려주는 함수.
각종 조건문에서 사용할 수 있겠다.
= IncAtLeast(qid, getPrecodeSet, 1)
IncAtLeast() 함수에서 세번째 인수를 1로 보낸다.


2.

function IncAtLeast(qid, getPrecodeSet, getNum)

18시 58분 현재. 원하는 결과가 나오지 않은다.
함수는 계속해서 true를 반환하고 있다.
다음주에 계속 이어서 해야 할 듯.

function IncAtLeast(qid, getPrecodeSet, getNum)
{

    var answerArr = new Array();
    var answerSet = new Set();
    var scaleArr = new Array();
    var scaleSet = new Set();
    var isTrue = new Boolean();

    var x = f(qid);
    isTrue = false;

    if (x.size() >= 1)
    {
        // Singles
        if (x.CODED)
        {// Response.Write("in Singles section");
             
            var answer = x.value(); // retrieve the selected precode
            answerArr[0] = answer; // add this precode to an array // populate the set from the array
            answerSet = ArrayToSet(answerArr);        // *** Check if the selected precode is in the getPrecodeSet  
            if (answerSet.isect(getPrecodeSet).size() >= getNum)
                isTrue = true;
        } // end if

        else if (x.COMPOUND)    // Multis and Grids
        {    // this retrieves an array of all the answered Answer precodes
            answerArr = x.categories();    // this retrieves an array of all the answered Scale precodes
            scaleArr = x.values();    // populate the appropriate set from each array
            answerSet = ArrayToSet(answerArr);
            scaleSet = ArrayToSet(scaleArr);    // repPrecode is the first precode in the array
            var repPrecode = answerArr[0].toString();    // y is the first question answered.    // It is used as a represenative to find out if question    // is a multi or a grid.
            var y = f(qid)[repPrecode];    // Multis
            if (y.DICHOTOMY)
            {    // Response.Write("in Multis section");    // *** Check at least getNum of the selected Answer precodes are in the getPrecodeSet  
                if (answerSet.isect(getPrecodeSet).size() >= getNum)
                    isTrue = true;
            } // end if
            // Grids
            else if (y.CODED)
            {
                // Response.Write("in Grids section");
                // *** Check at least getNum of the selected Scale precodes are in the getPrecodeSet 
                if (scaleSet.isect(getPrecodeSet).size() >= getNum)
                    isTrue = true;
            } // end else if
        } // end else if
    } // end if
    return isTrue;
} // end function


728x90