<commit_before>/**
 * DEPENDENCY: YUI lib (at least YAHOO.util and its dependencies)
 * DEPENDENCY: scripts/ilios_ui.js
 * DEPENDENCY: scripts/ilios_utilities.js
 */

ilios.namespace('cm.session');


ilios.cm.session.sessionContainerCount = 0;

ilios.cm.session.collapseOrExpandSessions = function (courseIsLoading) {
    var element = new YAHOO.util.Element(document.getElementById('expand_sessions_link'));
    var collapseValue = 1;
    var sessions = ilios.cm.currentCourseModel.getSessions();
    var collapseValueToUse = -1;

    if (element.hasClass('sessions_collapsed') && (! courseIsLoading)) {
        element.removeClass('sessions_collapsed');
        element.get('element').innerHTML
                            = ilios_i18nVendor.getI18NString('general.phrases.collapse_all');
        collapseValue = 2;
    }
    else {
        element.addClass('sessions_collapsed');
        element.get('element').innerHTML
                            = ilios_i18nVendor.getI18NString('general.phrases.expand_all');
    }

    for (var key in sessions) {
        collapseValueToUse = collapseValue;

        if (courseIsLoading && (sessions[key].getDBId() == ilios.cm.loadedSessionIdToDisplay)) {
            collapseValueToUse = 2;
        }

        ilios.dom.collapseChildForContainerNumber(key, collapseValueToUse,ilios.cm.session.setSessionContainerHeaderTitle,ilios.cm.session.setSessionContainerHeaderTitle);
    }
};

ilios.cm.session.generateSessionOfferingsLinkText = function (offeringCount) {
    var i18nStr = ilios_i18nVendor.getI18NString('course_management.go_to_calendar');

    return i18nStr + ' (' + offeringCount + ')';
};

ilios.cm.session.generateIdStringForSessionAttireCheckbox = function (containerNumber) {
    return '' + containerNumber + '_session_attire_checkbox';
};

ilios.cm.session.generateIdStringForSessionCoreRadio = function (containerNumber) {
    return '' + containerNumber + '_session_core_radio';
};

ilios.cm.session.generateIdStringForSessionDescription = function (containerNumber) {
    return '' + containerNumber + '_session_description';
};

ilios.cm.session.generateIdStringForSessionDescriptionEditButton = function (containerNumber) {
    return '' + containerNumber + '_session_description_edit_button';
};

ilios.cm.session.generateIdStringForSessionEquipmentCheckbox = function (containerNumber) {
    return '' + containerNumber + '_session_equipment_checkbox';
};

ilios.cm.session.generateIdStringForSessionGroups = function (containerNumber) {
    return '' + containerNumber + '_session_groups';
};

ilios.cm.session.generateIdStringForSessionILMCheckbox = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_checkbox';
};

ilios.cm.session.generateIdStringForSessionILMDiv = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_div';
};

ilios.cm.session.generateIdStringForSessionILMDueDate = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_due_date_tf';
};

ilios.cm.session.generateIdStringForSessionILMHours = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_hours_tf';
};

ilios.cm.session.generateIdStringForSessionILMGroupsLink = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_groups_link';
};

ilios.cm.session.generateIdStringForSessionMultiOfferingCreateLink = function (containerNumber) {
    return '' + containerNumber + '_session_multi_offering_link';
};

ilios.cm.session.generateIdStringForSessionOfferingsLink = function (containerNumber) {
    return '' + containerNumber + '_session_offerings_link';
};

ilios.cm.session.generateIdStringForSessionOfferingEnumerationList = function (containerNumber) {
    return '' + containerNumber + '_session_offerings_enumeration';
};

ilios.cm.session.generateIdStringForSessionOfferingExpandWidget = function (containerNumber) {
    return '' + containerNumber + '_session_offerings_expand';
};

ilios.cm.session.generateIdStringForSessionSupplementalRadio = function (containerNumber) {
    return '' + containerNumber + '_session_supplemental_radio';
}

ilios.cm.session.generateIdStringForSessionTitle = function (containerNumber) {
    return '' + containerNumber + '_session_title';
};

ilios.cm.session.generateIdStringForSessionTypeSelector = function (containerNumber) {
    return '' + containerNumber + '_session_type_selector';
};

// @private
ilios.cm.session.appendMeSHBlock = function (parentElement, containerNumber, labelString) {
    var clickFunction = function (e) {
        var sessionModel = ilios.cm.currentCourseModel.getSessionForContainer(containerNumber);
        IEvent.fire({
            action: 'mesh_picker_dialog_open',
            model_in_edit: sessionModel
        });
    };

    return ilios.cm.createAttributeDisplayBlock(parentElement, containerNumber, labelString,
        clickFunction, 'mesh_terms_picker_selected_text_list', false, '');
};

ilios.cm.session.resetEditSessionObjectiveDialog = function (dialog) {
    var objectivesDiv = document.getElementById('eso_parent_objectives_div');
    var courseObjectives = ilios.cm.currentCourseModel.getObjectives();
    var courseObjective = null;
    var parentObjectives = [];

    var selected = false;
    if (ilios.cm.inEditObjectiveModel) {
        parentObjectives = ilios.cm.inEditObjectiveModel.getParentObjectives();
        document.getElementById("eso_textarea").value = ilios.cm.inEditObjectiveModel.getDescription();
        dialog.esoEditor.setEditorHTML(ilios.cm.inEditObjectiveModel.getDescription());
    } else {
        document.getElementById("eso_textarea").value = "";
        dialog.esoEditor.setEditorHTML("");
    }

    ilios.utilities.removeAllChildren(objectivesDiv);
    for (var i = 0; i < courseObjectives.length; i++) {
        courseObjective = courseObjectives[i];
        if (courseObjective != null) {
            selected = ilios.utilities.arrayContains(parentObjectives, courseObjective.getDBId());
            objectivesDiv.appendChild(ilios.cm.session.domForEditSessionCourseObjective(courseObjective, selected));
            ilios.utilities.appendClearingDivToContainer(objectivesDiv);
        }
    }
};

