diff --git a/Controller/QuestionnaireAnswersController.php b/Controller/QuestionnaireAnswersController.php index 3f969d6..46ddc54 100644 --- a/Controller/QuestionnaireAnswersController.php +++ b/Controller/QuestionnaireAnswersController.php @@ -93,6 +93,9 @@ public function beforeFilter() { // 親クラスのbeforeFilterを済ませる parent::beforeFilter(); + // CDNキャッシュを作成しない + $this->response->header('Pragma', 'no-cache'); + // 現在の表示形態を調べておく list($this->__displayType) = $this->QuestionnaireFrameSetting->getQuestionnaireFrameSetting( Current::read('Frame.key') @@ -178,11 +181,6 @@ protected function _viewGuard() { !isset($this->request->data['QuestionnairePage']['page_sequence'])) { // 認証キーコンポーネントお約束: if ($quest['is_key_pass_use'] == QuestionnairesComponent::USES_USE) { - $this->AuthorizationKey->contentId = $quest['id']; - $this->AuthorizationKey->guard( - AuthorizationKeyComponent::OPERATION_EMBEDDING, - 'Questionnaire', - $this->__questionnaire); $this->setAction('key_auth'); return; } @@ -205,6 +203,15 @@ protected function _viewGuard() { * @return void */ public function key_auth() { + $this->AuthorizationKey->contentId = $this->__questionnaire['Questionnaire']['id']; + $this->AuthorizationKey->guard( + AuthorizationKeyComponent::OPERATION_EMBEDDING, + 'Questionnaire', + $this->__questionnaire); + if ($this->request->is('ajax')) { + return; + } + $isKeyPassUse = $this->__questionnaire['Questionnaire']['is_key_pass_use']; if ($isKeyPassUse != QuestionnairesComponent::USES_USE) { $this->_redirectAnswerPage(); @@ -342,11 +349,15 @@ public function view() { } } if (! ($this->request->is('post') && $nextPageSeq == $postPageSeq)) { - $summary = $this->QuestionnairesOwnAnswer->getProgressiveSummaryOfThisUser( - $questionnaireKey); - $setAnswers = $this->QuestionnaireAnswer->getProgressiveAnswerOfThisSummary( - $questionnaire, - $summary); + if (empty($this->request->params['requested'])) { + $summary = $this->QuestionnairesOwnAnswer->getProgressiveSummaryOfThisUser( + $questionnaireKey); + $setAnswers = $this->QuestionnaireAnswer->getProgressiveAnswerOfThisSummary( + $questionnaire, + $summary); + } else { + $setAnswers = []; + } $this->set('answers', $setAnswers); $this->request->data['QuestionnaireAnswer'] = $setAnswers; diff --git a/Model/QuestionnaireAnswer.php b/Model/QuestionnaireAnswer.php index c088642..6be4158 100644 --- a/Model/QuestionnaireAnswer.php +++ b/Model/QuestionnaireAnswer.php @@ -259,6 +259,13 @@ public function saveAnswer($data, $questionnaire, $summary) { if (! $targetQuestion) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } + + //HACK: 作りが悪いため、DELETE->INSERTで既存データを初期化してから登録する + $this->deleteAll([ + $this->alias . '.questionnaire_answer_summary_id' => $summaryId, + $this->alias . '.questionnaire_question_key' => $targetQuestionKey, + ], false); + // データ保存 // Matrixタイプの場合はanswerが配列になっているがsaveでかまわない // saveMany中で1回しかValidateしなくてよい関数のためのフラグ diff --git a/View/QuestionnaireAnswers/key_auth.ctp b/View/QuestionnaireAnswers/key_auth.ctp index 73687ba..4cb7d4e 100644 --- a/View/QuestionnaireAnswers/key_auth.ctp +++ b/View/QuestionnaireAnswers/key_auth.ctp @@ -8,8 +8,11 @@ * @license http://www.netcommons.org/license.txt NetCommons License * @copyright Copyright 2014, NetCommons Project */ +echo $this->NetCommonsHtml->script(array( + '/authorization_keys/js/key_auth_init.js' +)); ?> -
+
element('Questionnaires.Answers/answer_header'); ?> element('Questionnaires.Answers/answer_test_mode_header'); ?>