多肢選択問題作成画面で、選択番号をつける際、番号を1,2でなく、①、②
の◯付番号にすることはできますか?
お教えください。
moodleバージョンは4.13です。
不可能ではありませんが、プログラム修正が必要になります。
具体的にはquestion/engine/lib.phpの1010行目あたりに以下のような「数字を◯付番号に変換する」ためのオリジナルの関数を追加する必要があります。
具体的にはquestion/engine/lib.phpの1010行目あたりに以下のような「数字を◯付番号に変換する」ためのオリジナルの関数を追加する必要があります。
public static function int_to_circled($number) {そして以下のプログラム修正も必要です。
$circled = [
'1' => '①',
'2' => '②',
'3' => '③',
'4' => '④',
'5' => '⑤',
--- 省略 ---
- question/type/multichoice/questiontype.php内の関数get_numbering_styles()
- question/type/multichoice/renderer.php内の関数number_in_style()
Yoshida様
お世話になっております。
プログラムの修正になるのですね。
自身でするのは難しいので考えてみます。
ありがとうございました。
Yoshida様
プログラム修正について、お聞きしたいのですが、そもそもプログラムとは、moodleの管理から修正箇所に進むのですか?
それとも、サーバーのどこかにアクセスして、修正箇所に進むのですか?
素人の質問で申し訳ありませんが、お教えください。
プログラム修正について、お聞きしたいのですが、そもそもプログラムとは、moodleの管理から修正箇所に進むのですか?
それとも、サーバーのどこかにアクセスして、修正箇所に進むのですか?
素人の質問で申し訳ありませんが、お教えください。
> それとも、サーバーのどこかにアクセスして、修正箇所に進むのですか?
そうです。
そうです。
Yoshida様
恐れ入りますがお教えください。
サーバーはconoha wingです。
この中のどこにアクセスすればmoodleのプログラム修正ができるか、教えていただけませんか?
宜しくお願い致します。
恐れ入りますがお教えください。
サーバーはconoha wingです。
この中のどこにアクセスすればmoodleのプログラム修正ができるか、教えていただけませんか?
宜しくお願い致します。
「SSH アカウントを作成する」をお読みになり、OpenSSH や Tera Term といったものを用意して SSH 接続をすれば、 /var/www/html/moodle/ あたりに Moodle が見つかると思いますので、それを emacs や vi で修正するのがよくある方法だと思います。(運用環境を直接変更することが望ましくなければ、test 環境を別途用意することになります。)
なお、ConoHa WING は「レンタルサーバ」ですので、VPS などの上に Moodle を設置するよりも難易度がかなり高いと思われます。「レンタルサーバ」上に Moodle を設置すると、VPS には存在しない様々な制約に直面することとなり原因を調べるだけで苦労します。
Ishikawa様
ありがとうございます。
やはり、素人には難しいのですね。
詳細を教えていただき感謝いたします。
> この中のどこにアクセスすればmoodleのプログラム修正ができるか、教えていただけませんか?
以下のプログラム修正等でご希望の機能を実装できるかと思いますが、石川先生ご指摘のように「VPS には存在しない様々な制約に直面する」可能性もあり、レンタルサーバ上でのプログラム修正は決して簡単なものではないとお考えください。
以下のプログラム修正等でご希望の機能を実装できるかと思いますが、石川先生ご指摘のように「VPS には存在しない様々な制約に直面する」可能性もあり、レンタルサーバ上でのプログラム修正は決して簡単なものではないとお考えください。
修正対象プログラム:
question/engine/lib.php
修正箇所:
1110行目
[ 修正前 ]
if (!is_integer($number) || $number < 1 || $number > count($alphabet)) {
throw new coding_exception('Only integers between 1 and 26 can be converted to letters.', $number);
}
return $alphabet[$number];
}
/**
* Typically, $mark will have come from optional_param($name, null, PARAM_RAW_TRIMMED).
* This method copes with:
* - keeping null or '' input unchanged - important to let teaches set a question back to requries grading.
* - numbers that were typed as either 1.00 or 1,00 form.
* - invalid things, which get turned into null.
[ 修正後 ]
if (!is_integer($number) || $number < 1 || $number > count($alphabet)) {
throw new coding_exception('Only integers between 1 and 26 can be converted to letters.', $number);
}
return $alphabet[$number];
}
/**
* Convert an integer to circled number.
* @param int $number an integer between 1 and 30 inclusive.
* Anything else will throw an exception.
* @return string circled number.
*/
public static function int_to_circled($number) {
$circled = [
'1' => '①',
'2' => '②',
'3' => '③',
'4' => '④',
'5' => '⑤',
'6' => '⑥',
'7' => '⑦',
'8' => '⑧',
'9' => '⑨',
'10' => '⑩',
'11' => '⑪',
'12' => '⑫',
'13' => '⑬',
'14' => '⑭',
'15' => '⑮',
'16' => '⑯',
'17' => '⑰',
'18' => '⑱',
'19' => '⑲',
'20' => '⑳',
'21' => '㉑',
'22' => '㉒',
'23' => '㉓',
'24' => '㉔',
'25' => '㉕',
'26' => '㉖',
'27' => '㉗',
'28' => '㉘',
'29' => '㉙',
'30' => '㉚'
];
if (!is_integer($number) || $number < 1 || $number > count($circled)) {
throw new coding_exception('Only integers between 1 and 30 can be converted to circled numbers.', $number);
}
return $circled[$number];
}
/**
* Typically, $mark will have come from optional_param($name, null, PARAM_RAW_TRIMMED).
* This method copes with:
* - keeping null or '' input unchanged - important to let teaches set a question back to requries grading.
* - numbers that were typed as either 1.00 or 1,00 form.
* - invalid things, which get turned into null.
----------
修正対象プログラム:
question/type/multichoice/questiontype.php
修正箇所:
286行目
[ 修正前 ]
/**
* @return array of the numbering styles supported. For each one, there
* should be a lang string answernumberingxxx in teh qtype_multichoice
* language file, and a case in the switch statement in number_in_style,
* and it should be listed in the definition of this column in install.xml.
*/
public static function get_numbering_styles() {
$styles = array();
foreach (array('abc', 'ABCD', '123', 'iii', 'IIII', 'none') as $numberingoption) {
$styles[$numberingoption] =
get_string('answernumbering' . $numberingoption, 'qtype_multichoice');
}
return $styles;
}
[ 修正後 ]
/**
* @return array of the numbering styles supported. For each one, there
* should be a lang string answernumberingxxx in teh qtype_multichoice
* language file, and a case in the switch statement in number_in_style,
* and it should be listed in the definition of this column in install.xml.
*/
public static function get_numbering_styles() {
$styles = array();
// foreach (array('abc', 'ABCD', '123', 'iii', 'IIII', 'none') as $numberingoption) {
foreach (array('abc', 'ABCD', '123', 'iii', 'IIII', 'CCC', 'none') as $numberingoption) {
$styles[$numberingoption] =
get_string('answernumbering' . $numberingoption, 'qtype_multichoice');
}
return $styles;
}
----------
修正対象プログラム:
question/type/multichoice/renderer.php
修正箇所:
215行目
[ 修正前 ]
protected function number_in_style($num, $style) {
switch($style) {
case 'abc':
$number = chr(ord('a') + $num);
break;
case 'ABCD':
$number = chr(ord('A') + $num);
break;
case '123':
$number = $num + 1;
break;
case 'iii':
$number = question_utils::int_to_roman($num + 1);
break;
case 'IIII':
$number = strtoupper(question_utils::int_to_roman($num + 1));
break;
case 'none':
return '';
default:
return 'ERR';
}
return $this->number_html($number);
}
[ 修正後 ]
protected function number_in_style($num, $style) {
switch($style) {
case 'abc':
$number = chr(ord('a') + $num);
break;
case 'ABCD':
$number = chr(ord('A') + $num);
break;
case '123':
$number = $num + 1;
break;
case 'iii':
$number = question_utils::int_to_roman($num + 1);
break;
case 'IIII':
$number = strtoupper(question_utils::int_to_roman($num + 1));
break;
case 'CCC':
$number = question_utils::int_to_circled($num + 1);
return $number;
case 'none':
return '';
default:
return 'ERR';
}
return $this->number_html($number);
}
----------
修正対象ファイル:
question/type/multichoice/lang/en/qtype_multichoice.php
修正箇所:
86行目
[ 修正前 ]
$string['toomanyselected'] = 'You have selected too many options.';
[ 修正後 ]
$string['toomanyselected'] = 'You have selected too many options.';
$string['answernumberingCCC'] = '①, ②, ③, ...';
----------
追加ファイル:
question/type/multichoice/lang/ja/qtype_multichoice.php
ファイルコンテンツ:
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle 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
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'qtype_multichoice', language 'en', branch 'MOODLE_20_STABLE'
*
* @package qtype
* @subpackage multichoice
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$string['answernumberingCCC'] = '①, ②, ③, ...';
Yoshida様
ありがとうございます。
お陰様でアクセスできました。
ご指示通り、易しくは無さそうですね。
また自身で修正して正常に動かなくなるのも困りますので、やめておいた方が良いかなと思いました。
色々とお手数をおかけしまして申し訳ありませんでした。
ありがとうございます。
お陰様でアクセスできました。
ご指示通り、易しくは無さそうですね。
また自身で修正して正常に動かなくなるのも困りますので、やめておいた方が良いかなと思いました。
色々とお手数をおかけしまして申し訳ありませんでした。