public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/import.php
/**
		 * Extract details from the XML for this single quiz (that's associated with a single unit).
		 */
Extract details from the XML for this single quiz (that's associated with a single unit).
Extract details from the XML for this single quiz ( that ' s associated with a single unit ) .
private function loadQuizData_Single( $singleQuiz ) {
			global $fieldsToProcess_quizzes;
			$dbdata = array();
			foreach ( $fieldsToProcess_quizzes as $fieldName ) {
				$dbdata[ $fieldName ] = ( isset( $singleQuiz->$fieldName ) ? (string) $singleQuiz->$fieldName : '' );
				$dbdata[ $fieldName ] = html_entity_decode( $dbdata[ $fieldName ], ENT_QUOTES );
			}
			global $fieldsToProcess_quizzes_inner__show_answers_settings;
			$dbdata['show_answers_settings'] = array();
			foreach ( $fieldsToProcess_quizzes_inner__show_answers_settings as $innerName => $validValueList ) {
				reset( $validValueList );
				$valueForSettingFromXML = current( $validValueList );
				if ( isset( $singleQuiz->show_answers_settings->$innerName ) ) {
					$valueFound = (string) $singleQuiz->show_answers_settings->$innerName;
					if ( in_array( $valueFound, $validValueList ) ) {
						$valueForSettingFromXML = $valueFound;
					}
				}
				$dbdata['show_answers_settings'][ $innerName ] = $valueForSettingFromXML;
			}
			global $fieldsToProcess_quizzes_inner__quiz_paginate_questions_settings;
			$dbdata['quiz_paginate_questions_settings'] = array();
			foreach ( $fieldsToProcess_quizzes_inner__quiz_paginate_questions_settings as $innerName => $validValueList ) {
				reset( $validValueList );
				$valueForSettingFromXML = current( $validValueList );
				if ( isset( $singleQuiz->quiz_paginate_questions_settings->$innerName ) ) {
					$valueFound = (string) $singleQuiz->quiz_paginate_questions_settings->$innerName;
					if ( in_array( $valueFound, $validValueList ) ) {
						$valueForSettingFromXML = $valueFound;
					}
				}
				$dbdata['quiz_paginate_questions_settings'][ $innerName ] = $valueForSettingFromXML;
			}
			if ( isset( $singleQuiz->questions ) && isset( $singleQuiz->questions->question[0] ) ) {
				$dbdata['questions'] = array();
				foreach ( $singleQuiz->questions->question as $singleQuestion ) {
					$dbdata['questions'][] = $this->loadQuestionData_quizMappingData( $singleQuestion );
				}
			} else {
				$dbdata['questions'] = false;
			}
			if ( isset( $singleQuiz->custom_feedback_msgs ) && isset( $singleQuiz->custom_feedback_msgs->custom_feedback_msg[0] ) ) {
				$dbdata['custom_feedback'] = array();
				foreach ( $singleQuiz->custom_feedback_msgs->custom_feedback_msg as $singleFeedbackMsg ) {
					$dbdata['custom_feedback'][] = $this->loadQuizData_customFeedback( $singleFeedbackMsg );
				}
			} else {
				$dbdata['custom_feedback'] = false;
			}
			return $dbdata;
		}
private function loadQuizData_Single ( $ singleQuiz ) { global $ fieldsToProcess_quizzes ; $ dbdata = array ( ) ; foreach ( $ fieldsToProcess_quizzes as $ fieldName ) { $ dbdata [ $ fieldName ] = ( isset ( $ singleQuiz -> $ fieldName ) ? ( string ) $ singleQuiz -> $ fieldName : '' ) ; $ dbdata [ $ fieldName ] = html_entity_decode ( $ dbdata [ $ fieldName ] , ENT_QUOTES ) ; } global $ fieldsToProcess_quizzes_inner__show_answers_settings ; $ dbdata [ 'show_answers_settings' ] = array ( ) ; foreach ( $ fieldsToProcess_quizzes_inner__show_answers_settings as $ innerName => $ validValueList ) { reset ( $ validValueList ) ; $ valueForSettingFromXML = current ( $ validValueList ) ; if ( isset ( $ singleQuiz -> show_answers_settings -> $ innerName ) ) { $ valueFound = ( string ) $ singleQuiz -> show_answers_settings -> $ innerName ; if ( in_array ( $ valueFound , $ validValueList ) ) { $ valueForSettingFromXML = $ valueFound ; } } $ dbdata [ 'show_answers_settings' ] [ $ innerName ] = $ valueForSettingFromXML ; } global $ fieldsToProcess_quizzes_inner__quiz_paginate_questions_settings ; $ dbdata [ 'quiz_paginate_questions_settings' ] = array ( ) ; foreach ( $ fieldsToProcess_quizzes_inner__quiz_paginate_questions_settings as $ innerName => $ validValueList ) { reset ( $ validValueList ) ; $ valueForSettingFromXML = current ( $ validValueList ) ; if ( isset ( $ singleQuiz -> quiz_paginate_questions_settings -> $ innerName ) ) { $ valueFound = ( string ) $ singleQuiz -> quiz_paginate_questions_settings -> $ innerName ; if ( in_array ( $ valueFound , $ validValueList ) ) { $ valueForSettingFromXML = $ valueFound ; } } $ dbdata [ 'quiz_paginate_questions_settings' ] [ $ innerName ] = $ valueForSettingFromXML ; } if ( isset ( $ singleQuiz -> questions ) && isset ( $ singleQuiz -> questions -> question [ 0 ] ) ) { $ dbdata [ 'questions' ] = array ( ) ; foreach ( $ singleQuiz -> questions -> question as $ singleQuestion ) { $ dbdata [ 'questions' ] [ ] = $ this -> loadQuestionData_quizMappingData ( $ singleQuestion ) ; } } else { $ dbdata [ 'questions' ] = false ; } if ( isset ( $ singleQuiz -> custom_feedback_msgs ) && isset ( $ singleQuiz -> custom_feedback_msgs -> custom_feedback_msg [ 0 ] ) ) { $ dbdata [ 'custom_feedback' ] = array ( ) ; foreach ( $ singleQuiz -> custom_feedback_msgs -> custom_feedback_msg as $ singleFeedbackMsg ) { $ dbdata [ 'custom_feedback' ] [ ] = $ this -> loadQuizData_customFeedback ( $ singleFeedbackMsg ) ; } } else { $ dbdata [ 'custom_feedback' ] = false ; } return $ dbdata ; }
Extract details from the XML for this single quiz (that's associated with a single unit).
Extract details from the XML for this single quiz ( that ' s associated with a single unit ) .
// ### 1 - Extract fields we want // Put data into database, but assume data is blank if not set in XML. // Use html_entity_decode to remove HTML entities. // ### 2 - Inner - show_answers_settings // Set the default value for this field, just in case it doesn't appear in the XML // Check value is set.... // And that it's valid (i.e. in the list of possible values). // Use the found value or the default and update the setting. // ### 3 - Inner - quiz_paginate_questions_settings // Set the default value for this field, just in case it doesn't appear in the XML // Check value is set.... // And that it's valid (i.e. in the list of possible values). // Use the found value or the default and update the setting. // ### 4 - Questions - translate into a mapping /*
			<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>
			*/ // ### 5 - Custom Feedback - translate ready to use. Assume tags loaded by the time we get here.