ilios.cm.session.domForEditSessionCourseObjective = function (objectiveModel, selected) {
    var rhett = document.createElement('div');
    var textDiv = document.createElement('div');
    var checkboxDiv = document.createElement('div');
    var checkbox = document.createElement('input');

    rhett.setAttribute('style', 'position: relative; margin: 0px;');

    checkboxDiv.setAttribute('style', 'float: left; margin: 1px 0px; width: 22px;');
    checkboxDiv.setAttribute('class', 'objective_checkbox_div');
    textDiv.setAttribute('style', 'float: auto; padding: 3px 6px 0; width: 95%;');

    checkbox.setAttribute('type', 'checkbox');
    if (selected) {
        checkbox.setAttribute('checked', 'yes');
    }
    checkbox.iliosModel = objectiveModel;
    checkboxDiv.appendChild(checkbox);

    textDiv.innerHTML = objectiveModel.getDescription();

    rhett.appendChild(checkboxDiv);
    rhett.appendChild(textDiv);

    return rhett;
};

ilios.cm.session.getArrayOfCurrentlySelectedSessionParentObjectives = function () {
    var Element = YAHOO.util.Element;
    var rhett = [];
    var objectivesDiv = document.getElementById('eso_parent_objectives_div');
    var children = objectivesDiv.children;
    var objective = null;
    var checkBoxDiv = null;
    var checkbox = null;

    for (var i = 0; i < children.length; i += 2) {
        objective = new Element(children[i]);
        checkboxDiv = objective.getElementsByClassName('objective_checkbox_div');
        checkbox = checkboxDiv[0].children[0];

        if (checkbox.checked) {
            rhett.push(checkbox.iliosModel.getDBId());
        }
    }

    return rhett;
};

// @private
ilios.cm.session.setOfferingEnumerationDivVisibility = function (containerNumber, widgetDiv, shouldToggle) {
    var Element = YAHOO.util.Element;
    var yElement = null;
    var idString = null;
    var div = null;

    if (ilios.cm.currentCourseModel == null) {
        return;
    }

    if (widgetDiv == null) {
        idString = ilios.cm.session.generateIdStringForSessionOfferingExpandWidget(containerNumber);

        widgetDiv = document.getElementById(idString);
    }

    yElement = new Element(widgetDiv);
    idString = ilios.cm.session.generateIdStringForSessionOfferingEnumerationList(containerNumber);
    div = new Element(document.getElementById(idString));
    if ((div.getStyle('display') != 'none') && shouldToggle) {
        yElement.removeClass('expanded_widget');
        yElement.addClass('collapsed_widget');
        div.setStyle('display', 'none');
    } else {
        yElement.removeClass('collapsed_widget');
        yElement.addClass('expanded_widget');
        div.setStyle('display', 'block');
    }
};

/*
 * (hideous thick coding -- unclear how to make it more readable
 */
