#!/usr/bin/perl
# Copyright (C) 2002-2004 Free Software Foundation, Inc.

# The GPL Quiz is free software; you can redistribute it and/or
# modify it under the terms of the Affero General Public License as
# published by Affero, Inc. either version 1 of the License, or
# (at your option) any later version.

# The __DATA__ section is not part of the GPL Quiz; and is not
# released under the Affero General Public License. As it represents
# the legal opinions of the FSF (but is not legal advice), only
# verbatim copying and redistribution is allowed. Translations must
# be approved by the FSF; please write to licensing@gnu.org for
# details.

# The GPL Quiz is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Affero General Public License for more details.

# A copy of the Affero Generall PublicLicense should be available at
# https://gnu.dev.org.tw/licenses/agpl.html. If not, write to Affero,
# Inc., 510 Third Street, Suite 225, San Francisco, CA 94107 USA.


use CGI::Carp;
use CGI qw(:standard);
use HTML::Entities;
use strict;

#a template looks like
#
#<mysection name="section1" />
#blah
#blah
#<mysection name="section2" />
#more
#stuff
#...
#This returns { section1 => "blah\nblah", section2 => "more\nstuff"}
sub parsetemplate {
my ($section, $template) = "__COMMENTS";
while (<DATA>) {
if (m{<mysection\s+name\s*=\s*"(.*)"\s*/>}) {
$section = $1;
} else {
$template->{$section} .= $_;
}
}
$template;
}


print "Content-type: text/html\n\n";

# XSS prevention: https://rt.gnu.org/Ticket/Display.html?id=1243718
my $mode = HTML::Entities::encode( param ('mode'));
#$mode =~ s/[^A-Za-z0-9 ]*/ /g;

if ($mode eq 'source') {
open A, $0;
my $src = join '', <A>;
$src =~ s/&/&amp;/g;
$src =~ s/</&lt;/g;
$src =~ s/>/&gt;/g;
$src =~ s/$/<br>/mg;
print $src;
} elsif ($mode eq 'answer') {
my $tmpl = parsetemplate ();
print $tmpl->{top};

my @answers = (1,3,2,4,3,5,4,1,3);
my $correct;

for (my $i = 1; $i <= @answers; $i++) {

my $answer = $answers [$i - 1];
my $question = $tmpl->{"Q$i"};
# XSS prevention: https://rt.gnu.org/Ticket/Display.html?id=1243718
my $userans = HTML::Entities::encode( param ("q$i"));

$question =~ s!<input type="radio".*?/>!!g;

if ($userans) {
$question =~ s,<(/?)a$i-$answer>,<$1em>,g;
} else {
$question =~ s,<(/?)a$i-$answer>,,g;
}
my $hint;

if ($question =~ s,<hint>(.*?)</hint>,,msg) {
$hint = $1;
}

print $question;

if ($userans) {
if ($answer == $userans) {
#correct
print "<p><b>Correct!</b></p>";
$correct++;
} else {
print "<p><b>You chose $userans, but the correct answer was $answers[$i-1].</b></p>";
}
} else {
print "<p><b>You didn't answer this question.</b></p>";
}

print "<p> $hint</p>";
}
print $tmpl->{"endquestions"};
if ($correct == @answers) {
print <<EOF;
<h2>Perfect!</h2>
You got everything right! The FSF is looking for people to answer licensing questions -- if think you've got what it takes, why not <a href="mailto:license-volunteers\@gnu.org">volunteer</a> to answer licensing questions from the public?
EOF
} else {
print <<EOF;

You might want to review the <a
href="https://gnu.dev.org.tw/licenses/gpl-faq.html">GPL FAQ</a>. Better
luck next time!
EOF

}
print $tmpl->{bottom};
} else {
#assume question mode
my $html = join '', <DATA>;
$html =~ s,</?a\d+-\d+>,,g;
$html =~ s,<mysection .*?>,,g;
$html =~ s,<hint>.*?</hint>,,msg;
print $html;
}
__DATA__
<mysection name="top" />

