Serialize the options in peer instruction XBlock to xml

    Args:
        options (lxml.etree.Element): The <options> XML element.
        block (PeerInstructionXBlock): The XBlock with configuration to serialize.

    Returns:
        None
558626
def serialize_options(options, block):
    
    for index, option_dict in enumerate(block.options):
        option = etree.SubElement(options, 'option')
        # set correct option and rationale
        if index == block.correct_answer:
            option.set('correct', u'True')

            if hasattr(block, 'correct_rationale'):
                rationale = etree.SubElement(option, 'rationale')
                rationale.text = block.correct_rationale['text']

        text = etree.SubElement(option, 'text')
        text.text = option_dict.get('text', '')

        serialize_image(option_dict, option)
541174
def save_and_respond(resource, options={}, &block)
      creation = resource.new_record?
      resource.attributes = options[:attributes] unless options[:attributes].nil?
      respond_to do |format|
        # if ((block_given? and block.arity == 1) ? yield(resource) : (block_given? and block.arity == 2) ? yield(resource, format) : resource.save)
        if (block_given? ? yield(resource, format) : resource.save)
          status = (creation ? :created : :ok)
          response.headers["X-Return-Code"] = "success"
          response.headers["X-Saved-Record-Id"] = resource.id.to_s
          format.html { params[:dialog] ? head(status) : redirect_to(options[:url] || resource) }
          format.json { render :json => resource.to_json, :status => status, :location => resource}
          format.xml  { render  :xml => resource.to_xml,  :status => status, :location => resource }
        else
          response.headers["X-Return-Code"] = "invalid"
          format.html { render :action => (resource.new_record? ? "new" : "edit")}
          format.json { render :json => resource.errors.to_json, :status => :unprocessable_entity }
          format.xml  { render  :xml => resource.errors.to_xml,  :status => :unprocessable_entity }
        end
      end
    end
449894
def serialize_on_parent(
            self,
            parent,  # type: ET.Element
            value,  # type: Any
            state  # type: _ProcessorState
    ):
        # type: (...) -> None
        """"""
        dict_value = self._converter.to_dict(value)
        self._dictionary.serialize_on_parent(parent, dict_value, state)
1279307
def to_xml(options = {})
      builder = options[:builder] || XML.new("<#{self.class.member_name}/>")
      xml_keys.each { |key|
        value = respond_to?(key) ? send(key) : self[key]
        node = builder.add_element key

        # Duck-typing here is problematic because of ActiveSupport's #to_xml.
        case value
        when Resource, Subscription::AddOns
          value.to_xml options.merge(:builder => node)
        when Array
          value.each do |e|
            if e.is_a? Recurly::Resource
              # create a node to hold this resource
              e_node = node.add_element Helper.singularize(key)
              # serialize the resource into this node
              e.to_xml(options.merge(builder: e_node))
            else
              # it's just a primitive value
              node.add_element(Helper.singularize(key), e)
            end
          end
        when Hash, Recurly::Money
          value.each_pair { |k, v| node.add_element k.to_s, v }
        else
          node.text = value
        end
      }
      builder.to_s
    end
982162
function(options) {
        var doc             = node.ownerDocument,
          nextSibling     = wysihtml5.dom.domNode(node).next({ignoreBlankTexts: true}),
          previousSibling = wysihtml5.dom.domNode(node).prev({ignoreBlankTexts: true});

        if (nextSibling && !_isLineBreakOrBlockElement(nextSibling)) {
          wysihtml5.dom.insert(doc.createElement("br")).after(node);
        }
        if (previousSibling && !_isLineBreakOrBlockElement(previousSibling)) {
          wysihtml5.dom.insert(doc.createElement("br")).before(node);
        }
      }
1195916
function(options) {
        var node = this.writeNode("csw:GetDomain", options);
        return OpenLayers.Format.XML.prototype.write.apply(this, [node]);
    }
742043
def serialize_on_parent(
            self,
            parent,  # type: ET.Element
            value,  # type: Any
            state  # type: _ProcessorState
    ):
        # type: (...) -> None
        """"""
        xml_value = _hooks_apply_before_serialize(self._hooks, state, value)
        self._processor.serialize_on_parent(parent, xml_value, state)