// @private
ilios.cm.session.sessionContentGenerator = function (parentElement, containerNumber) {
    var scratchLabel = null;
    var scratchInput = null;
    var scratchOption = null;
    var scratchElement = null;
    var scratchContainer = null;
    var subContainer = null;
    var subSubContainer = null;
    var text = null;
    var i18nStr = ilios_i18nVendor.getI18NString('course_management.session.session_title');
    var len = ilios.cm.loadedSessionTypes.length;
    var i = 0;
    var sessionType = null;
    var rowElement, labelCol, dataCol, actionCol, count;
    var scratchElementId = null;
    var Event = YAHOO.util.Event;
    var Element = YAHOO.util.Element;

    //session title
    rowElement = ilios.dom.createEntityContainerInputRow();
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionTitle(containerNumber));
    scratchInput.setAttribute('type', 'text');
    Event.addListener(scratchInput, 'keyup', function () {
        var element = document.getElementById(ilios.cm.session.generateIdStringForSessionTitle(containerNumber));
        var sessionModel = ilios.cm.currentCourseModel.getSessionForContainer(containerNumber);
        sessionModel.setTitle(element.value);
    });

    ilios.dom.createDataCol(rowElement, scratchInput);
    //no actions
    scratchInput = document.createElement('span');
    ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //session type
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.session_type');
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label column
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchInput = new Element(document.createElement('select'), {id:
        ilios.cm.session.generateIdStringForSessionTypeSelector(containerNumber)
    });
    scratchInput.addListener('change', function (e) {
        ilios.cm.session.sessionTypeSelected(containerNumber);
    });

    for (i = 0; i < len; i++) {
        sessionType = ilios.cm.loadedSessionTypes[i];
        scratchOption = document.createElement('option');
        scratchOption.setAttribute('value', sessionType.dbId);
        if (i == 0) {
            scratchOption.setAttribute('selected', 'true');
        }
        textNode = document.createTextNode(sessionType.title);
        scratchOption.appendChild(textNode);
        scratchInput.appendChild(scratchOption);
    }
    ilios.dom.createDataCol(rowElement, scratchInput.get('element'));
    //no actions
    scratchElement = document.createElement('span');
    ilios.dom.createActionCol(rowElement, scratchElement);

    parentElement.appendChild(rowElement);

    //ILM
    rowElement = ilios.dom.createEntityContainerInputRow();
    //no label
    scratchLabel = document.createElement('span');
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchElement = document.createElement('label');
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'checkbox');
    scratchInput.setAttribute('name', 'independent_learning');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMCheckbox(containerNumber));
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.sessionILMCheckboxSelected(this, containerNumber);
    });
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.independent_learning');
    scratchElement.appendChild(scratchInput);
    scratchElement.appendChild(document.createTextNode(i18nStr));
    dataCol = ilios.dom.createDataCol(rowElement, scratchElement);

    //add in the ILM due date - clean this up later
    subContainer = document.createElement('span');
    subContainer.setAttribute('class', 'margin-l');
    subContainer.setAttribute('style', 'display:none;');
    subContainer.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMDiv(containerNumber));
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('style', 'width: 3em;');
    scratchInput.setAttribute('type', 'text');
    scratchInput.setAttribute('name', 'ilm_hours');
    scratchInput.setAttribute('value', '1');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMHours(containerNumber));
    Event.addListener(scratchInput, 'keyup', function () {
        var hourIdString = ilios.cm.session.generateIdStringForSessionILMHours(containerNumber);
        var hourTF = document.getElementById(hourIdString);
        if (ilios.utilities.isNumber(hourTF.value)) {
            var sessionModel = ilios.cm.currentCourseModel.getSessionForContainer(containerNumber);
            var ilmModel = sessionModel.getIndependentLearningModel();
            ilmModel.setHours(hourTF.value);
        }
    });

    subContainer.appendChild(scratchInput);
    i18nStr = ' ' + ilios_i18nVendor.getI18NString('general.terms.hours').toLowerCase() + ' ';
    subContainer.appendChild(document.createTextNode(i18nStr));

    subSubContainer = document.createElement('span');
    subSubContainer.setAttribute('style', 'display: inline-block;');
    i18nStr = ' ' + ilios_i18nVendor.getI18NString('general.phrases.due_by').toLowerCase() + ' ';
    subSubContainer.appendChild(document.createTextNode(i18nStr));

    scratchInput = document.createElement('input');
    scratchInput.setAttribute('style', 'width: 6em;');
    scratchInput.setAttribute('type', 'text');
    scratchInput.setAttribute('name', 'ilm_hours');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMDueDate(containerNumber));
    scratchInput.disabled = true;
    subSubContainer.appendChild(scratchInput);
    subContainer.appendChild(subSubContainer);

    subSubContainer = document.createElement('div');
    subSubContainer.setAttribute('class', 'calendar_button');
    subSubContainer.setAttribute('style', 'display: inline-block;');
    Event.addListener(subSubContainer, 'click',
                       function () {ilios.cm.session.ilm.showILMLightbox(containerNumber);});
    ilios.cm.uiElementsToHideOnLockedView.push(new Element(subSubContainer));
    subContainer.appendChild(subSubContainer);

    //scratchContainer.appendChild(subContainer);
    dataCol.appendChild(subContainer);

    //action column
    scratchInput = document.createElement('button');
    scratchInput.setAttribute('class', 'tiny radius button');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMGroupsLink(containerNumber));
    Event.addListener(scratchInput, 'click', function (e) {
        Event.preventDefault(e);
        ilios.cm.session.ilm.showILMLightbox(containerNumber);
    });
    i18nStr = ' ' + ilios_i18nVendor.getI18NString('general.phrases.add_groups');
    scratchInput.appendChild(document.createTextNode(i18nStr));
    ilios.cm.uiElementsToHideOnLockedView.push(new Element(scratchInput));
    ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //Offerings
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label
    scratchLabel = document.createElement('label');
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.offerings');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    ilios.dom.createLabelCol(rowElement, scratchLabel);

    //data column
    scratchInput = document.createElement('div');
    scratchInput.setAttribute('class', 'read_only_data scroll_list');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionOfferingEnumerationList(containerNumber));
    ilios.dom.createDataCol(rowElement, scratchInput);

    //action column
    //button 1
    scratchInput = document.createElement('button');
    scratchInput.setAttribute('class', 'small radius button');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionOfferingsLink(containerNumber));
    scratchInput.setAttribute('onclick', 'return false;');
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.editOfferingsForContainer(containerNumber);
    });
    text = document.createTextNode(ilios.cm.session.generateSessionOfferingsLinkText(0));
    scratchInput.appendChild(text);
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput);

    //button 2
    scratchInput = document.createElement('button');
    scratchInput.setAttribute('class', 'small radius button');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionMultiOfferingCreateLink(containerNumber));
    Event.addListener(scratchInput, 'click', function (e) {
        Event.preventDefault(e);
        ilios.cm.session.mo.showMultiOfferingLightbox(containerNumber);
    });
    i18nStr = ilios_i18nVendor.getI18NString('course_management.create_multi_offering');
    text = document.createTextNode(i18nStr);
    scratchInput.appendChild(text);
    ilios.cm.uiElementsToHideOnLockedView.push(new Element(scratchInput));
    actionCol.appendChild(scratchInput);

    parentElement.appendChild(rowElement);

    //groups
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.groups');
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label col
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    labelCol = ilios.dom.createLabelCol(rowElement, scratchLabel);

    //data col
    scratchInput = document.createElement('div');
    scratchInput.setAttribute('id',
                              ilios.cm.session.generateIdStringForSessionGroups(containerNumber));
    scratchInput.setAttribute('class', 'read_only_data scroll_list');
    dataCol = ilios.dom.createDataCol(rowElement, scratchInput);

    //no actions
    scratchInput = document.createElement('span');
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //core/supplemental
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.curriculum_type');
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label column
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    labelCol = ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'radio');
    scratchInput.setAttribute('name', 'core_or_supplement');
    scratchInput.setAttribute('value', 'core');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionCoreRadio(containerNumber));
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.supplementalCoreRadioChanged(containerNumber, this, false);
    });
    scratchLabel = document.createElement('label');
    scratchLabel.setAttribute('for', scratchInput.getAttribute('id'));
    scratchLabel.setAttribute('id', (scratchInput.getAttribute('id') + '_label'));
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.core');
    scratchLabel.appendChild(scratchInput);
    scratchLabel.appendChild(document.createTextNode(i18nStr));
    dataCol = ilios.dom.createDataCol(rowElement, scratchLabel);

    dataCol.appendChild(document.createElement('br'));

    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'radio');
    scratchInput.setAttribute('name', 'core_or_supplement');
    scratchInput.setAttribute('value', 'supplemental');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionSupplementalRadio(containerNumber));
    scratchInput.setAttribute('checked', 'true');
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.supplementalCoreRadioChanged(containerNumber, this, true);
    });
    scratchLabel = document.createElement('label');
    scratchLabel.setAttribute('for', scratchInput.getAttribute('id'));
    scratchLabel.setAttribute('id', (scratchInput.getAttribute('id') + '_label'));
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.supplemental');
    scratchLabel.appendChild(scratchInput);
    scratchLabel.appendChild(document.createTextNode(i18nStr));
    dataCol.appendChild(scratchLabel);
    //action column - no actions
    scratchInput = document.createElement('span');
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //special requirements
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.special_requirements');
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label column
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'checkbox');
    scratchInput.setAttribute('name', 'attire_and_equipment');
    scratchInput.setAttribute('value', 'attire');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionAttireCheckbox(containerNumber));
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.attireCheckboxChanged(containerNumber);
    });
    scratchLabel = document.createElement('label');
    scratchLabel.appendChild(scratchInput);
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.attire');
    scratchLabel.appendChild(document.createTextNode(i18nStr));
    dataCol = ilios.dom.createDataCol(rowElement, scratchLabel);

    dataCol.appendChild(document.createElement('br'));

    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'checkbox');
    scratchInput.setAttribute('name', 'attire_and_equipment');
    scratchInput.setAttribute('value', 'equipment');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionEquipmentCheckbox(containerNumber));
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.equipmentCheckboxChanged(containerNumber);
    });
    scratchLabel = document.createElement('label');
    scratchLabel.appendChild(scratchInput);
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.equipment');
    scratchLabel.appendChild(document.createTextNode(i18nStr));
    dataCol.appendChild(scratchLabel);
    //action column - no actions
    scratchInput = document.createElement('span');
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //description
    rowElement = ilios.dom.createEntityContainerInputRow();
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.description');
    //label column
    scratchLabel= document.createElement('label');
    scratchLabel.appendChild(document.createTextNode(i18nStr))
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchElement = document.createElement('div');
    scratchElement.setAttribute('class', 'session_description')
    scratchElementId = ilios.cm.session.generateIdStringForSessionDescription(containerNumber);
    scratchElement.setAttribute('id', scratchElementId);
    dataCol = ilios.dom.createDataCol(rowElement, scratchElement);

    // action column
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.edit');
    scratchInput = new Element(document.createElement('a'), {href: ''});
    scratchInput.get('element').setAttribute('onclick', 'return false;');
    scratchElementId = ilios.cm.session.generateIdStringForSessionDescriptionEditButton(containerNumber);
    scratchInput.get('element').setAttribute('id', scratchElementId);
    scratchInput.addClass('tiny radius button');
    text = document.createTextNode(i18nStr);
    scratchInput.appendChild(text);
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput.get('element'));
    ilios.cm.uiElementsToHideOnLockedView.push(scratchInput);
    parentElement.appendChild(rowElement);

    //disciplines
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.topics');
    scratchElement = ilios.cm.appendAttributeDisplayBlock(parentElement, containerNumber, i18nStr,
        'discipline_picker_show_dialog', 'discipline_picker_selected_text_list', false, '');
    ilios.cm.uiElementsToHideOnLockedView.push(scratchElement);

    //MeSH
    i18nStr = ilios_i18nVendor.getI18NString('general.phrases.mesh_terms');
    scratchElement = ilios.cm.session.appendMeSHBlock(parentElement, containerNumber, i18nStr);
    ilios.cm.uiElementsToHideOnLockedView.push(scratchElement);

    //Learning Material
    rowElement = ilios.dom.createEntityContainerInputRow();
    i18nStr = ilios_i18nVendor.getI18NString('course_management.learning_materials.title');
    //label column
    text = document.createTextNode(i18nStr);
    scratchLabel = document.createElement('label');
    scratchLabel.appendChild(text);
    count = document.createElement('span');
    count.setAttribute('id', ilios.cm.lm.generateIdStringForLearningMaterialCount(containerNumber));
    scratchLabel.appendChild(count);
    ilios.dom.createLabelCol(rowElement, scratchLabel);

    //data column
    subContainer = document.createElement('div');
    subContainer.setAttribute('class', 'scroll_list');
    subSubContainer = document.createElement('ul');
    subSubContainer.setAttribute('class', 'learning_material_list');
    subSubContainer.setAttribute('id', ilios.cm.lm.generateIdStringForLearningMaterialList(containerNumber));
    subContainer.appendChild(subSubContainer);
    dataCol = ilios.dom.createDataCol(rowElement, subContainer);

    //action column
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.add');
    scratchInput = new Element(document.createElement('a'), {href: ''});
    scratchInput.get('element').setAttribute('onclick', 'return false;');
    scratchInput.addClass('tiny radius button');
    scratchInput.addListener('click', function (e) {
        IEvent.fire({
            action: 'alm_dialog_open',
            container_number: containerNumber
        });
    }, null, this);
    text = document.createTextNode(i18nStr);
    scratchInput.appendChild(text);
    ilios.cm.uiElementsToHideOnLockedView.push(scratchInput);<commit_msg>bugfix: added missing expand/collapse widget and corresponding wrapper container for session learning materials. this fixes session LM upload JS error. refs #3096<commit_after>/**
 * DEPENDENCY: YUI lib (at least YAHOO.util and its dependencies)
 * DEPENDENCY: scripts/ilios_ui.js
 * DEPENDENCY: scripts/ilios_utilities.js
 */