<html>
<head>
<title>
GNU 專案 - 自由軟體授權測驗
</title>
<meta HTTP-EQUIV="Keywords"
CONTENT="GPL, GFDL, LGPL, GNU General Public License">
<meta HTTP-EQUIV="Description"
CONTENT="透過這個關於 GPL 與 LGPL 的測驗(據說是),來測試您對自由軟體授權的知識。
如果您不覺得它非常乏味,您應該來我們這裡當志工。">
find it mind-numbingly dull, you should volunteer for us.">
<link REV="made" HREF="mailto:novalis@gnu.org">
</head>

<body BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#1F00FF" ALINK="#FF0000" VLINK="#9900DD">

<form action="/cgi-bin/license-quiz.cgi" method="get">
<input type="hidden" name="mode" value="answer" />

<mysection name="header" />
<p>
參加自由軟體授權測驗,並測試您對
GPL 與 LGPL 的知識。
</p>

<mysection name="Q1" />
<ol>
<li>
<p>

Joan 撰寫了一個網頁瀏覽器,並在 GPL 授權下於她的網站發布原始碼。
Fred 給了他的朋友一片光碟,裡面是 Joan 瀏覽器的二進位檔,作為她的生日禮物。
下列哪一項<b>不</b>符合
Fred 提供原始碼的義務:

<ol>
<li>
<input type="radio" name="q1" value="1" />

<a1-1>
他可以將原始碼放在他的網站上,並將網址放在光碟中。
</a1-1>
</li>

<li>
<input type="radio" name="q1" value="2" />
<a1-2>
他可以在與二進位檔相同的光碟中提供原始碼。
</a1-2>
</li>

<li>
<input type="radio" name="q1" value="3" />
<a1-3>
他可以書面承諾以涵蓋其發行成本的費用,在光碟中提供原始碼。
a fee that covers his distribution costs.
</a1-3>
</li>
</ol>
<hint>
這個問題在 <a href="https://gnu.dev.org.tw/licenses/gpl-faq.html#DistributeWithSourceOnInternet">GPL 常見問答集</a> 中有詳細說明。
</hint>
<mysection name="Q2" />
</li>
<li>
<p> 現在 Fred 修改了 Joan 的網頁瀏覽器,並
在他的網站上發布二進位檔。下列哪一項符合
Fred 發布修改後
瀏覽器原始碼的義務? </p>

<ul>
<li><b>I.</b>

他可以逐字發布 Joan 的原始原始碼,保留
所有著作權聲明。

</li>
<li><b>II.</b>

他可以與二進位檔一起發布修改後的原始碼。

</li>
<li><b>III.</b>

他可以僅發布針對
原始原始碼的微不足道的修補程式。

</li>
<li><b>IV.</b>

他可以發布針對 Joan
原始原始碼的微不足道的修補程式,以及原始原始碼。

</li>
</ul>

<br>

<ol>
<li> <input type="radio" name="q2" value="1" />
<a2-1>
<b>I</b> 或 <b>II</b>,沒有其他選項。
</a2-1>
</li>

<li> <input type="radio" name="q2" value="2" />
<a2-2>
<b>II</b>,沒有其他選項。
</a2-2>
</li>

<li> <input type="radio" name="q2" value="3" />
<a2-3>
<b>II</b> 或 <b>IV</b>,沒有其他選項
</a2-3>
</li>

<li> <input type="radio" name="q2" value="4" />
<a2-4>
任何或所有 <b>I</b>、<b>II</b>、<b>III</b> 或 <b>IV</b>
</a2-4>
</li>

</ol>

<hint>
這個問題在 <a href="https://gnu.dev.org.tw/licenses/gpl-faq.html#TOCDistributingSourceIsInconvenient">GPL 常見問答集</a>,以及 <a href="https://gnu.dev.org.tw/copyleft/gpl.html">GPL</a> 第 2 和 3 節中有詳細說明
</hint>

<mysection name="Q3" />
</li>
<li>

