Beispiel #1
0
// Add a binary option for a selection answer
func (question *QuestionForm) AddSelectionAnswerBinarySelection(
	selectionIdentifier, mimeType, mimeSubType string,
	dataURL *url.URL, altText string) {
	answer := question.getCurrentAnswer()
	if answer.SelectionAnswer == nil {
		answer.SelectionAnswer = &questionform.TSelectionAnswerType{}
	}
	if answer.SelectionAnswer.Selections == nil {
		answer.SelectionAnswer.Selections = &questionform.TxsdSelectionAnswerTypeSequenceSelections{}
	}
	selection := &questionform.TxsdSelectionAnswerTypeSequenceSelectionsSequenceSelection{}
	selection.SelectionIdentifier = xsdt.String(selectionIdentifier)
	selection.Binary = &questionform.TBinaryContentType{}
	if mimeType != "" || mimeSubType != "" {
		selection.Binary.MimeType = &questionform.TMimeType{}
		if mimeType != "" {
			selection.Binary.MimeType.Type = questionform.TxsdMimeTypeSequenceType(mimeType)
		}
		if mimeSubType != "" {
			selection.Binary.MimeType.SubType = xsdt.String(mimeSubType)
		}
	}
	selection.Binary.DataURL = questionform.TURLType(dataURL.String())
	if altText != "" {
		selection.Binary.AltText = xsdt.String(altText)
	}
	answer.SelectionAnswer.Selections.Selections = append(
		answer.SelectionAnswer.Selections.Selections, selection)
}
Beispiel #2
0
// Add a Binary item to the most recent Question/Overview added.
func (question *QuestionForm) AddBinaryContent(mimeType, mimeSubType string,
	dataURL *url.URL, altText string) {
	binary := &questionform.TBinaryContentType{}
	if mimeType != "" || mimeSubType != "" {
		binary.MimeType = &questionform.TMimeType{}
		if mimeType != "" {
			binary.MimeType.Type = questionform.TxsdMimeTypeSequenceType(mimeType)
		}
		if mimeSubType != "" {
			binary.MimeType.SubType = xsdt.String(mimeSubType)
		}
	}
	binary.DataURL = questionform.TURLType(dataURL.String())
	if altText != "" {
		binary.AltText = xsdt.String(altText)
	}

	content := question.getCurrentContent()
	content.Binaries = append(content.Binaries, binary)
}