ilios.namespace('cm.session');


ilios.cm.session.sessionContainerCount = 0;

ilios.cm.session.collapseOrExpandSessions = function (courseIsLoading) {
    var element = new YAHOO.util.Element(document.getElementById('expand_sessions_link'));
    var collapseValue = 1;
    var sessions = ilios.cm.currentCourseModel.getSessions();
    var collapseValueToUse = -1;

    if (element.hasClass('sessions_collapsed') && (! courseIsLoading)) {
        element.removeClass('sessions_collapsed');
        element.get('element').innerHTML
                            = ilios_i18nVendor.getI18NString('general.phrases.collapse_all');
        collapseValue = 2;
    }
    else {
        element.addClass('sessions_collapsed');
        element.get('element').innerHTML
                            = ilios_i18nVendor.getI18NString('general.phrases.expand_all');
    }

    for (var key in sessions) {
        collapseValueToUse = collapseValue;

        if (courseIsLoading && (sessions[key].getDBId() == ilios.cm.loadedSessionIdToDisplay)) {
            collapseValueToUse = 2;
        }

        ilios.dom.collapseChildForContainerNumber(key, collapseValueToUse,ilios.cm.session.setSessionContainerHeaderTitle,ilios.cm.session.setSessionContainerHeaderTitle);
    }
};

