Commit 49c05b2f authored by Raph El's avatar Raph El

Answer validation

parent 5d5ed643
......@@ -16,6 +16,7 @@
'directory'=>'survey.controllers.answer.DirectoryAction',
'get' => 'survey.controllers.answer.GetAction',
'sendmail' => 'survey.controllers.answer.mail.SendAction',
'validate' => 'survey.controllers.answer.ValidateAction',
);
}
public function actionViews($tpl="survey.views.tpls.forms.cplx.answers"){
......
<?php
class ValidateAction extends CAction
{
public function run($id=null, $type=null , $tpl=null)
{
$res = Answer::validate($_POST);
//Rest::json($_POST);
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -364,5 +364,20 @@ class Answer{
}
}
public static function validate($params){
$costum = CacheHelper::getCostum();
$set = array();
if(Costum::isSameFunction("answerValidate")){
$paramBeforeValidate = Costum::sameFunction("answerValidate", $params);
}
$set["validated"] = true;
PHDB::update(Answer::COLLECTION,
array( "_id" => new MongoId((string)$params["answerId"])),
array( '$set' => $set ) );
$res = array('result' => true, "msg" => "Valider");
return $res;
}
}
?>
\ No newline at end of file
<?php
if($mode != "pdf"){
?>
<div class="">
<label for="<?php echo $key ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<div class="text-center">
<button class="btn btn-primary" id="validation<?php echo $kunik ?>">Validation</button>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/validate.php");
$("#validation<?php echo $kunik ?>").click(function(){
var params = {
answerId : answerId,
answer : answerObj.answers
};
ajaxPost(
null,
baseUrl+"/survey/answer/validate",
params,
function(data){
toastr.success("Le formulaire à été soumis");
},
function(data){
toastr.error("Un soucis est apparue. Contacter l'administrateur");
}
);
});
});
</script>
<?php } ?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment