Skip to content

Commit b4104eb

Browse files
committed
Merge branch 'develop'
2 parents a0414bb + c046414 commit b4104eb

File tree

9 files changed

+50
-3712
lines changed

9 files changed

+50
-3712
lines changed

Config/Schema/app.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,6 @@ CREATE TABLE IF NOT EXISTS `ib_cake_sessions` (
250250
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
251251

252252
INSERT INTO `ib_settings` VALUES ('1', 'title', 'システム名', 'iroha Board');
253-
INSERT INTO `ib_settings` VALUES ('2', 'copyright', 'コピーライト', 'Copyright (C) 2016-2021 iroha Soft Co.,Ltd. All rights reserved.');
253+
INSERT INTO `ib_settings` VALUES ('2', 'copyright', 'コピーライト', 'Copyright (C) 2016-2022 iroha Soft Co.,Ltd. All rights reserved.');
254254
INSERT INTO `ib_settings` VALUES ('3', 'color', 'テーマカラー', '#337ab7');
255255
INSERT INTO `ib_settings` VALUES ('4', 'information', 'お知らせ', '全体のお知らせを表示します。\r\nこのお知らせは管理機能の「システム設定」にて変更可能です。');

Config/ib_config.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'movie' => '動画',
1919
'url' => 'URL',
2020
'file' => '配布資料',
21-
'test' => 'テスト'
21+
'test' => 'テスト',
2222
];
2323

2424
$config['content_kind_comment'] = [
@@ -28,12 +28,12 @@
2828
'movie' => '動画 <span>(動画をアップロードします。HTML5のVIDEOタグで再生できるものに限られます。)</span>',
2929
'url' => 'URL <span>(外部のWebページを学習項目として追加します。)</span>',
3030
'file' => '配布資料 <span>(配布したいファイルをアップロードします。)</span>',
31-
'test' => 'テスト <span>(テストを作成します。問題はテスト作成後、別画面にて追加します。)'
31+
'test' => 'テスト <span>(テストを作成します。問題はテスト作成後、別画面にて追加します。)</span>',
3232
];
3333

3434
$config['content_category'] = [
3535
'study' => '学習',
36-
'test' => 'テスト'
36+
'test' => 'テスト',
3737
];
3838

3939
$config['wrong_mode'] = ['0' => '正解と解説を表示しない', '1' => '正解と解説を表示する', '2' => '解説のみ表示する'];

Controller/AppController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ protected function hasCookie($key)
195195
* @param string $key キー
196196
* @param string $value 値
197197
*/
198-
protected function writeCookie($key, $value, $secure = true, $expires = '+2 weeks')
198+
protected function writeCookie($key, $value, $encrypt = true, $expires = '+2 weeks')
199199
{
200-
$this->Cookie->write($key, $value, $secure, $expires);
200+
$this->Cookie->write($key, $value, $encrypt, $expires);
201201
}
202202

