public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/import.php
/**
		 * Extract details from the XML for this single question.
		 *
		 * @param String $singleQuestion The details of the question to extract.
		 */
Extract details from the XML for this single question.
@param String $singleQuestion The details of the question to extract.
Extract details from the XML for this single question . @param String $singleQuestion The details of the question to extract .
private function loadQuestionData_fullData( $singleQuestion ) {
			global $fieldsToProcess_quiz_questions;
			$dbdata = array();
			foreach ( $fieldsToProcess_quiz_questions as $fieldName ) {
				$dbdata[ $fieldName ] = ( isset( $singleQuestion->$fieldName ) ? (string) $singleQuestion->$fieldName : '' );
				$dbdata[ $fieldName ] = html_entity_decode( $dbdata[ $fieldName ], ENT_QUOTES );
			}
			$dbdata['question_data_answers'] = array();
			if ( isset( $singleQuestion->question_data_answers ) && ! empty( $singleQuestion->question_data_answers ) ) {
				$i = 1;
				$possibleAnswerField = 'possible_answer_' . $i;
				while ( isset( $singleQuestion->question_data_answers->$possibleAnswerField ) ) {
					$dbdata['question_data_answers'][ $i ] = array( 'answer' => (string) $singleQuestion->question_data_answers->$possibleAnswerField );
					$possibleAnswerField_image = $possibleAnswerField . '_image';
					if ( isset( $singleQuestion->question_data_answers->$possibleAnswerField_image ) ) {
						$dbdata['question_data_answers'][ $i ]['image'] = (string) $singleQuestion->question_data_answers->$possibleAnswerField_image;
					}
					$i ++;
					$possibleAnswerField = 'possible_answer_' . $i;
				}
			}
			if ( isset( $singleQuestion->tags ) && isset( $singleQuestion->tags->tag[0] ) ) {
				$dbdata['tags'] = array();
				foreach ( $singleQuestion->tags->tag as $singleTag ) {
					$tagName = (string) $singleTag;
					$tagName = html_entity_decode( $tagName, ENT_QUOTES );
					$dbdata['tags'][] = $tagName;
				}
			}
			if ( ! isset( $dbdata['question_author'] ) ) {
				$dbdata['question_author'] = get_current_user_id();
			}
			return $dbdata;
		}
private function loadQuestionData_fullData ( $ singleQuestion ) { global $ fieldsToProcess_quiz_questions ; $ dbdata = array ( ) ; foreach ( $ fieldsToProcess_quiz_questions as $ fieldName ) { $ dbdata [ $ fieldName ] = ( isset ( $ singleQuestion -> $ fieldName ) ? ( string ) $ singleQuestion -> $ fieldName : '' ) ; $ dbdata [ $ fieldName ] = html_entity_decode ( $ dbdata [ $ fieldName ] , ENT_QUOTES ) ; } $ dbdata [ 'question_data_answers' ] = array ( ) ; if ( isset ( $ singleQuestion -> question_data_answers ) && ! empty ( $ singleQuestion -> question_data_answers ) ) { $ i = 1 ; $ possibleAnswerField = 'possible_answer_' . $ i ; while ( isset ( $ singleQuestion -> question_data_answers -> $ possibleAnswerField ) ) { $ dbdata [ 'question_data_answers' ] [ $ i ] = array ( 'answer' => ( string ) $ singleQuestion -> question_data_answers -> $ possibleAnswerField ) ; $ possibleAnswerField_image = $ possibleAnswerField . '_image' ; if ( isset ( $ singleQuestion -> question_data_answers -> $ possibleAnswerField_image ) ) { $ dbdata [ 'question_data_answers' ] [ $ i ] [ 'image' ] = ( string ) $ singleQuestion -> question_data_answers -> $ possibleAnswerField_image ; } $ i ++ ; $ possibleAnswerField = 'possible_answer_' . $ i ; } } if ( isset ( $ singleQuestion -> tags ) && isset ( $ singleQuestion -> tags -> tag [ 0 ] ) ) { $ dbdata [ 'tags' ] = array ( ) ; foreach ( $ singleQuestion -> tags -> tag as $ singleTag ) { $ tagName = ( string ) $ singleTag ; $ tagName = html_entity_decode ( $ tagName , ENT_QUOTES ) ; $ dbdata [ 'tags' ] [ ] = $ tagName ; } } if ( ! isset ( $ dbdata [ 'question_author' ] ) ) { $ dbdata [ 'question_author' ] = get_current_user_id ( ) ; } return $ dbdata ; }
Extract details from the XML for this single question.
Extract details from the XML for this single question .
// ### 1 - Load main fields // Put data into database, but assume data is blank if not set in XML. // Use html_entity_decode to remove HTML entities. // ### 2 - Load question_data_answers // Need to extract the values from the question // SimpleXMLElement Object ( // [possible_answer_1] => SimpleXMLElement Object // [possible_answer_2] => SimpleXMLElement Object // ) // It's assumed that the possible_answer numbers are in numerical order starting at 1. // This is reasonable if we did the export. // Need to create variable for use in the loop // Copy answer accross. (<possible_answer_1><![CDATA[UGlnZ3k=]]></possible_answer_1>) // Is there an image for this particular answer too?
 // e.g. <possible_answer_1_image>URL goes here...</possible_answer_1_image> // Try next entry // ### 3 - Load tags // Check for units in this module // Here, we're just converting the tag name to a string // Use html_entity_decode to remove HTML entities. // Add to list of clean tags // ### 4 - Load Question author if not set.