ilios.cm.session.generateSessionOfferingsLinkText = function (offeringCount) {
    var i18nStr = ilios_i18nVendor.getI18NString('course_management.go_to_calendar');

    return i18nStr + ' (' + offeringCount + ')';
};

ilios.cm.session.generateIdStringForSessionAttireCheckbox = function (containerNumber) {
    return '' + containerNumber + '_session_attire_checkbox';
};

ilios.cm.session.generateIdStringForSessionCoreRadio = function (containerNumber) {
    return '' + containerNumber + '_session_core_radio';
};

ilios.cm.session.generateIdStringForSessionDescription = function (containerNumber) {
    return '' + containerNumber + '_session_description';
};

ilios.cm.session.generateIdStringForSessionDescriptionEditButton = function (containerNumber) {
    return '' + containerNumber + '_session_description_edit_button';
};

ilios.cm.session.generateIdStringForSessionEquipmentCheckbox = function (containerNumber) {
    return '' + containerNumber + '_session_equipment_checkbox';
};

ilios.cm.session.generateIdStringForSessionGroups = function (containerNumber) {
    return '' + containerNumber + '_session_groups';
};

ilios.cm.session.generateIdStringForSessionILMCheckbox = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_checkbox';
};

ilios.cm.session.generateIdStringForSessionILMDiv = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_div';
};

ilios.cm.session.generateIdStringForSessionILMDueDate = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_due_date_tf';
};

ilios.cm.session.generateIdStringForSessionILMHours = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_hours_tf';
};

ilios.cm.session.generateIdStringForSessionILMGroupsLink = function (containerNumber) {
    return '' + containerNumber + '_session_ilm_groups_link';
};

ilios.cm.session.generateIdStringForSessionMultiOfferingCreateLink = function (containerNumber) {
    return '' + containerNumber + '_session_multi_offering_link';
};

ilios.cm.session.generateIdStringForSessionOfferingsLink = function (containerNumber) {
    return '' + containerNumber + '_session_offerings_link';
};

ilios.cm.session.generateIdStringForSessionOfferingEnumerationList = function (containerNumber) {
    return '' + containerNumber + '_session_offerings_enumeration';
};

ilios.cm.session.generateIdStringForSessionOfferingExpandWidget = function (containerNumber) {
    return '' + containerNumber + '_session_offerings_expand';
};

ilios.cm.session.generateIdStringForSessionSupplementalRadio = function (containerNumber) {
    return '' + containerNumber + '_session_supplemental_radio';
}

ilios.cm.session.generateIdStringForSessionTitle = function (containerNumber) {
    return '' + containerNumber + '_session_title';
};

ilios.cm.session.generateIdStringForSessionTypeSelector = function (containerNumber) {
    return '' + containerNumber + '_session_type_selector';
};

// @private
ilios.cm.session.appendMeSHBlock = function (parentElement, containerNumber, labelString) {
    var clickFunction = function (e) {
        var sessionModel = ilios.cm.currentCourseModel.getSessionForContainer(containerNumber);
        IEvent.fire({
            action: 'mesh_picker_dialog_open',
            model_in_edit: sessionModel
        });
    };

    return ilios.cm.createAttributeDisplayBlock(parentElement, containerNumber, labelString,
        clickFunction, 'mesh_terms_picker_selected_text_list', false, '');
};

ilios.cm.session.resetEditSessionObjectiveDialog = function (dialog) {
    var objectivesDiv = document.getElementById('eso_parent_objectives_div');
    var courseObjectives = ilios.cm.currentCourseModel.getObjectives();
    var courseObjective = null;
    var parentObjectives = [];

    var selected = false;
    if (ilios.cm.inEditObjectiveModel) {
        parentObjectives = ilios.cm.inEditObjectiveModel.getParentObjectives();
        document.getElementById("eso_textarea").value = ilios.cm.inEditObjectiveModel.getDescription();
        dialog.esoEditor.setEditorHTML(ilios.cm.inEditObjectiveModel.getDescription());
    } else {
        document.getElementById("eso_textarea").value = "";
        dialog.esoEditor.setEditorHTML("");
    }

    ilios.utilities.removeAllChildren(objectivesDiv);
    for (var i = 0; i < courseObjectives.length; i++) {
        courseObjective = courseObjectives[i];
        if (courseObjective != null) {
            selected = ilios.utilities.arrayContains(parentObjectives, courseObjective.getDBId());
            objectivesDiv.appendChild(ilios.cm.session.domForEditSessionCourseObjective(courseObjective, selected));
            ilios.utilities.appendClearingDivToContainer(objectivesDiv);
        }
    }
};

ilios.cm.session.domForEditSessionCourseObjective = function (objectiveModel, selected) {
    var rhett = document.createElement('div');
    var textDiv = document.createElement('div');
    var checkboxDiv = document.createElement('div');
    var checkbox = document.createElement('input');

    rhett.setAttribute('style', 'position: relative; margin: 0px;');

    checkboxDiv.setAttribute('style', 'float: left; margin: 1px 0px; width: 22px;');
    checkboxDiv.setAttribute('class', 'objective_checkbox_div');
    textDiv.setAttribute('style', 'float: auto; padding: 3px 6px 0; width: 95%;');

    checkbox.setAttribute('type', 'checkbox');
    if (selected) {
        checkbox.setAttribute('checked', 'yes');
    }
    checkbox.iliosModel = objectiveModel;
    checkboxDiv.appendChild(checkbox);

    textDiv.innerHTML = objectiveModel.getDescription();

    rhett.appendChild(checkboxDiv);
    rhett.appendChild(textDiv);

    return rhett;
};