203203
/**

Controller/ContentsQuestionsController.php

+15-13
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function index($content_id, $record_id = null)
136136
//------------------------------//
137137
if($this->request->is('post'))
138138
{
139-
$details = []; // 成績詳細情報
139+
$details = []; // 成績詳細情報
140140
$full_score = 0; // 最高点
141141
$pass_score = 0; // 合格基準点
142142
$my_score = 0; // 得点
@@ -145,44 +145,46 @@ public function index($content_id, $record_id = null)
145145
//------------------------------//
146146
// 成績の詳細情報の作成 //
147147
//------------------------------//
148-
$i = 0;
149148
foreach($contentsQuestions as $contentsQuestion)
150149
{
151150
$question_id = $contentsQuestion['ContentsQuestion']['id']; // 問題ID
152-
$answer = $this->getData('answer_' . $question_id); // 解答
151+
$answer = $this->getData('answer_'.$question_id); // 解答(複数選択問題の場合、配列)
152+
153153
$correct = $contentsQuestion['ContentsQuestion']['correct']; // 正解
154-
$corrects = explode(',', $correct); // 複数選択
154+
$corrects = explode(',', $correct); // 複数選択問題の正解(配列)
155155

156-
$is_correct = ($answer == $correct) ? 1 : 0; // 正誤判定
157156
$score = $contentsQuestion['ContentsQuestion']['score']; // 配点
158-
$full_score += $score; // 合計点(配点の合計)
157+
159158

160159
// 複数選択問題の場合
161160
if(count($corrects) > 1)
162161
{
163-
$answers = $this->getData('answer_'.$question_id);
164-
$answer = @implode(',', $answers);
165-
$is_correct = $this->isMultiCorrect($answers, $corrects) ? 1 : 0;
166-
//debug($is_correct);
162+
// 全ての解答と正解が一致するか確認
163+
$is_correct = $this->isMultiCorrect($answer, $corrects) ? 1 : 0;
164+
165+
// データベース格納用に解答をカンマ区切りの文字列に変更
166+
$answer = is_array($answer) ? implode(',', $answer) : null;
167167
}
168168
else
169169
{
170-
$answer = $this->getData('answer_'.$question_id);
171170
$is_correct = ($answer == $correct) ? 1 : 0;
172171
}
173172

173+
// 合計点(配点の合計)
174+
$full_score += $score;
175+
176+
// 得点(正解した問題の配点の合計)
174177
if($is_correct == 1)
175178
$my_score += $score;
176179

177180
// 問題の正誤
178-
$details[$i] = [
181+
$details[] = [
179182
'question_id' => $question_id, // 問題ID
180183
'answer' => $answer, // 解答
181184
'correct' => $correct, // 正解
182185
'is_correct' => $is_correct, // 正誤
183186
'score' => $score, // 配点
184187
];
185-
$i++;
186188
}
187189

188190
// 合格基準得点

View/ContentsQuestions/index.ctp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
var MSG_REST_TIME = '<?php echo __('残り時間') ?>';
2323
var MSG_TIME = '<?php echo __('経過') ?>';
2424
</script>
25-
<?= $this->Html->script('contents_questions.js?20190401');?>
25+
<?= $this->Html->script('contents_questions.js?20220401');?>
2626
<?php $this->end(); ?>
2727
<div class="contents-questions-index">
2828
<div class="breadcrumb">

View/Layouts/default.ctp

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
echo $this->Html->script('jquery-1.9.1.min.js');
4242
echo $this->Html->script('jquery-ui-1.9.2.min.js');
4343
echo $this->Html->script('bootstrap.min.js');
44-
echo $this->Html->script('moment.js');
45-
echo $this->Html->script('common.js?20211001');
44+
echo $this->Html->script('common.js?20220401');
4645

4746
// 管理画面用スクリプト
4847
if($is_admin_page)

webroot/js/common.js

+25
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,30 @@ CommonUtility.prototype.setRichTextEditor = function (selector, upload_image_max
6969
});
7070
}
7171

72+
CommonUtility.prototype.getHHMMSSbySec = function (sec)
73+
{
74+
var date = new Date('2000/1/1');
75+
76+
date.setSeconds(sec);
77+
78+
var h = date.getHours();
79+
var m = date.getMinutes();
80+
var s = date.getSeconds();
81+
82+
if (h < 10)
83+
h = '0' + h;
84+
85+
if (m < 10)
86+
m = '0' + m;
87+
88+
if (s < 10)
89+
s = '0' + s;
90+
91+
var hms = h + ':' + m + ':' + s;
92+
93+
return hms;
94+
}
95+
96+
7297
var CommonUtil = new CommonUtility();
7398

webroot/js/contents_questions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function setStudySec()
4646
}
4747

4848
var restSec = TIMELIMIT_SEC - _studySec;
49-
var rest = moment("2000/01/01").add('seconds', restSec ).format('HH:mm:ss');
49+
var rest = CommonUtil.getHHMMSSbySec(restSec);
5050

5151
if(typeof MSG_REST_TIME == 'undefined')
5252
{
@@ -65,7 +65,7 @@ function setStudySec()
6565
}
6666
else
6767
{
68-
var passed = moment("2000/01/01").add('seconds', _studySec ).format('HH:mm:ss');
68+
var passed = CommonUtil.getHHMMSSbySec(_studySec);
6969

7070
if(typeof MSG_TIME == 'undefined')
7171
{

0 commit comments

Comments
 (0)