Search in sources :

Example 1 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class AssessmentTreeComponentRenderer method renderAssessmentItemMark.

private void renderAssessmentItemMark(StringOutput sb, AssessmentTreeComponent component, TestPlanNode itemNode, Translator translator) {
    String key = itemNode.getKey().toString();
    Form form = component.getQtiItem().getRootForm();
    String dispatchId = component.getQtiItem().getFormDispatchId();
    boolean mark = component.getCandidateSessionContext().isMarked(key);
    sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRFnCallFor(form, dispatchId, 1, true, true, new NameValuePair("cid", Event.mark.name()), new NameValuePair("item", key))).append("; o_toggleMark(this); return false;\" class='o_assessmentitem_marks'><i class='o_icon ").append("o_icon_bookmark", "o_icon_bookmark_add", mark).append("' title='").append(StringHelper.escapeHtml(translator.translate("assessment.item.mark"))).append("'>&nbsp;</i></a>");
}
Also used : NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 2 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class SelectSectionsCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
    if (cellValue instanceof SharedItemRow) {
        SharedItemRow itemRow = (SharedItemRow) cellValue;
        List<AssessedBinderSection> sections = itemRow.getSections();
        if (sections != null && sections.size() > 0) {
            FlexiTableElementImpl ftE = source.getFlexiTableElement();
            String id = source.getFormDispatchId();
            Form rootForm = ftE.getRootForm();
            boolean expand = itemRow.isExpandSections();
            for (int i = 0; i < sections.size(); i++) {
                if (i > 0) {
                    if (expand)
                        target.append("<br />");
                    else
                        target.append(" | ");
                }
                NameValuePair pair1 = new NameValuePair("select-section", Integer.toString(row));
                NameValuePair pair2 = new NameValuePair("section", Integer.toString(i));
                String jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, true, true, pair1, pair2);
                target.append("<a href=\"javascript:").append(jsCode).append(";\"").append(">");
                if (expand) {
                    target.append(StringHelper.escapeHtml(sections.get(i).getSectionTitle()));
                } else {
                    target.append(i + 1);
                }
                target.append("</a>");
            }
            NameValuePair pair = new NameValuePair("expand-section", Integer.toString(row));
            String jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, true, true, pair);
            target.append(" <a href=\"javascript:").append(jsCode).append(";\"").append(">");
            if (itemRow.isExpandSections()) {
                target.append("<i class='o_icon o_icon-sm o_icon_expand'> </i>");
            } else {
                target.append("<i class='o_icon o_icon-sm o_icon_compress'> </i>");
            }
            target.append("</a>");
        }
    }
}
Also used : SharedItemRow(org.olat.modules.portfolio.model.SharedItemRow) NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) AssessedBinderSection(org.olat.modules.portfolio.model.AssessedBinderSection) FlexiTableElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableElementImpl)

Example 3 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class UserInterestsElement method evalFormRequest.

@Override
public void evalFormRequest(UserRequest ureq) {
    Form form = getRootForm();
    String dispatchuri = form.getRequestParameter("dispatchuri");
    if (editLink != null && editLink.getFormDispatchId().equals(dispatchuri)) {
        doEdit(ureq);
    }
}
Also used : Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 4 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class SmsPhoneElement method evalFormRequest.

@Override
public void evalFormRequest(UserRequest ureq) {
    Form form = getRootForm();
    String dispatchuri = form.getRequestParameter("dispatchuri");
    if (editLink != null && editLink.getFormDispatchId().equals(dispatchuri)) {
        doEdit(ureq);
    } else if (removeLink != null && removeLink.getFormDispatchId().equals(dispatchuri)) {
        doRemove();
    }
}
Also used : Form(org.olat.core.gui.components.form.flexible.impl.Form)

Example 5 with Form

use of org.olat.core.gui.components.form.flexible.impl.Form in project OpenOLAT by OpenOLAT.

the class AssessmentTestComponentRenderer method renderSectionRubrics.