<p> Fred 希望發布 Joan 的瀏覽器,並連結到一個
第三方模組。該第三方模組具有以下授權條款
</p>

<tt><blockquote>
只要不收取任何費用,此程式碼可以自由修改、複製和發布。
no fee is charged for it.
</blockquote></tt>

<p>
這會違反 GPL 嗎?
</p>

<ol>
<li>
<input type="radio" name="q3" value="1" />

<a3-1>
是,因為 GPL 要求連結到
GPL 授權程式碼的程式碼,也必須以 GPL 授權。
</a3-1>

</li>
<li>
<input type="radio" name="q3" value="2" />

<a3-2>
是,因為 GPL 不允許對
程式碼的任何部分施加額外限制。
</a3-2>

</li>
<li>
<input type="radio" name="q3" value="3" />

<a3-3>
否,因為新程式碼是連結到 Joan 的程式碼,
而不是複製到 Joan 的程式碼中。
</a3-3>


</li>
<li>
<input type="radio" name="q3" value="4" />
<a3-4>
否,因為產生的作品仍然可以免費發布。
</a3-4>
</li>

<li>
<input type="radio" name="q3" value="5" />
<a3-5>
否,因為 GPL 已經禁止收取發行費用。
</a3-5>
</li>

</ol>

<hint>
您可以在 <a href="https://gnu.dev.org.tw/copyleft/gpl.html">GPL</a> 第 6 節,以及 <a href="https://gnu.dev.org.tw/philosophy/free-sw.html">自由軟體定義</a> 中找到關於此問題的資訊
</hint>

<mysection name="Q4" />
</li>
<li>

<p>
Peter 建立了一個名為 LibIdo 的函式庫,並以次要通用公共授權條款 (Lesser General Public License) 授權。FooCorp 發布了 LibIdo 函式庫的修改版本,並連結到他們的專有程式 Frobber。下列哪一項<b>不</b>是 FooCorp 的義務?
</p>

<ol>
<li>
<input type="radio" name="q4" value="1" />
<a4-1>
FooCorp 必須提供一種機制,讓 Frobber 可以連結到
新版本的 LibIdo。
</a4-1>
</li>

<li>
<input type="radio" name="q4" value="2" />
<a4-2>
FooCorp 必須提供其
修改版 LibIdo 的完整原始碼。
</a4-2>
</li>

<li>
<input type="radio" name="q4" value="3" />
<a4-3>
FooCorp 必須註明他們對 LibIdo 的所有修改。
</a4-3>
</li>

<li>
<input type="radio" name="q4" value="4" />
<a4-4>
FooCorp 必須提供 Frobber 的完整原始碼。
</a4-4>
</li>

<hint>
您可以在 <a href="https://gnu.dev.org.tw/copyleft/lesser.html">LGPL</a> 第 2 和 6 節中找到關於此問題的資訊。
</hint>
</ol>

<mysection name="Q5" />

</li>
<li>
<p>
Joan 想要發布她的瀏覽器副本,並靜態連結到
Postfix(郵件伺服器),它是在 <a
href="http://oss.software.ibm.com/developerworks/opensource/license10.html">
IBM 公共授權條款</a>(一個與 GPL 不相容的自由軟體授權條款)下發布的。
除了 Postfix 之外,瀏覽器僅包含 Joan 擁有
著作權的程式碼。她應該為此授予 GPL 例外條款嗎?
</p>
<ol>
<li>
<input type="radio" name="q5" value="1" />
<a5-1>
否,因為靜態連結不會產生衍生作品
</a5-1>
</li>
<li>
<input type="radio" name="q5" value="2" />
<a5-2>
否,因為 GPL 已經允許連結到其他軟體,只要
該軟體是自由軟體。
</a5-2>
</li>
<li>
<input type="radio" name="q5" value="3" />
<a5-3>
是 — 以下例外條款可以接受:<br/ >