ilios.cm.session.getArrayOfCurrentlySelectedSessionParentObjectives = function () {
    var Element = YAHOO.util.Element;
    var rhett = [];
    var objectivesDiv = document.getElementById('eso_parent_objectives_div');
    var children = objectivesDiv.children;
    var objective = null;
    var checkBoxDiv = null;
    var checkbox = null;

    for (var i = 0; i < children.length; i += 2) {
        objective = new Element(children[i]);
        checkboxDiv = objective.getElementsByClassName('objective_checkbox_div');
        checkbox = checkboxDiv[0].children[0];

        if (checkbox.checked) {
            rhett.push(checkbox.iliosModel.getDBId());
        }
    }

    return rhett;
};

// @private
ilios.cm.session.setOfferingEnumerationDivVisibility = function (containerNumber, widgetDiv, shouldToggle) {
    var Element = YAHOO.util.Element;
    var yElement = null;
    var idString = null;
    var div = null;

    if (ilios.cm.currentCourseModel == null) {
        return;
    }

    if (widgetDiv == null) {
        idString = ilios.cm.session.generateIdStringForSessionOfferingExpandWidget(containerNumber);

        widgetDiv = document.getElementById(idString);
    }

    yElement = new Element(widgetDiv);
    idString = ilios.cm.session.generateIdStringForSessionOfferingEnumerationList(containerNumber);
    div = new Element(document.getElementById(idString));
    if ((div.getStyle('display') != 'none') && shouldToggle) {
        yElement.removeClass('expanded_widget');
        yElement.addClass('collapsed_widget');
        div.setStyle('display', 'none');
    } else {
        yElement.removeClass('collapsed_widget');
        yElement.addClass('expanded_widget');
        div.setStyle('display', 'block');
    }
};

/*
 * (hideous thick coding -- unclear how to make it more readable
 */
