qtism / qtism
OAT QTI-SDK
Requires
- php: >=7.4
- ext-date: *
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- ext-simplexml: *
- league/flysystem: ^1.0|2.1.1|^3.0
- league/mime-type-detection: ^1.0
- oat-sa/lib-beeme: 0.2.0
- wp-cli/php-cli-tools: 0.10.3
Requires (Dev)
- phpunit/phpunit: ~9|~7
- squizlabs/php_codesniffer: 3.*
- dev-master
- v19.5.0
- v19.4.2
- v19.4.1
- v19.4.0
- v19.3.0
- 19.2.1
- 19.2.0
- 19.1.0
- 19.0.4
- 19.0.3
- 19.0.2
- 19.0.1
- 19.0.0
- 18.1.1
- 18.1.0
- 18.0.0
- 17.2.0
- 17.1.5
- 17.1.4
- 17.1.3
- 17.1.2
- 17.1.1
- 17.1.0
- 17.0.3
- 17.0.2
- 17.0.1
- 17.0.0
- 16.5.1
- 16.5.0
- 16.4.0
- 16.3.2
- 16.3.1
- 16.3.0
- 16.2.0
- 16.1.10
- 16.1.9
- 16.1.8
- 16.1.7
- 16.1.6
- 16.1.5
- 16.1.4
- 16.1.3
- 16.1.2
- 16.1.1
- 16.1.0
- 16.0.1
- 16.0.0
- 15.0.1
- 15.0.0
- 14.2.0
- 14.1.0
- 14.0.6
- 14.0.5
- 14.0.4
- 14.0.3
- 14.0.2
- 14.0.1
- 14.0.0
- 13.1.1
- 13.1.0
- 13.0.0
- 12.3.4
- 12.3.3
- 12.3.2
- 12.3.0
- 12.2.0
- 12.1.0
- 12.0.0
- 11.5.1
- 11.5.0
- 11.4.0
- 11.3.5
- 11.3.4
- 11.3.3
- 11.3.2
- 11.3.1
- 11.3.0
- 11.2.0
- 11.1.0
- 11.0.0
- 10.0.1
- 10.0.0
- 9.0.2
- 9.0.1
- 9.0.0
- 8.7.2
- 8.7.1
- 8.7.0
- 8.6.4
- 8.6.3
- 8.6.2
- 8.6.1
- 8.6.0
- 8.5.0
- 8.4.0
- 8.3.0
- 8.2.0
- 8.1.0
- 8.0.1
- 8.0.0
- 7.0.0
- 6.0.1
- 6.0.0
- 5.0.11
- 5.0.10
- 5.0.9
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.3.1
- 4.3.0
- 4.2.0
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.1.0
- 4.0.0
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.0
- 1.0.0
- 0.28.6
- 0.28.5
- 0.28.4
- 0.28.3
- 0.28.2
- 0.28.1
- 0.28.0
- 0.27.0
- 0.26.1
- 0.26.0
- 0.25.3
- 0.25.2
- 0.25.1
- 0.25.0
- 0.24.13
- 0.24.12
- 0.24.11
- 0.24.10
- 0.24.9
- 0.24.8
- 0.24.7
- 0.24.6
- 0.24.5
- 0.24.4
- 0.24.3
- 0.24.2
- 0.24.1
- 0.24.0
- 0.23.0
- 0.22.6
- 0.22.5
- 0.22.4
- 0.22.3
- 0.22.2
- 0.22.1
- 0.22.0
- 0.21.0
- 0.20.0
- 0.19.4
- 0.19.3
- 0.19.0
- 0.18.0
- 0.17.1
- 0.17.0
- 0.16.2
- 0.16.1
- 0.16.0
- 0.15.0
- 0.14.1
- 0.14.0
- 0.13.5
- 0.13.4
- 0.13.3
- 0.13.2
- 0.13.1
- 0.13.0
- 0.12.4
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.4
- 0.11.3
- 0.11.2
- 0.11.1
- 0.11.0
- 0.10.29
- 0.10.28
- 0.10.27
- 0.10.26
- 0.10.25
- 0.10.24
- 0.10.23
- 0.10.22
- 0.10.21
- 0.10.20
- 0.10.19
- 0.10.18
- 0.10.17
- 0.10.16
- 0.10.15
- 0.10.14
- 0.10.13
- 0.10.12
- 0.10.11
- 0.10.10
- 0.10.9
- 0.10.8
- 0.10.7
- 0.10.6
- 0.10.5
- 0.10.4
- 0.10.3
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.33
- 0.9.32
- 0.9.31
- 0.9.30
- 0.9.29
- 0.9.28
- 0.9.27
- 0.9.26
- 0.9.25
- 0.9.24
- 0.9.23
- 0.9.21
- 0.9.20
- 0.9.19
- 0.9.18
- 0.9.16
- 0.9.15
- 0.9.14
- 0.9.13
- 0.9.12
- 0.9.11
- 0.9.10
- 0.9.9
- 0.9.8
- 0.9.7
- 0.9.6
- 0.9.5
- 0.9.4
- 0.9.3
- 0.9.2
- 0.9.1
- 0.9.0
- dev-ops-534/actions/checkout
- dev-release-0-28-6
- dev-develop
- dev-fix/sonarqube-workflow-update-ops-184
- dev-feature/LSI-3472/visualize-assessment-test-session
- dev-legacy
- dev-test-oatsd-2994
- dev-feat/TR-5967/debug-sdk-session
- dev-feature/enable-auto-semver-release-action
- dev-feat/RFE-568/branchrules-on-testparts
- dev-feature/add-license-and-copying-file
- dev-feature/tr-5760/support-adaptive-branch-rules
- dev-feat/AUT-3265/twig-compilation-feedback-modals
- dev-release-19.0.2-1
- dev-feat/PISA25-166/proxy-api
This package is auto-updated.
Last update: 2024-08-29 12:23:40 UTC
README
PHP QTI 软件开发套件
IMS QTI (问题 & 测试互操作性) 软件开发套件,支持 PHP 7.0 及更高版本,支持由 IMS QTI 规范家族 描述的广泛功能。
QTI 的此实现正在持续增强。主分支的 API 可能会随时更改。
功能
- 目标 QTI 2.0、2.1 和部分 2.2
- 完整的 QTI 信息模型
- 完整的 QTI 规则引擎支持
- 通过 PSR-0/PSR-4 进行自定义操作钩子
- 威尔伯特·克拉恩的Goldilocks 渲染 / 史蒂夫·莱的 XHTML5 转换
- 在渲染时直接映射到 QTI 信息模型的 CSS 解析器
- 项目和测试会话(具有闪电般的二进制持久性)
- 用于 QTI 文档操作/遍历的简洁 API
- 前置条件 & 分支
- 选择和排序
- 响应、结果和模板处理
- aria-* 属性
- 单元测试驱动
安装(开发者)
- 克隆仓库。
- 确保您了解如何使用 Composer,并且它已安装在本系统上。
- php composer.phar install
- 您已准备好!
单元测试(开发者)
通过以下 shell 命令运行单元测试
cp phpunit.xml.dist phpunit.xml
./vendor/bin/phpunit test
贡献
我们一直在寻找人们为项目提供以下内容
- 错误报告
- 单元测试
- 新功能
QTI 项目会话管理
介绍示例
以下示例演示了如何为给定的 QTI XML 项目文档实例化一个项目会话。在此示例中使用的项目是来自 QTI 2.1 实施指南 的 "水的组成" 项目。
<?php use qtism\common\enums\BaseType; use qtism\common\enums\Cardinality; use qtism\common\datatypes\QtiIdentifier; use qtism\data\storage\xml\XmlDocument; use qtism\runtime\common\State; use qtism\runtime\common\ResponseVariable; use qtism\runtime\common\MultipleContainer; use qtism\runtime\tests\AssessmentItemSession; // Instantiate a new QTI XML document, and load a QTI XML document. $itemDoc = new XmlDocument('2.1'); $itemDoc->load('choice_multiple.xml'); /* * A QTI XML document can be used to load various pieces of QTI content such as assessmentItem, * assessmentTest, responseProcessing, ... components. Our target is an assessmentItem, which is the * root component of our document. */ $item = $itemDoc->getDocumentComponent(); /* * The item session represents the collected and computed data related to the interactions a * candidate performs on a single assessmentItem. As per the QTI specification, "an item session * is the accumulation of all attempts at a particular instance of an assessmentItem made by * a candidate. */ $itemSession = new AssessmentItemSession($item); // The candidate is entering the item session, and is beginning his first attempt. $itemSession->beginItemSession(); $itemSession->beginAttempt(); /* * We instantiate the responses provided by the candidate for this assessmentItem, for the current * item session. For this assessmentItem, the data collected from the candidate is represented by * a State, composed of a single ResponseVariable named 'RESPONSE'. */ $responses = new State( array( // The 'RESPONSE' ResponseVariable has a QTI multiple cardinality, and a QTI identifier baseType. new ResponseVariable( 'RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, /* * The ResponseVariable value is a Container with multiple cardinality and an identifier * baseType to meet the cardinality and baseType requirements of the ResponseVariable. */ new MultipleContainer( BaseType::IDENTIFIER, /* * The values composing the Container are identifiers 'H' and 'O', which represent * the correct response to this item. */ array( new QtiIdentifier('H'), new QtiIdentifier('O') ) ) ) ) ); /* * The candidate is finishing the current attempt, by providing a correct response. * ResponseProcessing takes place to produce a new value for the 'SCORE' OutcomeVariable. */ $itemSession->endAttempt($responses); // The item session variables and their values can be accessed by their identifier. echo 'numAttempts: ' . $itemSession['numAttempts'] . "\n"; echo 'completionStatus: ' . $itemSession['completionStatus'] . "\n"; echo 'RESPONSE: ' . $itemSession['RESPONSE'] . "\n"; echo 'SCORE: ' . $itemSession['SCORE'] . "\n"; /* * numAttempts: 1 * completionStatus: completed * RESPONSE: ['H'; 'O'] * SCORE: 2 */ // End the current item session. $itemSession->endItemSession();
多次尝试示例
根据 QTI 规范,项目会话默认允许单个尝试。尝试开始一个会使项目会话超过最大尝试次数的尝试将导致 PHP 异常,如以下示例所示。
<?php use qtism\data\storage\xml\XmlDocument; use qtism\runtime\common\State; use qtism\runtime\tests\AssessmentItemSession; use qtism\runtime\tests\AssessmentItemSessionException; $itemDoc = new XmlDocument('2.1'); $itemDoc->load('choice_multiple.xml'); $item = $itemDoc->getDocumentComponent(); $itemSession = new AssessmentItemSession($item); $itemSession->beginItemSession(); // Begin 1st attempt. $itemSession->beginAttempt(); // End attempt by providing an empty response... $itemSession->endAttempt(new State()); // Begin 2nd attempt, but by default, maximum number of attempts is 1. try { $itemSession->beginAttempt(); } catch (AssessmentItemSessionException $e) { echo $e->getMessage(); // A new attempt for item 'choiceMultiple' is not allowed. The maximum number of attempts (1) is reached. }
如果允许在给定的评估项上多次尝试,则可以将 itemSessionControl 的 maxAttempts 属性修改为允许多次或无限次尝试,候选人可以执行。
<?php use qtism\data\ItemSessionControl; use qtism\data\storage\xml\XmlDocument; use qtism\runtime\common\State; use qtism\runtime\tests\AssessmentItemSession; $itemDoc = new XmlDocument('2.1'); $itemDoc->load('choice_multiple.xml'); $item = $itemDoc->getDocumentComponent(); $itemSession = new AssessmentItemSession($item); // Set the maximum number of attempts to 0 (means unlimited). $itemSessionControl = new ItemSessionControl(); $itemSessionControl->setMaxAttempts(0); $itemSession->setItemSessionControl($itemSessionControl); // Performing multiple attempts will not lead to a PHP exception anymore, because the maximum number of attemps is unlimited! $itemSession->beginItemSession(); // 1st attempt will be an incorrect response from the candidate (['H'; 'Cl']). $responses = new State( array( new ResponseVariable( 'RESPONSE', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer( BaseType::IDENTIFIER, array( new QtiIdentifier('H'), new QtiIdentifier('Cl') ) ) ) ) ); $itemSession->endAttempt($responses); echo 'numAttempts: ' . $itemSession['numAttempts'] . "\n"; echo 'completionStatus: ' . $itemSession['completionStatus'] . "\n"; echo 'RESPONSE: ' . $itemSession['RESPONSE'] . "\n"; echo 'SCORE: ' . $itemSession['SCORE'] . "\n"; /* * numAttempts: 1 * completionStatus: completed * RESPONSE: ['H'; 'N'] * SCORE: 0 */ // 2nd attempt will send a correct response this time (['H'; 'O'])! $itemSession->beginAttempt(); $responses['RESPONSE'][1]->setValue('O'); $itemSession->endAttempt(); echo 'numAttempts: ' . $itemSession['numAttempts'] . "\n"; echo 'completionStatus: ' . $itemSession['completionStatus'] . "\n"; echo 'RESPONSE: ' . $itemSession['RESPONSE'] . "\n"; echo 'SCORE: ' . $itemSession['SCORE'] . "\n"; /* * numAttempts: 2 * completionStatus: completed * RESPONSE: ['H'; 'O'] * SCORE: 2 */ $itemSession->endItemSession();
您可以在 QTI-SDK GitHub Wiki 上获取更多信息!
QTI 渲染
QTI 软件开发套件允许您将 XML 序列化的 QTI 文件转换为它们的 (X)HTML5 Goldilocks 相当物。以下 shell 命令使用具有缩进格式的 (X)HTML5 Golidlocks 渲染风格将 path/to/qti.xml QTI 文件渲染为 HTML5 文档。渲染输出(stdout)重定向到 /home/jerome/qti.html 文件。
./vendor/bin/qtisdk render -df --source path/to/qti.xml --flavour goldilocks > /home/jerome/qti.html
有关更多帮助和信息,只需调用帮助屏幕即可了解渲染二进制文件提供的功能!
./vendor/bin/qtisdk render --help
配置
对于其他主要的PHP框架,例如Doctrine QTI-SDK使用注解。在这种情况下,以下两个Zend Opcache配置指令必须按照以下方式配置。
