diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9501566..f46fc05 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,22 +3,21 @@ on: branches: - main - master - - availability pull_request: branches: - main - master - - availability name: tests jobs: setup: name: setup - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Slack Notification on Start uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests @@ -28,11 +27,11 @@ jobs: tests: name: tests needs: setup - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest strategy: matrix: - php: [ '7.1', '7.2', '7.3', '7.4' ] - mysql: [ '5.7', '8.0' ] + php: [ '7.4' ] + mysql: [ '8.0' ] env: NC3_BUILD_DIR: "/opt/nc3" @@ -44,6 +43,7 @@ jobs: MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 @@ -91,46 +91,53 @@ jobs: docker-compose exec -T nc3app bash /opt/scripts/app-build.sh - name: phpcs (PHP CodeSniffer) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh - name: phpmd (PHP Mess Detector) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh - name: phpcpd (PHP Copy/Paste Detector) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh - name: gjslint (JavaScript Style Check) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh - name: phpdoc (PHP Documentor) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh - name: phpunit (PHP UnitTest) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpunit.sh sudo -s chmod a+w -R ${NC3_BUILD_DIR}/build - - name: push coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: ${{ matrix.php }} - run: | - cd ${NC3_BUILD_DIR} - ls -la ${NC3_BUILD_DIR} - vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v +# - name: push coveralls +# env: +# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# COVERALLS_FLAG_NAME: ${{ matrix.php }} +# run: | +# cd ${NC3_BUILD_DIR} +# ls -la ${NC3_BUILD_DIR} +# vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v - name: docker-compose remove + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose rm -f @@ -138,7 +145,7 @@ jobs: # テスト失敗時はこちらのステップが実行される - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.2.0 - if: failure() + if: env.SLACK_WEBHOOK != '' && failure() env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests @@ -147,13 +154,13 @@ jobs: teardown: name: teardown - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest needs: tests steps: # テスト成功時はこちらのステップが実行される - name: Slack Notification on Success - if: success() uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' && success() env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests diff --git a/Model/Behavior/QuestionnaireAnswerTextBehavior.php b/Model/Behavior/QuestionnaireAnswerTextBehavior.php index 996013f..d7d57ab 100644 --- a/Model/Behavior/QuestionnaireAnswerTextBehavior.php +++ b/Model/Behavior/QuestionnaireAnswerTextBehavior.php @@ -69,6 +69,7 @@ public function answerMaxLength($model, $data, $question, $max) { * @param array $question 回答データに対応する質問 * @param array $allAnswers 入力された回答すべて * @return bool + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function answerTextValidation($model, $data, $question, $allAnswers) { if (! in_array($question['question_type'], $this->_textValidateType)) { @@ -77,7 +78,7 @@ public function answerTextValidation($model, $data, $question, $allAnswers) { $ret = true; // 数値型回答を望まれている場合 if ($question['question_type_option'] == QuestionnairesComponent::TYPE_OPTION_NUMERIC) { - if (!Validation::numeric($data['answer_value'])) { + if (mb_strlen($data['answer_value']) !== 0 && !Validation::numeric($data['answer_value'])) { $ret = false; $model->validationErrors['answer_value'][] = __d('questionnaires', 'Number required'); } @@ -86,7 +87,7 @@ public function answerTextValidation($model, $data, $question, $allAnswers) { $data['answer_value'], intval($question['min']), intval($question['max'])); - if (!$rangeRes) { + if (mb_strlen($data['answer_value']) !== 0 && !$rangeRes) { $ret = false; $model->validationErrors['answer_value'][] = __d('questionnaires', 'Please enter the answer between %s and %s.', diff --git a/Model/QuestionnaireAnswerSummary.php b/Model/QuestionnaireAnswerSummary.php index 2441f21..f6cd2ea 100644 --- a/Model/QuestionnaireAnswerSummary.php +++ b/Model/QuestionnaireAnswerSummary.php @@ -113,11 +113,13 @@ class QuestionnaireAnswerSummary extends QuestionnairesAppModel { */ public function saveAnswerStatus($questionnaire, $summary, $status) { $summary['QuestionnaireAnswerSummary']['answer_status'] = $status; + if ($status == QuestionnairesComponent::ACTION_ACT) { + // サマリの状態を完了にして確定する + $summary['QuestionnaireAnswerSummary']['answer_time'] = (new NetCommonsTime())->getNowDatetime(); + } if ($status == QuestionnairesComponent::ACTION_ACT && $questionnaire['Questionnaire']['is_answer_mail_send']) { - // サマリの状態を完了にして確定する - $summary['QuestionnaireAnswerSummary']['answer_time'] = (new NetCommonsTime())->getNowDatetime(); // メールのembed のURL設定を行っておく $url = NetCommonsUrl::actionUrl(array( 'controller' => 'questionnaire_blocks', diff --git a/Model/QuestionnaireAnswerSummaryCsv.php b/Model/QuestionnaireAnswerSummaryCsv.php index 781fc2c..578f5b8 100644 --- a/Model/QuestionnaireAnswerSummaryCsv.php +++ b/Model/QuestionnaireAnswerSummaryCsv.php @@ -257,7 +257,12 @@ protected function _getRows($questionnaire, $summary, $answers) { $cols = array(); $cols[] = $this->_getUserName($questionnaire, $summary); - $cols[] = $summary['QuestionnaireAnswerSummaryCsv']['modified']; + if (isset($summary['QuestionnaireAnswerSummaryCsv']['answer_time'])) { + $anserTime = $summary['QuestionnaireAnswerSummaryCsv']['answer_time']; + } else { + $anserTime = $summary['QuestionnaireAnswerSummaryCsv']['modified']; + } + $cols[] = $anserTime; $cols[] = $summary['QuestionnaireAnswerSummaryCsv']['answer_number']; foreach ($questionnaire['QuestionnairePage'] as $page) { diff --git a/Test/Case/Controller/QuestionnaireAnswersController/ViewTest.php b/Test/Case/Controller/QuestionnaireAnswersController/ViewTest.php index 5949eef..e8c3edb 100644 --- a/Test/Case/Controller/QuestionnaireAnswersController/ViewTest.php +++ b/Test/Case/Controller/QuestionnaireAnswersController/ViewTest.php @@ -325,7 +325,8 @@ public function testGetShuffle() { 'action' => 'view', 'frame_id' => 6, 'block_id' => 2, - 'key' => 'questionnaire_4' + 'key' => 'questionnaire_4', + '?' => ['lang' => 'ja'] ); $assert = array('method' => 'assertTextContains', 'expected' => __d('questionnaires', 'This questionnaire is being temporarily stored . You can questionnaire test before performed in this page . If you want to modify or change the questionnaire , you will be able to edit by pressing the [ Edit question ] button in the upper-right corner .')); diff --git a/VERSION.txt b/VERSION.txt index fa7adc7..86fb650 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.5 +3.3.7