79473
def to_element(self):
        
        if not self.protocol_info:
            raise DIDLMetadataError('Could not create Element for this'
                                    'resource:'
                                    'protocolInfo not set (required).')
        root = XML.Element('res')

        # Required
        root.attrib['protocolInfo'] = self.protocol_info
        # Optional
        if self.import_uri is not None:
            root.attrib['importUri'] = self.import_uri
        if self.size is not None:
            root.attrib['size'] = str(self.size)
        if self.duration is not None:
            root.attrib['duration'] = self.duration
        if self.bitrate is not None:
            root.attrib['bitrate'] = str(self.bitrate)
        if self.sample_frequency is not None:
            root.attrib['sampleFrequency'] = str(self.sample_frequency)
        if self.bits_per_sample is not None:
            root.attrib['bitsPerSample'] = str(self.bits_per_sample)
        if self.nr_audio_channels is not None:
            root.attrib['nrAudioChannels'] = str(self.nr_audio_channels)
        if self.resolution is not None:
            root.attrib['resolution'] = self.resolution
        if self.color_depth is not None:
            root.attrib['colorDepth'] = str(self.color_depth)
        if self.protection is not None:
            root.attrib['protection'] = self.protection

        root.text = self.uri
        return root
764145
def prepare_update_xml(options = {})
      r = ["<add#{options.to_xml_attribute_string}>\n"]
      # copy and clear pending docs
      working_docs, @pending_documents = @pending_documents, nil
      working_docs.each { |doc| r << doc.xml }
      r << "\n</add>\n"
      r.join # not sure, but I think Array#join is faster then String#<< for large buffers
    end
741936
def htmlCtxtUseOptions(self, options):
        
        ret = libxml2mod.htmlCtxtUseOptions(self._o, options)
        return ret
1212493
def to_xml(options = {})
      doc = Nokogiri::XML::Document.new
      root = doc.create_element(tag_name)
      self.class.keys.each do |name|
        value = read_attribute(name)
        next if value.blank?
        root[name.to_s.camelize] = value
      end
      self.class.elements.each do |name, field|
        next if options[:only] && !options[:only].include?(name)
        next if field.options[:readonly]
        value = read_attribute(name)
        next if field.type.is_a?(Array) && value.blank?
        next if new_record? && field.type == Identifier
        next if new_record? && value.blank?
        if name == :text
          root << value.to_s
        else
          root << field.to_xml(value)
        end
      end
      root
    end
1159474
def _serialize_xml(self, root):
        
        if hasattr(etree, 'tostringlist'):
            if six.PY3:
                xml_content_list = [
                    x.decode("utf-8") for x in etree.tostringlist(root)]
            else:
                xml_content_list = etree.tostringlist(root)

            xml = '\r\n'.join(xml_content_list) + '\r\n'
        else:
            if six.PY3:
                xml_content = etree.tostring(root).decode("utf-8")
            else:
                xml_content = etree.tostring(root)
            xml = xml_content + '\r\n'
        return xml
821632
def export_to_xml(self, block, xmlfile):
        
        root = etree.Element("unknown_root", nsmap=XML_NAMESPACES)
        tree = etree.ElementTree(root)
        block.add_xml_to_node(root)
        # write asides as children
        for aside in self.get_asides(block):
            if aside.needs_serialization():
                aside_node = etree.Element("unknown_root", nsmap=XML_NAMESPACES)
                aside.add_xml_to_node(aside_node)
                block.append(aside_node)
        tree.write(xmlfile, xml_declaration=True, pretty_print=True, encoding='utf-8')
664669
function PeerOptions(options) {
  if (!(this instanceof PeerOptions))
    return new PeerOptions(options);

  this.network = Network.primary;
  this.logger = Logger.global;

  this.createSocket = tcp.createSocket;
  this.version = common.PROTOCOL_VERSION;
  this.services = common.LOCAL_SERVICES;
  this.agent = common.USER_AGENT;
  this.noRelay = false;
  this.spv = false;
  this.compact = false;
  this.headers = false;
  this.banScore = common.BAN_SCORE;

  this.getHeight = PeerOptions.getHeight;
  this.isFull = PeerOptions.isFull;
  this.hasWitness = PeerOptions.hasWitness;
  this.createNonce = PeerOptions.createNonce;
  this.hasNonce = PeerOptions.hasNonce;
  this.getRate = PeerOptions.getRate;

  if (options)
    this.fromOptions(options);
}
1319682
def to_html
      output_options = Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^
        Nokogiri::XML::Node::SaveOptions::FORMAT
      @fragment.children.inject("") do |out, child|
        out << child.serialize(:save_with => output_options, :encoding => 'UTF-8')
      end
    end
48935
def serialize(node, stream=None, Dumper=Dumper, **kwds):
    
    return serialize_all([node], stream, Dumper=Dumper, **kwds)
459008
def parse_options(cls, options):
        
        options = options.copy()
        subdomain = options.pop('subdomain', None)
        endpoint = options.pop('endpoint', None)
        return subdomain, endpoint, options,