我在moodle中看到了这个功能,他们上传 .txt 文件并解析数据并创建问题库。有些问题也有三个选项
样本 :-
What is php?
A. Php is a language.
B. Php creates HTML.
C. Php is fun.
D. none of these.
ANSWER: D
Which is YII-2?
A. Framework.
B. Tool.
C. None of these
ANSWER: A
到目前为止,我已经尝试过解析它,但我不知道要实现批量上传到底要做什么。
txt_file = file_get_contents('path/to/file.txt');
$rows = explode("\n", $txt_file);
array_shift($rows);
foreach($rows as $row => $data)
{
}
我正在尝试获取的数组
[
[
'question' => 'Php is a language.',
'options' => [
'A' => 'Php is a language.',
'B' => 'Php creates HTML.',
'C' => 'Php is fun.',
'D' => 'none of these.'
],
'answer' => 'D'
],
.....
]
示例文件:-文件代码fbSObnlghQkqroEk4lrQ
元芳怎么了