正規表現記述問題タイプ

提供:MoodleDocs
2021年4月9日 (金) 03:10時点におけるToshihiro KITA (トーク | 投稿記録)による版
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索


正規表現記述問題タイプ

  • 重要な注意事項
    • このドキュメントページで説明されている正規表現記述問題は、サードパーティのプラグインであり、小テスト 活動の問題を作成できます。レッスン モジュールの "正規表現を使用する" オプションとは 別物 です。

レッスン モジュールの "正規表現を使用する" オプションのドキュメントは次の場所にあります:記述問題アナリティクス

正規表現記述問題は、記述問題と同様に、解答者が "オープン" な問題に単語や短いフレーズで答えることを期待しています。しかし、正規表現システムでは、より適切な即時のフィードバックを提供する ことを目的とした、学生の解答を分析する ためのより強力なシステムにアクセスすることができます。 正規表現記述問題は、自然言語 での解答を必要とする問題に使用することを意図しています。この問題タイプは、数学、科学、プログラミングの "言語" を必要とする問題には適していません。

正規表現パターンに一致する正解

このシステムが提供する膨大な可能性を完全に例示することはできませんが、以下はその可能性の一例です。

例1

問題が "What are the colors of the French flag?" だったとします。答え1の欄には、"it's blue, white and red" など、"ベスト" な答えを入力します。詳しくは以下のFirst correct answerをご覧ください。

  • 答え2のボックスには、次のような正規表現を入力します。"it's blue, white(,| and) red" (もちろん、引用符はタイプしてはいけません)。
  • Case sensivityが "No" に設定されている場合は、これら4つの解答のいずれかにマッチします。
   it's blue, white, red
   it's blue, white and red
   It's blue, white, red
   It's blue, white and red

例2

問題: "What are blue, red and yellow?"

  • 答え1: "they are colours".
  • 答え2: "(|they('| a)re )colou?rs".
  • この6つの解答のいずれかにマッチします。
   colours
   colors
   they're colours
   they're colors
   they are colours
   they are colors

注意 - この正規表現の最初の部分 "(|they('| a)re )" は、何もないか、"they're " または "they are "にマッチします。"colou?r" のクエスチョンマークは、直前の文字 (または括弧で囲まれた文字群) がゼロまたは1回という意味で、ここではアメリカのスペルだけでなくイギリス英語にもマッチするように使われています。

例3

問題: "Name an animal whose name consists of 3 letters and the middle letter is the vowel a".

  • 答え1: "cat"
  • 答え2: "[bcr]at".
  • bat, cat または ratのいずれかにマッチします。

注意 - 正規表現の構文では、角括弧の間に文字が含まれていると、それらの文字のいずれもが使用できることを意味します。つまり、上記の例では、正規表現 "[bcr]at" は "(b|c|r)at" と全く同じ意味になります。ただし、[...] の正規表現では、セパレータとしてパイプ文字を使用しないように注意してください。例えば、"[b|c|r]at" は正常に動作しません。

例4

'順列' 機能(Moodle2.3以降の正規表現バージョン 2012102900 で導入)

問題: "What are the colours of the French flag (in any order)".

  • 答え1: "it's blue, white and red"
  • 答え2: "it's [[_blue_, _white_(,| and) _red_]]".

問題を保存すると、解答2は自動的に解答2bとして書き直されます。

これは (blue, white(,| and) red|blue, red(,| and) white|white, red(,| and) blue|white, blue(,| and) red|red, blue(,| and) white|red, white(,| and) blue)

と表示され、以下のすべての解答と一致します:

   it's blue, white, red
   it's blue, white and red
   it's blue, red, white
   it's blue, red and white
   it's white, red, blue
   it's white, red and blue
   it's white, blue, red
   it's white, blue and red
   it's red, blue, white
   it's red, blue and white
   it's red, white, blue
   it's red, white and blue

注意 - この '順列機能' は、正規表現ユーザからかなりの回数の質問を受けています。標準的な正規表現の構文を使ってこの機能を得ることは、間違いなく 不可能 です。

上記の回答2bのように、すべての可能な順列を含む正規表現を書くことは可能ですが(しかし退屈です)、私が提供している アドホック 構文を使えば、簡単に書くことができます...ただし、その構文を厳密に守ることが条件です。

二重の角括弧の中に、'順列可能な' 単語やフレーズを含む答えの部分を入れてください。このような '順列可能な' 単語やフレーズのセットは、実際には最大2つまで認められています。ただし、1つのセットを別のセットに埋め込むことはできません。

そして、アンダースコア(_文字)のペアを使って、それぞれの '順列可能な' 単語やフレーズを区切ってください。このような '順列可能な' 単語やフレーズのセットを1つ(または2つ)含む解答には、ここで説明しているように、受け入れられる正規表現文字を使用することができます。あなたの解答にアンダースコアが偶数個含まれていない場合、別の解答を表示するボタンをクリックしたときや、問題を保存しようとしたときにエラー警告が表示されます。

例5

別の '順列' の例

問題: "Quote the English proverb that is an encouragement to hard, diligent work."

  • 答え1: "Early to bed and early to rise makes a man healthy, wealthy and wise"
  • 答え2: "Early to [[_bed_ and early to _rise_]], makes a man [[_healthy_, _wealthy_ and _wise_]]"

問題を保存すると、解答2は自動的に解答2bとして書き直されます。

Early to (bed and early to rise|rise and early to bed) makes a man (healthy, wealthy and wise|healthy, wise and wealthy|wealthy, wise and healthy|wealthy, healthy and wise|wise, healthy and wealthy|wise, wealthy and healthy)

と表示され、以下のすべての回答と一致します:

   Early to bed and early to rise makes a man healthy, wealthy and wise
   Early to bed and early to rise makes a man healthy, wise and wealthy
   Early to bed and early to rise makes a man wealthy, wise and healthy
   Early to bed and early to rise makes a man wealthy, healthy and wise
   Early to bed and early to rise makes a man wise, healthy and wealthy
   Early to bed and early to rise makes a man wise, wealthy and healthy
   Early to rise and early to bed makes a man healthy, wealthy and wise
   Early to rise and early to bed makes a man healthy, wise and wealthy
   Early to rise and early to bed makes a man wealthy, wise and healthy
   Early to rise and early to bed makes a man wealthy, healthy and wise
   Early to rise and early to bed makes a man wise, healthy and wealthy
   Early to rise and early to bed makes a man wise, wealthy and healthy