public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/import.php
/**
		 * Extract details from the XML that associates a single question with a quiz. The full details
		 * of the question have already been extracted by this point. So this is just the data that maps
		 * a question (or random quiz selection) to a specific quiz.
		 *
		 * @param String $singleQuestion The details of the question to extract.
		 */
Extract details from the XML that associates a single question with a quiz. The full details
of the question have already been extracted by this point. So this is just the data that maps
a question (or random quiz selection) to a specific quiz.

@param String $singleQuestion The details of the question to extract.
Extract details from the XML that associates a single question with a quiz . The full details of the question have already been extracted by this point . So this is just the data that maps a question ( or random quiz selection ) to a specific quiz . @param String $singleQuestion The details of the question to extract .
private function loadQuestionData_quizMappingData( $singleQuestion ) {
			$fieldsToProcess = array(
				'question_type',
				'question_hash',
				'question_order',
				'question_type',
			);
			$dbdata = array();
			foreach ( $fieldsToProcess as $fieldName ) {
				$dbdata[ $fieldName ] = ( isset( $singleQuestion->$fieldName ) ? (string) $singleQuestion->$fieldName : '' );
				$dbdata[ $fieldName ] = html_entity_decode( $dbdata[ $fieldName ], ENT_QUOTES );
			}
			if ( isset( $singleQuestion->tag_selections ) && isset( $singleQuestion->tag_selections->tag_selection[0] ) ) {
				$dbdata['tag_selections'] = array();
				foreach ( $singleQuestion->tag_selections->tag_selection as $singleTag ) {
					$count = intval( (string) WPCW_arrays_getValue( $singleTag, 'count' ) );
					$tagName = html_entity_decode( (string) $singleTag, ENT_QUOTES );
					$dbdata['tag_selections'][ $tagName ] = $count;
				}
			}
			$dbdata['question_real_id'] = false;
			if ( $dbdata['question_hash'] ) {
				$dbdata['question_real_id'] = WPCW_arrays_getValue( $this->questionData, $dbdata['question_hash'] );
			}
			return $dbdata;
		}
private function loadQuestionData_quizMappingData ( $ singleQuestion ) { $ fieldsToProcess = array ( 'question_type' , 'question_hash' , 'question_order' , 'question_type' , ) ; $ dbdata = array ( ) ; foreach ( $ fieldsToProcess as $ fieldName ) { $ dbdata [ $ fieldName ] = ( isset ( $ singleQuestion -> $ fieldName ) ? ( string ) $ singleQuestion -> $ fieldName : '' ) ; $ dbdata [ $ fieldName ] = html_entity_decode ( $ dbdata [ $ fieldName ] , ENT_QUOTES ) ; } if ( isset ( $ singleQuestion -> tag_selections ) && isset ( $ singleQuestion -> tag_selections -> tag_selection [ 0 ] ) ) { $ dbdata [ 'tag_selections' ] = array ( ) ; foreach ( $ singleQuestion -> tag_selections -> tag_selection as $ singleTag ) { $ count = intval ( ( string ) WPCW_arrays_getValue ( $ singleTag , 'count' ) ) ; $ tagName = html_entity_decode ( ( string ) $ singleTag , ENT_QUOTES ) ; $ dbdata [ 'tag_selections' ] [ $ tagName ] = $ count ; } } $ dbdata [ 'question_real_id' ] = false ; if ( $ dbdata [ 'question_hash' ] ) { $ dbdata [ 'question_real_id' ] = WPCW_arrays_getValue ( $ this -> questionData , $ dbdata [ 'question_hash' ] ) ; } return $ dbdata ; }
Extract details from the XML that associates a single question with a quiz.
Extract details from the XML that associates a single question with a quiz .
/*
			<questions>
				<question>
					<question_type><![CDATA[fixed]]></question_type>
					<question_hash><![CDATA[wpcwqid_1]]></question_hash>
					<question_order><![CDATA[1]]></question_order>
				</question>
				<question>
					<question_type><![CDATA[fixed]]></question_type>
					<question_hash><![CDATA[wpcwqid_3]]></question_hash>
					<question_order><![CDATA[2]]></question_order>
				</question>
				<question>
					<question_type><![CDATA[fixed]]></question_type>
					<question_hash><![CDATA[wpcwqid_5]]></question_hash>
					<question_order><![CDATA[3]]></question_order>
				</question>
			</questions>

			<questions>
				<question>
					<question_type><![CDATA[random_selection]]></question_type>
					<question_order><![CDATA[1]]></question_order>
					<tag_selections>
						<tag_selection count="4"><![CDATA[Dan Test 2]]></tag_selection>
						<tag_selection count="1"><![CDATA[Nate&#039;s Tag]]></tag_selection>
					</tag_selections>
				</question>
				<question>
					<question_type><![CDATA[fixed]]></question_type>
					<question_hash><![CDATA[wpcwqid_7]]></question_hash>
					<question_order><![CDATA[2]]></question_order>
				</question>
				<question>
					<question_type><![CDATA[random_selection]]></question_type>
					<question_order><![CDATA[3]]></question_order>
					<tag_selections>
						<tag_selection count="2"><![CDATA[whole_pool]]></tag_selection>
					</tag_selections>
				</question>
			</questions>
			*/ // ### 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 any tag selections for random questions // Need selection count - <tag_selection count="4"><![CDATA[Tag Name]]></tag_selection> // Use html_entity_decode to remove HTML entities. // Add to list of clean tags // ### 3 - Attempt to get the real ID of the question now that it's been added to the database and it // 		   should have a database ID.