// @private
ilios.cm.session.sessionContentGenerator = function (parentElement, containerNumber) {
    var scratchLabel = null;
    var scratchInput = null;
    var scratchOption = null;
    var scratchElement = null;
    var scratchContainer = null;
    var subContainer = null;
    var subSubContainer = null;
    var text = null;
    var i18nStr = ilios_i18nVendor.getI18NString('course_management.session.session_title');
    var len = ilios.cm.loadedSessionTypes.length;
    var i = 0;
    var sessionType = null;
    var rowElement, labelCol, dataCol, actionCol, count;
    var scratchElementId = null;
    var Event = YAHOO.util.Event;
    var Element = YAHOO.util.Element;

    //session title
    rowElement = ilios.dom.createEntityContainerInputRow();
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionTitle(containerNumber));
    scratchInput.setAttribute('type', 'text');
    Event.addListener(scratchInput, 'keyup', function () {
        var element = document.getElementById(ilios.cm.session.generateIdStringForSessionTitle(containerNumber));
        var sessionModel = ilios.cm.currentCourseModel.getSessionForContainer(containerNumber);
        sessionModel.setTitle(element.value);
    });

    ilios.dom.createDataCol(rowElement, scratchInput);
    //no actions
    scratchInput = document.createElement('span');
    ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //session type
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.session_type');
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label column
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchInput = new Element(document.createElement('select'), {id:
        ilios.cm.session.generateIdStringForSessionTypeSelector(containerNumber)
    });
    scratchInput.addListener('change', function (e) {
        ilios.cm.session.sessionTypeSelected(containerNumber);
    });

    for (i = 0; i < len; i++) {
        sessionType = ilios.cm.loadedSessionTypes[i];
        scratchOption = document.createElement('option');
        scratchOption.setAttribute('value', sessionType.dbId);
        if (i == 0) {
            scratchOption.setAttribute('selected', 'true');
        }
        textNode = document.createTextNode(sessionType.title);
        scratchOption.appendChild(textNode);
        scratchInput.appendChild(scratchOption);
    }
    ilios.dom.createDataCol(rowElement, scratchInput.get('element'));
    //no actions
    scratchElement = document.createElement('span');
    ilios.dom.createActionCol(rowElement, scratchElement);

    parentElement.appendChild(rowElement);

    //ILM
    rowElement = ilios.dom.createEntityContainerInputRow();
    //no label
    scratchLabel = document.createElement('span');
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchElement = document.createElement('label');
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'checkbox');
    scratchInput.setAttribute('name', 'independent_learning');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMCheckbox(containerNumber));
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.sessionILMCheckboxSelected(this, containerNumber);
    });
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.independent_learning');
    scratchElement.appendChild(scratchInput);
    scratchElement.appendChild(document.createTextNode(i18nStr));
    dataCol = ilios.dom.createDataCol(rowElement, scratchElement);

    //add in the ILM due date - clean this up later
    subContainer = document.createElement('span');
    subContainer.setAttribute('class', 'margin-l');
    subContainer.setAttribute('style', 'display:none;');
    subContainer.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMDiv(containerNumber));
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('style', 'width: 3em;');
    scratchInput.setAttribute('type', 'text');
    scratchInput.setAttribute('name', 'ilm_hours');
    scratchInput.setAttribute('value', '1');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMHours(containerNumber));
    Event.addListener(scratchInput, 'keyup', function () {
        var hourIdString = ilios.cm.session.generateIdStringForSessionILMHours(containerNumber);
        var hourTF = document.getElementById(hourIdString);
        if (ilios.utilities.isNumber(hourTF.value)) {
            var sessionModel = ilios.cm.currentCourseModel.getSessionForContainer(containerNumber);
            var ilmModel = sessionModel.getIndependentLearningModel();
            ilmModel.setHours(hourTF.value);
        }
    });

    subContainer.appendChild(scratchInput);
    i18nStr = ' ' + ilios_i18nVendor.getI18NString('general.terms.hours').toLowerCase() + ' ';
    subContainer.appendChild(document.createTextNode(i18nStr));

    subSubContainer = document.createElement('span');
    subSubContainer.setAttribute('style', 'display: inline-block;');
    i18nStr = ' ' + ilios_i18nVendor.getI18NString('general.phrases.due_by').toLowerCase() + ' ';
    subSubContainer.appendChild(document.createTextNode(i18nStr));

    scratchInput = document.createElement('input');
    scratchInput.setAttribute('style', 'width: 6em;');
    scratchInput.setAttribute('type', 'text');
    scratchInput.setAttribute('name', 'ilm_hours');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMDueDate(containerNumber));
    scratchInput.disabled = true;
    subSubContainer.appendChild(scratchInput);
    subContainer.appendChild(subSubContainer);

    subSubContainer = document.createElement('div');
    subSubContainer.setAttribute('class', 'calendar_button');
    subSubContainer.setAttribute('style', 'display: inline-block;');
    Event.addListener(subSubContainer, 'click',
                       function () {ilios.cm.session.ilm.showILMLightbox(containerNumber);});
    ilios.cm.uiElementsToHideOnLockedView.push(new Element(subSubContainer));
    subContainer.appendChild(subSubContainer);

    //scratchContainer.appendChild(subContainer);
    dataCol.appendChild(subContainer);

    //action column
    scratchInput = document.createElement('button');
    scratchInput.setAttribute('class', 'tiny radius button');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionILMGroupsLink(containerNumber));
    Event.addListener(scratchInput, 'click', function (e) {
        Event.preventDefault(e);
        ilios.cm.session.ilm.showILMLightbox(containerNumber);
    });
    i18nStr = ' ' + ilios_i18nVendor.getI18NString('general.phrases.add_groups');
    scratchInput.appendChild(document.createTextNode(i18nStr));
    ilios.cm.uiElementsToHideOnLockedView.push(new Element(scratchInput));
    ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //Offerings
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label
    scratchLabel = document.createElement('label');
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.offerings');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    ilios.dom.createLabelCol(rowElement, scratchLabel);

    //data column
    scratchInput = document.createElement('div');
    scratchInput.setAttribute('class', 'read_only_data scroll_list');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionOfferingEnumerationList(containerNumber));
    ilios.dom.createDataCol(rowElement, scratchInput);

    //action column
    //button 1
    scratchInput = document.createElement('button');
    scratchInput.setAttribute('class', 'small radius button');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionOfferingsLink(containerNumber));
    scratchInput.setAttribute('onclick', 'return false;');
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.editOfferingsForContainer(containerNumber);
    });
    text = document.createTextNode(ilios.cm.session.generateSessionOfferingsLinkText(0));
    scratchInput.appendChild(text);
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput);

    //button 2
    scratchInput = document.createElement('button');
    scratchInput.setAttribute('class', 'small radius button');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionMultiOfferingCreateLink(containerNumber));
    Event.addListener(scratchInput, 'click', function (e) {
        Event.preventDefault(e);
        ilios.cm.session.mo.showMultiOfferingLightbox(containerNumber);
    });
    i18nStr = ilios_i18nVendor.getI18NString('course_management.create_multi_offering');
    text = document.createTextNode(i18nStr);
    scratchInput.appendChild(text);
    ilios.cm.uiElementsToHideOnLockedView.push(new Element(scratchInput));
    actionCol.appendChild(scratchInput);

    parentElement.appendChild(rowElement);

    //groups
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.groups');
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label col
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    labelCol = ilios.dom.createLabelCol(rowElement, scratchLabel);

    //data col
    scratchInput = document.createElement('div');
    scratchInput.setAttribute('id',
                              ilios.cm.session.generateIdStringForSessionGroups(containerNumber));
    scratchInput.setAttribute('class', 'read_only_data scroll_list');
    dataCol = ilios.dom.createDataCol(rowElement, scratchInput);

    //no actions
    scratchInput = document.createElement('span');
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //core/supplemental
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.curriculum_type');
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label column
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    labelCol = ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'radio');
    scratchInput.setAttribute('name', 'core_or_supplement');
    scratchInput.setAttribute('value', 'core');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionCoreRadio(containerNumber));
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.supplementalCoreRadioChanged(containerNumber, this, false);
    });
    scratchLabel = document.createElement('label');
    scratchLabel.setAttribute('for', scratchInput.getAttribute('id'));
    scratchLabel.setAttribute('id', (scratchInput.getAttribute('id') + '_label'));
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.core');
    scratchLabel.appendChild(scratchInput);
    scratchLabel.appendChild(document.createTextNode(i18nStr));
    dataCol = ilios.dom.createDataCol(rowElement, scratchLabel);

    dataCol.appendChild(document.createElement('br'));

    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'radio');
    scratchInput.setAttribute('name', 'core_or_supplement');
    scratchInput.setAttribute('value', 'supplemental');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionSupplementalRadio(containerNumber));
    scratchInput.setAttribute('checked', 'true');
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.supplementalCoreRadioChanged(containerNumber, this, true);
    });
    scratchLabel = document.createElement('label');
    scratchLabel.setAttribute('for', scratchInput.getAttribute('id'));
    scratchLabel.setAttribute('id', (scratchInput.getAttribute('id') + '_label'));
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.supplemental');
    scratchLabel.appendChild(scratchInput);
    scratchLabel.appendChild(document.createTextNode(i18nStr));
    dataCol.appendChild(scratchLabel);
    //action column - no actions
    scratchInput = document.createElement('span');
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //special requirements
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.special_requirements');
    rowElement = ilios.dom.createEntityContainerInputRow();
    //label column
    scratchLabel = document.createElement('label');
    text = document.createTextNode(i18nStr);
    scratchLabel.appendChild(text);
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'checkbox');
    scratchInput.setAttribute('name', 'attire_and_equipment');
    scratchInput.setAttribute('value', 'attire');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionAttireCheckbox(containerNumber));
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.attireCheckboxChanged(containerNumber);
    });
    scratchLabel = document.createElement('label');
    scratchLabel.appendChild(scratchInput);
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.attire');
    scratchLabel.appendChild(document.createTextNode(i18nStr));
    dataCol = ilios.dom.createDataCol(rowElement, scratchLabel);

    dataCol.appendChild(document.createElement('br'));

    scratchInput = document.createElement('input');
    scratchInput.setAttribute('type', 'checkbox');
    scratchInput.setAttribute('name', 'attire_and_equipment');
    scratchInput.setAttribute('value', 'equipment');
    scratchInput.setAttribute('id', ilios.cm.session.generateIdStringForSessionEquipmentCheckbox(containerNumber));
    Event.addListener(scratchInput, 'click', function () {
        ilios.cm.session.equipmentCheckboxChanged(containerNumber);
    });
    scratchLabel = document.createElement('label');
    scratchLabel.appendChild(scratchInput);
    i18nStr = ilios_i18nVendor.getI18NString('course_management.session.equipment');
    scratchLabel.appendChild(document.createTextNode(i18nStr));
    dataCol.appendChild(scratchLabel);
    //action column - no actions
    scratchInput = document.createElement('span');
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput);

    parentElement.appendChild(rowElement);

    //description
    rowElement = ilios.dom.createEntityContainerInputRow();
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.description');
    //label column
    scratchLabel= document.createElement('label');
    scratchLabel.appendChild(document.createTextNode(i18nStr))
    ilios.dom.createLabelCol(rowElement, scratchLabel);
    //data column
    scratchElement = document.createElement('div');
    scratchElement.setAttribute('class', 'session_description')
    scratchElementId = ilios.cm.session.generateIdStringForSessionDescription(containerNumber);
    scratchElement.setAttribute('id', scratchElementId);
    dataCol = ilios.dom.createDataCol(rowElement, scratchElement);

    // action column
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.edit');
    scratchInput = new Element(document.createElement('a'), {href: ''});
    scratchInput.get('element').setAttribute('onclick', 'return false;');
    scratchElementId = ilios.cm.session.generateIdStringForSessionDescriptionEditButton(containerNumber);
    scratchInput.get('element').setAttribute('id', scratchElementId);
    scratchInput.addClass('tiny radius button');
    text = document.createTextNode(i18nStr);
    scratchInput.appendChild(text);
    actionCol = ilios.dom.createActionCol(rowElement, scratchInput.get('element'));
    ilios.cm.uiElementsToHideOnLockedView.push(scratchInput);
    parentElement.appendChild(rowElement);

    //disciplines
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.topics');
    scratchElement = ilios.cm.appendAttributeDisplayBlock(parentElement, containerNumber, i18nStr,
        'discipline_picker_show_dialog', 'discipline_picker_selected_text_list', false, '');
    ilios.cm.uiElementsToHideOnLockedView.push(scratchElement);

    //MeSH
    i18nStr = ilios_i18nVendor.getI18NString('general.phrases.mesh_terms');
    scratchElement = ilios.cm.session.appendMeSHBlock(parentElement, containerNumber, i18nStr);
    ilios.cm.uiElementsToHideOnLockedView.push(scratchElement);

    //Learning Material
    rowElement = ilios.dom.createEntityContainerInputRow();
    i18nStr = ilios_i18nVendor.getI18NString('course_management.learning_materials.title');

    //label column
    subContainer = document.createElement('div');
    subContainer.setAttribute('class', 'collapsed_widget');
    subContainer.setAttribute('id', ilios.cm.lm.generateIdStringForLearningMaterialExpandWidget(containerNumber));
    Event.addListener(subContainer, 'click', function () {
        ilios.cm.lm.setLearningMaterialDivVisibility(containerNumber, this, true);
    });
    labelCol = ilios.dom.createLabelCol(rowElement, subContainer);

    text = document.createTextNode(i18nStr);
    scratchLabel = document.createElement('label');
    scratchLabel.appendChild(text);
    count = document.createElement('span');
    count.setAttribute('id', ilios.cm.lm.generateIdStringForLearningMaterialCount(containerNumber));
    scratchLabel.appendChild(count);
    labelCol.appendChild(scratchLabel);

    //data column
    subContainer = document.createElement('div');
    subContainer.setAttribute('class', 'scroll_list');
    subContainer.setAttribute('style', 'display: none;');
    subSubContainer = document.createElement('ul');
    subSubContainer.setAttribute('class', 'learning_material_list');
    subSubContainer.setAttribute('id', ilios.cm.lm.generateIdStringForLearningMaterialList(containerNumber));
    subContainer.appendChild(subSubContainer);
    dataCol = ilios.dom.createDataCol(rowElement, subContainer);

    //action column
    i18nStr = ilios_i18nVendor.getI18NString('general.terms.add');
    scratchInput = new Element(document.createElement('a'), {href: ''});
    scratchInput.get('element').setAttribute('onclick', 'return false;');
    scratchInput.addClass('tiny radius button');
    scratchInput.addListener('click', function (e) {
        IEvent.fire({
            action: 'alm_dialog_open',
            container_number: containerNumber
        });
    }, null, this);
    text = document.createTextNode(i18nStr);
    scratchInput.appendChild(text);
    ilios.cm.uiElementsToHideOnLockedView.push(scratchInput);
{'fraction_non_alphanumeric': 0.11906753269863866, 'fraction_numerical': 0.007651926327965121, 'mean_word_length': 4.765466297322253, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1890188', 'n_tokens_mistral': 16098, 'n_tokens_neox': 15995, 'n_words': 2251}