隨機測驗工具
目的:
- 一份試題,可隨機測驗。
設定:
- 建立試題目錄
- 將試題拆解成每題一個檔案,檔名為 [題號].txt。
- 試題檔最後一行為解答。
- 所有試題檔均在試題目錄之下。
- 執行 Quiz.pl [試題目錄]。
使用:
- 輸入 [答案] 或
- 輸入 [Q/q] 結束程式
- 輸入 [#] 顯示試題檔名
- 輸入 [?] 顯示答案
#!/usr/bin/perl
use List::Util 'shuffle';
chdir($ARGV[0]);
@quizFiles = <*.txt>;
@myQuiz = shuffle(@quizFiles);
$done = 0;
foreach $quizFile (@myQuiz) {
system("clear");
open(QUIZ, $quizFile);
@quizData = <QUIZ>;
close(QUIZ);
$myAnswer = "";
$quizAnswer = pop(@quizData);
chomp($quizAnswer);
$quizAnswer = lc($quizAnswer);
$hasShow = 0;
$hasShown = 0;
while ($quizAnswer ne $myAnswer) {
if ($hasShown == 0) {
print "@quizData\n";
$hasShown = 1;
}
print "=> ";
$myAnswer = <STDIN>;
chomp($myAnswer);
$myAnswer = lc($myAnswer);
if ("q" eq $myAnswer) {
$done = 1;
last;
}
if ("?" eq $myAnswer) {
print "(" . uc($quizAnswer) . ")\n";
}
else {
if ("#" eq $myAnswer) {
print "$quizFile\n";
}
else {
if ($quizAnswer ne $myAnswer) {
system("clear");
$hasShown = 0;
}
}
}
}
if ($done != 0) { last; }
}
Q1. Where is specific information regarding height, width, depth, and weight of a Power Systems server located?
A. Hardware InfoCenter
B. System Planning Tool
C. Offering Information website
D. Technical Delivery and Assessment Guide
A