private void renderSectionRubrics(AssessmentRenderer renderer, StringOutput sb, AssessmentTestComponent component, TestPlanNode itemRefNode, URLBuilder ubu, Translator translator) {
    boolean writeRubrics = false;
    boolean writeTitles = false;
    List<AssessmentSection> sectionParentLine = new ArrayList<>();
    for (TestPlanNode parentNode = itemRefNode.getParent(); parentNode.getParent() != null; parentNode = parentNode.getParent()) {
        AssessmentSection selectedSection = component.getAssessmentSection(parentNode.getIdentifier());
        if (selectedSection != null && selectedSection.getVisible()) {
            sectionParentLine.add(selectedSection);
            if (selectedSection.getRubricBlocks().size() > 0) {
                for (RubricBlock rubric : selectedSection.getRubricBlocks()) {
                    if (rubric.getBlocks().size() > 0) {
                        writeRubrics = true;
                    }
                }
            }
            if (StringHelper.containsNonWhitespace(selectedSection.getTitle())) {
                writeTitles = true;
            }
        }
    }
    if (writeRubrics) {
        boolean show = true;
        for (int i = sectionParentLine.size(); i-- > 0; ) {
            AssessmentSection selectedSection = sectionParentLine.get(i);
            if (component.getCandidateSessionContext().isRubricHidden(selectedSection.getIdentifier())) {
                show = false;
            }
        }
        String key = sectionParentLine.get(0).getIdentifier().toString();
        Form form = component.getQtiItem().getRootForm();
        String dispatchId = component.getQtiItem().getFormDispatchId();
        sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRNFFnCallFor(form, dispatchId, 1, new NameValuePair("cid", Event.rubric.name()), new NameValuePair("section", key))).append("; return false;\" class='o_toogle_rubrics translated'><i class='o_icon o_icon-fw ");
        if (show) {
            sb.append("o_icon_close_togglebox'> </i> <span>").append(translator.translate("hide.rubric"));
        } else {
            sb.append("o_icon_open_togglebox'> </i> <span>").append(translator.translate("show.rubric"));
        }
        sb.append("</span></a>");
        sb.append("<div class='o_info o_assessmentsection_rubrics clearfix");
        if (show) {
            sb.append(" o_show");
        } else {
            sb.append(" o_hide");
        }
        sb.append("'>");
        // write the titles first
        if (writeTitles) {
            sb.append("<h4>");
            for (int i = 0; i < sectionParentLine.size(); i++) {
                if (i == 1) {
                    sb.append("<small>");
                } else if (i > 1) {
                    sb.append(" / ");
                }
                sb.append(sectionParentLine.get(i).getTitle());
            }
            if (sectionParentLine.size() > 1) {
                sb.append("</small>");
            }
            sb.append("</h4>");
        }
        for (int i = sectionParentLine.size(); i-- > 0; ) {
            AssessmentSection selectedSection = sectionParentLine.get(i);
            for (RubricBlock rubricBlock : selectedSection.getRubricBlocks()) {
                // @view (candidate)
                sb.append("<div class='rubric'>");
                rubricBlock.getBlocks().forEach(block -> renderBlock(renderer, sb, component, null, null, block, ubu, translator));
                sb.append("</div>");
            }
        }
        sb.append("<a href='javascript:;' onclick=\"").append(FormJSHelper.getXHRNFFnCallFor(form, dispatchId, 1, new NameValuePair("cid", Event.rubric.name()), new NameValuePair("section", key))).append("; return false;\" class='o_toogle_rubrics o_hide'><span>").append(translator.translate("hide.rubric.short")).append("</span></a>");
        // script to show/hide the rubrics with the translated linked
        sb.append("<script type=\"text/javascript\">\n").append("/* <![CDATA[ */ \n").append("jQuery(function() {\n").append(" jQuery('.o_toogle_rubrics').on('click', function() {\n").append("   jQuery('.o_assessmentsection_rubrics').each(function(index, el) {\n").append("     var current = jQuery(el).attr('class');\n").append("     if(current.indexOf('o_hide') >= 0) {\n").append("       jQuery(el).removeClass('o_hide').addClass('o_show');\n").append("       jQuery('a.o_toogle_rubrics.translated i').removeClass('o_icon_open_togglebox').addClass('o_icon_close_togglebox');\n").append("       jQuery('a.o_toogle_rubrics.translated span').html('").append(translator.translate("hide.rubric")).append("');").append("     } else {\n").append("   	  jQuery(el).removeClass('o_show').addClass('o_hide');\n").append("       jQuery('a.o_toogle_rubrics.translated i').removeClass('o_icon_close_togglebox').addClass('o_icon_open_togglebox');\n").append("       jQuery('a.o_toogle_rubrics.translated span').html('").append(translator.translate("show.rubric")).append("');").append("     }\n").append("   });").append(" });").append("});\n /* ]]> */").append("</script>").append("</div>");
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) NameValuePair(org.olat.core.gui.components.form.flexible.impl.NameValuePair) Form(org.olat.core.gui.components.form.flexible.impl.Form) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) ArrayList(java.util.ArrayList) AssessmentRenderFunctions.contentAsString(org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

Aggregations

Form (org.olat.core.gui.components.form.flexible.impl.Form)64 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)42 AssessmentRenderFunctions.contentAsString (org.olat.ims.qti21.ui.components.AssessmentRenderFunctions.contentAsString)10 Component (org.olat.core.gui.components.Component)4 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)4 FlexiTableSort (org.olat.core.gui.components.form.flexible.elements.FlexiTableSort)4 StringOutput (org.olat.core.gui.render.StringOutput)4 TestSessionController (uk.ac.ed.ph.jqtiplus.running.TestSessionController)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 HashSet (java.util.HashSet)2 Matcher (java.util.regex.Matcher)2 SortKey (org.olat.core.commons.persistence.SortKey)2 TextBoxListElementComponent (org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementComponent)2 TextBoxListElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl)2 TextModeState (org.olat.core.gui.components.form.flexible.impl.elements.richText.RichTextElementImpl.TextModeState)2 FlexiTableElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableElementImpl)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 AJAXFlags (org.olat.core.gui.control.winmgr.AJAXFlags)2