当前位置: 首页>>代码示例>>PHP>>正文


PHP Exercise::randSubExercise方法代码示例

本文整理汇总了PHP中Exercise::randSubExercise方法的典型用法代码示例。如果您正苦于以下问题:PHP Exercise::randSubExercise方法的具体用法?PHP Exercise::randSubExercise怎么用?PHP Exercise::randSubExercise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exercise的用法示例。


在下文中一共展示了Exercise::randSubExercise方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

function main() {
	$collection_id = 376317; # olpc dictionary.... WAY too big

	$fetcher = new OWFetcher();
	echo "fullset...\n";
	$fullSetXML = $fetcher->getFullSetXML_asString( $collection_id );

	$fullSet = new DOMDocument();
	$success = $fullSet->loadXML( $fullSetXML );
	if ( !$success ) {
		throw new Exception( "Failed to load category XML from server" );
	}

	$maxSubSet = dom2set( $fullSet );
	# sort($maxSubSet); foreach ($maxSubSet as $dmid) {print "$dmid,";}


	# var_dump($fullSet->saveXML());
	$exercise = new Exercise( $fetcher, $fullSet, $maxSubSet ); # pwease, not the max!
	# $exercise->setLanguages(array("eng","fra","deu"));
	$exercise->setQuestionLanguages( array( "deu" ) );
	$exercise->setAnswerLanguages( array( "eng" ) );

	# $question_dmid=$maxSubSet[array_rand($maxSubSet)];
	echo "question...\n";
	# $questionNode=$exercise->getQuestionNode($question_dmid);

	# dumpNode($questionNode);
	$runex = $exercise->randSubExercise( 10 );
	dumpExercise( $runex, 5 );

	echo "\n\n=== presistence test ===\n\n";
	saveExercise( $runex );
	$exid = mysql_insert_id();
	$loadex = loadExercise( $exid );
	$loadex->setFetcher( $fetcher );
	dumpExercise( $loadex, 10 );

}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:39,代码来源:test.php

示例2: createExercise

	/** create a new Exercise from scratch.
	# */
	public function createExercise( $userName, $size, $collection_id, $questionLanguages, $answerLanguages, $hide ) {

		# this can be simplified for now...
		# first get a master exercise...
		$fetcher = new OWFetcher();
		$fullSetXML = $fetcher->getFullSetXML_asString( $collection_id, array_merge( $questionLanguages, $answerLanguages ) );
		$fullSet = new DOMDocument();
		$success = $fullSet->loadXML( $fullSetXML );
		if ( !$success ) {
			throw new Exception( "Failed to load category XML from server" );
		}

		$exercise = new Exercise( $fetcher, $fullSet );
		$exercise->setQuestionLanguages( $questionLanguages );
		$exercise->setAnswerLanguages( $answerLanguages );
		$exercise->setHide( $hide );

		# This is the master exercise... which we should now store and 
		# worship. That's for mark II though. 
		# Today we toss it in the trash and just snarf a
		# subset instead. Mean huh?

		$subExercise = $exercise->randSubExercise( $size );
		$this->saveExercise( $subExercise, $userName );
		return $subExercise;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:28,代码来源:model.php


注:本文中的Exercise::randSubExercise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。