<p> 此外,作為一個特別的例外,Joan Smith 授權
將此程式的程式碼與 Postfix(或與修改過的
使用與 Postfix 相同授權條款的 Postfix 版本)連結,並
發布包含這兩者的連結組合。對於 Postfix 以外的所有程式碼,您必須在各方面遵守
the GNU General Public License in all respects for all of the code
使用的 GNU 通用公共授權條款。如果您修改此檔案,您可以將
此例外條款延伸到您的檔案版本,但您沒有
義務這樣做。如果您不希望這樣做,請從您的版本中刪除此
例外條款聲明。 </p>
</a5-3>
</li>
<li>
<input type="radio" name="q5" value="4" />
<a5-4>
是 — 以下例外條款可以接受:<br/ >

<p>此外,作為一個特別的例外,Joan Smith 授權
將此程式的程式碼與任何專有函式庫連結,並
發布包含這些函式庫的連結組合。對於
這些函式庫以外的所有程式碼,您必須在各方面遵守 GNU 通用公共授權條款。
使用的程式碼。如果您修改此
檔案,您可以將此例外條款延伸到您的檔案版本,
但您沒有義務這樣做。如果您不希望這樣做,
請從您的版本中刪除此例外條款聲明。</p>
</a5-4>
</li>

<hint>
您可以在 GPL 常見問答集 <a href="https://gnu.dev.org.tw/licenses/gpl-faq.html#WritingFSWithNFLibs">這裡</a>,以及 <a href="https://gnu.dev.org.tw/licenses/gpl-faq.html#WhatIsCompatible">這裡</a> 找到關於此問題的資訊。
</hint>
</ol>
<mysection name="Q6" />

</li>
<li>
<p>
FooCorp 在 CD 上販售 Joan 的 GPL 授權網頁瀏覽器二進位檔,
沒有原始碼。他們包含提供原始碼的承諾。
下列哪一項承諾符合他們在 GPL 下的義務?
</p>

<ul>
<li>
<b>I.</b>
「您可以從我們的網站下載原始碼,網址為
http://foocorp.example.com/download.html」
</li>
<li>
<b>II.</b>
「每位購買二進位檔光碟的人,可以訂購最多一片原始碼光碟,
每片二進位檔光碟售價 $5000 美元。」
</li>
<li>
<b>III.</b>
「任何人都可以訂購原始碼光碟,售價 $5000 美元。」
</li>
<li>
<b>IV.</b>
「每位購買二進位檔光碟的人,可以訂購最多一片原始碼光碟,
每片二進位檔光碟的發行成本。」
</li>
<li>
<b>V.</b>
「任何人都可以訂購原始碼光碟,費用為發行成本。」
</li>
<li>
<b>VI.</b>
「每位購買二進位檔光碟的人,可以訂購最多一片原始碼光碟,
免費。」
</li>
<li>
<b>VII.</b>
「任何人都可以免費訂購原始碼光碟。」
</li>
</ul>
<ol>
<li>
<input type="radio" name="q6" value="1" />
<a6-1>
任何 <b>I</b>-<b>VII</b> 都可以接受。
</a6-1>
</li>
<li>
<input type="radio" name="q6" value="2" />
<a6-2>
任何 <b>II</b>-<b>VII</b> 都可以接受,但 <b>I</b> 不可以接受。
</a6-2>
</li>
<li>
<input type="radio" name="q6" value="3" />
<a6-3>
任何 <b>IV</b>-<b>VII</b> 都可以接受,但 <b>I</b>-<b>III</b> 不可以接受。
</a6-3>
</li>
<li>
<input type="radio" name="q6" value="4" />
<a6-4>
任何 <b>III</b>、<b>V</b> 和 <b>VII</b> 都可以接受,但 <b>I</b>、<b>II</b>、<b>IV</b>、<b>VI</b> 不可以接受。
</a6-4>
</li>
<li>
<input type="radio" name="q6" value="5" />
<a6-5>
<b>V</b> 和 <b>VII</b> 都可以接受,其他都不可以。
</a6-5>
</li>
<li>
<input type="radio" name="q6" value="6" />
<a6-6>
<b>I</b>-<b>VII</b> 都不可以接受。
</a6-6>
</li>
</ol>

