1<?php 2 3require_once 'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Exception/ilAssLacException.php'; 4require_once 'Modules/TestQuestionPool/classes/questions/LogicalAnswerCompare/Exception/ilAssLacFormAlertProvider.php'; 5 6/** 7 * Class ExpressionNotSupportedByQuestion 8 * @package 9 * 10 * Date: 25.03.13 11 * Time: 15:15 12 * @author Thomas Joußen <tjoussen@databay.de> 13 * @author Björn Heyser <bheyser@databay.de> 14 */ 15class ilAssLacExpressionNotSupportedByQuestion extends ilAssLacException implements ilAssLacFormAlertProvider 16{ 17 /** 18 * @var string 19 */ 20 protected $expression; 21 22 /** 23 * @var int 24 */ 25 protected $question_index; 26 27 /** 28 * @param string $expression 29 * @param int $question_index 30 */ 31 public function __construct($expression, $question_index) 32 { 33 $this->expression = $expression; 34 $this->question_index = $question_index; 35 36 if ($this->getQuestionIndex() === null) { 37 $msg = sprintf( 38 'The expression "%s" is not supported by the current question', 39 $this->getExpression() 40 ); 41 } else { 42 $msg = sprintf( 43 'The expression "%s" is not supported by the question with index "Q%s"', 44 $this->getExpression(), 45 $this->getQuestionIndex() 46 ); 47 } 48 49 parent::__construct($msg); 50 } 51 52 /** 53 * @return int 54 */ 55 public function getQuestionIndex() 56 { 57 return $this->question_index; 58 } 59 60 /** 61 * @return string 62 */ 63 public function getExpression() 64 { 65 return $this->expression; 66 } 67 68 /** 69 * @param ilLanguage $lng 70 * @return string 71 */ 72 public function getFormAlert(ilLanguage $lng) 73 { 74 if ($this->getQuestionIndex() === null) { 75 return sprintf( 76 $lng->txt("ass_lac_expression_not_supported_by_cur_question"), 77 $this->getExpression() 78 ); 79 } 80 81 return sprintf( 82 $lng->txt("ass_lac_expression_not_supported_by_question"), 83 $this->getQuestionIndex(), 84 $this->getExpression() 85 ); 86 } 87} 88