
使用答案如何讓使用者在PDF中輸入完形填空?,我能夠建立一個完形填空文檔,使用者可以在 PDF 中輸入填空內容。我在巨集中使用了該程式碼,因此它\field[cloze]
多次調用相同的程式碼。
\setupinteraction[state=start]
\definefield[cloze][line]
\starttext
Frogs have four \field[cloze] and two eyes.
Frogs have four \field[cloze] and two eyes.
Frogs have four \field[cloze] and two eyes.
Frogs have four \field[cloze] and two eyes.
\stoptext
<<-- 嘗試在一個欄位中輸入內容,然後它會複製到其他欄位。
問題是,當使用者填入第一個完形填空時,Adobe Acrobat 會自動使用完全相同的值填入所有其他完形填空。我需要用戶輸入不同的值。
\setupinteraction[state=start]
\definefield[cloze1][line]
\definefield[cloze2][line]
\definefield[cloze3][line]
\definefield[cloze4][line]
\starttext
Frogs have four \field[cloze1] and two eyes.
Frogs have four \field[cloze2] and two eyes.
Frogs have four \field[cloze3] and two eyes.
Frogs have four \field[cloze4] and two eyes.
\stoptext
<<-- 嘗試在一個欄位中輸入內容,它不再複製到其他欄位。
現在,「最小工作答案」中的解決方案是將\field[cloze] 更改為每個完形填空具有不同的名稱,例如\field[tree] 和\field[mountain],問題是,我將其嵌入到某些複雜的巨集。我嘗試使用 \field[#1] 發送不同的值,並且 \field[\expanded[#1]] 和 \field[\randomnumber{0}{10000000}], \def\somevalue{\randomnumber{0} { 10000000}}\field{\expanded{somevalue}} 等以及許多其他程式碼組合,但我嘗試的所有內容都無法編譯。由於它深入許多巨集層,我無法手動將 \field[cloze] 變更為其他值。
我如何使用答案中的程式碼,但在某種程度上,每個完形填空都是使用者可以鍵入唯一值的地方,而該值不會自動複製到每個完形填空?
答案1
您不需要擴展,ConTeXt 無論如何都會擴展名稱。另外我建議使用全域計數器而不是隨機值。這使得該文件更具可重複性和可靠性。
\setupinteraction[state=start]
\newcount\clozecount
\def\mycloze{%
\global \advance \clozecount by 1
\definefield[uniqcloze\the\clozecount][line]%
\field[uniqcloze\the\clozecount]%
}
\starttext
Frogs have four \mycloze\ and two eyes.
Frogs have four \mycloze\ and two eyes.
Frogs have four \mycloze\ and two eyes.
Frogs have four \mycloze\ and two eyes.
\stoptext