<hint>
您可以在 <a href="https://gnu.dev.org.tw/copyleft/gpl.html">GPL</a> 第 3b 節中找到關於此問題的資訊。
</hint>

<mysection name="Q7" />
</li>
<li>
<p>
Patty 建立了一個函式庫,並以 GPL 發布。許多人對此函式庫進行了
改進,並將其提交回 Patty,Patty
將它們納入函式庫的較新版本中。現在 Patty 想要
製作此函式庫的專有版本。她提出了兩個聲明:</p>

<ul>
<li><b>I.</b>

由於原始版本是在 GPL 下發布的,因此每個做出
改進的人都會自動將這些
改進的著作權轉讓給 Patty,因此她不需要在
重新授權之前徵求許可。

</li>
<li><b>II.</b>

因為她是著作權持有人,所以她可以重新授權程式碼
追溯既往,因此沒有人可以再根據 GPL 發布舊版本
了。

</li>
</ul>

<p>這些聲明是真的嗎?</p>

<ol>
<li>
<input type="radio" name="q7" value="1" />
<a7-1>
兩個聲明都是真的。
</a7-1>
</li>
<li>
<input type="radio" name="q7" value="2" />
<a7-2>
I 是真的,但 II 是假的
</a7-2>
</li>
<li>
<input type="radio" name="q7" value="3" />
<a7-3>
II 是真的,但 I 是假的
</a7-3>
</li>
<li>
<input type="radio" name="q7" value="4" />
<a7-4>
兩個聲明都是假的。
</a7-4>
</li>
</ol>

<hint>
<a href="https://gnu.dev.org.tw/copyleft/gpl.html">GPL</a> 第 4 節說明了撤銷發布 GPL 軟體許可的條件。著作權法本身有更多資訊。
</hint>

<mysection name="Q8" />
</li>
<li>

<p> FooCorp 發布了 Frobber,它連結到未修改版本的
LibIdo。LGPL 是否要求 FooCorp 允許使用者對
Frobber 進行逆向工程以供自己使用?</p>

<ol>
<li>
<input type="radio" name="q8" value="1" />
<a8-1>
是。
</a8-1>
</li>
<li>
<input type="radio" name="q8" value="2" />
<a8-2>
否。
</a8-2>
</li>
</ol>

<hint>
<a href="https://gnu.dev.org.tw/copyleft/lesser.html">LGPL</a> 第 6 節包含「使用該函式庫的作品」的要求。
</hint>

<mysection name="Q9" />
</li>
<li>

<p>現在 FooCorp 修改了 Joan 的瀏覽器,以包含他們
已獲得專利的技術。他們在 CD 上發布了這個修改後的瀏覽器。在
GPL 中,對於他們如何授權其
適用的專利,有任何要求嗎?</p>

<ol>
<li>
<input type="radio" name="q9" value="1" />
<a9-1>
否。
否,沒有任何特殊要求。
</li>
<li>
</a9-1>
<input type="radio" name="q9" value="2" />
<a9-2>
是,他們必須允許所有人為了任何目的而實施該專利技術。
for any purpose.
</li>
<li>
</a9-2>
<input type="radio" name="q9" value="3" />
<a9-3>
是,他們必須允許每個使用瀏覽器中任何程式碼的人,實施其專利技術。
to practice their patented technology.
</li>
</ol>
</li>
</ol>
<hint>
</a9-3>
</hint>

<a href="https://gnu.dev.org.tw/copyleft/gpl.html">GPL</a> 第 7 節說明了專利授權要求。
<mysection name="formbottom" />
<input type="submit" name = "Quiz Me!" value = "考考我!" / >

<mysection name="bottom" />
<p>關於此測驗的意見或問題,請寄至 licensing@gnu.org。測驗的原始碼可在此處 <a href="license-quiz.cgi?mode=source">取得</a></p>

</body>
</html>