Search in sources :

Example 1 with HttpItemInput

use of org.olat.ims.qti.container.HttpItemInput in project OpenOLAT by OpenOLAT.

the class CourseAssessmentWebService method convertToHttpItemInput.

private Map<String, ItemInput> convertToHttpItemInput(Map<Long, String> results) {
    Map<String, ItemInput> datas = new HashMap<String, ItemInput>();
    for (Long key : results.keySet()) {
        HttpItemInput iip = new HttpItemInput(results.get(key));
        iip.putSingle(key.toString(), results.get(key));
        // TODO somehow obtain answer from value
        datas.put(iip.getIdent(), iip);
    }
    return datas;
}
Also used : HashMap(java.util.HashMap) HttpItemInput(org.olat.ims.qti.container.HttpItemInput) HttpItemInput(org.olat.ims.qti.container.HttpItemInput) ItemInput(org.olat.ims.qti.container.ItemInput)

Example 2 with HttpItemInput

use of org.olat.ims.qti.container.HttpItemInput in project OpenOLAT by OpenOLAT.

the class IQManager method getItemsInput.

/**
 * Extract item inputs from http request
 *
 * @param ureq The request to extract item responses from.
 * @return ItemsInput
 */
public ItemsInput getItemsInput(UserRequest ureq) {
    ItemsInput result = new ItemsInput();
    Enumeration<String> params = ureq.getHttpReq().getParameterNames();
    while (params.hasMoreElements()) {
        String paramKey = params.nextElement();
        StringTokenizer st = new StringTokenizer(paramKey, "§", false);
        String value = ureq.getParameter(paramKey);
        if (st.countTokens() == 4) {
            String itemType = st.nextToken();
            String itemIdent = st.nextToken();
            String responseID = st.nextToken();
            HttpItemInput itemInput = (HttpItemInput) result.getItemInput(itemIdent);
            if (itemInput == null) {
                itemInput = new HttpItemInput(itemIdent);
                result.addItemInput(itemInput);
            }
            // all items. it does not provide any response data
            if (itemType.equals("qti"))
                itemInput.putSingle(responseID, value);
        }
    // refactoring to new setFormDirty() javascript method sends now an additional param "olat_fosm" which has no tokens inside
    // so assertExc. is useless.
    // else {
    // throw new AssertException ("not 4 tokens in form name: orig='"+paramKey+"'");
    // }
    // <input id="QTI_1098869464495" type="checkbox"
    // name="qti§QTIEDIT:MCQ:1098869464490§1098869464492§1098869464495" ....
    }
    return result;
}
Also used : StringTokenizer(java.util.StringTokenizer) HttpItemInput(org.olat.ims.qti.container.HttpItemInput) ItemsInput(org.olat.ims.qti.container.ItemsInput)

Example 3 with HttpItemInput

use of org.olat.ims.qti.container.HttpItemInput in project openolat by klemens.

the class IQManager method getItemsInput.

/**
 * Extract item inputs from http request
 *
 * @param ureq The request to extract item responses from.
 * @return ItemsInput
 */
public ItemsInput getItemsInput(UserRequest ureq) {
    ItemsInput result = new ItemsInput();
    Enumeration<String> params = ureq.getHttpReq().getParameterNames();
    while (params.hasMoreElements()) {
        String paramKey = params.nextElement();
        StringTokenizer st = new StringTokenizer(paramKey, "§", false);
        String value = ureq.getParameter(paramKey);
        if (st.countTokens() == 4) {
            String itemType = st.nextToken();
            String itemIdent = st.nextToken();
            String responseID = st.nextToken();
            HttpItemInput itemInput = (HttpItemInput) result.getItemInput(itemIdent);
            if (itemInput == null) {
                itemInput = new HttpItemInput(itemIdent);
                result.addItemInput(itemInput);
            }
            // all items. it does not provide any response data
            if (itemType.equals("qti"))
                itemInput.putSingle(responseID, value);
        }
    // refactoring to new setFormDirty() javascript method sends now an additional param "olat_fosm" which has no tokens inside
    // so assertExc. is useless.
    // else {
    // throw new AssertException ("not 4 tokens in form name: orig='"+paramKey+"'");
    // }
    // <input id="QTI_1098869464495" type="checkbox"
    // name="qti§QTIEDIT:MCQ:1098869464490§1098869464492§1098869464495" ....
    }
    return result;
}
Also used : StringTokenizer(java.util.StringTokenizer) HttpItemInput(org.olat.ims.qti.container.HttpItemInput) ItemsInput(org.olat.ims.qti.container.ItemsInput)

Example 4 with HttpItemInput

use of org.olat.ims.qti.container.HttpItemInput in project openolat by klemens.

the class CourseAssessmentWebService method convertToHttpItemInput.

private Map<String, ItemInput> convertToHttpItemInput(Map<Long, String> results) {
    Map<String, ItemInput> datas = new HashMap<String, ItemInput>();
    for (Long key : results.keySet()) {
        HttpItemInput iip = new HttpItemInput(results.get(key));
        iip.putSingle(key.toString(), results.get(key));
        // TODO somehow obtain answer from value
        datas.put(iip.getIdent(), iip);
    }
    return datas;
}
Also used : HashMap(java.util.HashMap) HttpItemInput(org.olat.ims.qti.container.HttpItemInput) HttpItemInput(org.olat.ims.qti.container.HttpItemInput) ItemInput(org.olat.ims.qti.container.ItemInput)

Aggregations

HttpItemInput (org.olat.ims.qti.container.HttpItemInput)4 HashMap (java.util.HashMap)2 StringTokenizer (java.util.StringTokenizer)2 ItemInput (org.olat.ims.qti.container.ItemInput)2 ItemsInput (org.olat.ims.qti.container.ItemsInput)2