本文整理汇总了PHP中Exercise::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Exercise::model方法的具体用法?PHP Exercise::model怎么用?PHP Exercise::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exercise
的用法示例。
在下文中一共展示了Exercise::model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkCode
public function checkCode()
{
Helpers::normalizeCode($this->code);
if (!($this->exercise = Exercise::model()->findByAttributes(array('code' => trim($this->code))))) {
$this->addError('code', Yii::t('swu', 'The code you entered does not exist.'));
}
}
示例2: sendCodes
public function sendCodes($controller)
{
if (!($student = Student::model()->findByAttributes(array('email' => $this->email)))) {
return false;
}
$exercises = Exercise::model()->with('assignment')->sortByDuedate()->findAllByAttributes(array('student_id' => $student->id));
foreach ($exercises as $exercise) {
$exercise->link = Yii::app()->controller->createAbsoluteSslUrl('exercise/info', array('k' => $exercise->generateAckKey()));
}
$options = array();
if (Helpers::getYiiParam('addOriginatingIP')) {
$options['originating_IP'] = sprintf('[%s]', Yii::app()->request->userHostAddress);
}
return MailTemplate::model()->mailFromTemplate('send_codes', array($student->email => $student->name), array('student' => $student, 'exercises' => $exercises), $options);
}
示例3: checkCode
public function checkCode()
{
if ($this->getError('verifyCode')) {
return;
// we don't provide any information about the code if the captcha is not valid
}
Helpers::normalizeCode($this->code);
if ($this->exercise = Exercise::model()->findByAttributes(array('code' => trim($this->code)))) {
if (!$this->byteacher and $this->exercise->duedate < date('Y-m-d H:m:s', time() - $this->exercise->assignment->grace * 24 * 60 * 60)) {
$this->addError('code', Yii::t('swu', 'The code provided is not valid anymore (time expired on %date%).', array('%date%' => $this->exercise->duedate)));
return;
}
} elseif ($this->code) {
$this->addError('code', Yii::t('swu', 'The code provided is not valid.'));
return;
}
}
示例4: removeExercises
public function removeExercises($ids)
{
$result = array('removed' => array(), 'left' => array());
$exercises = Exercise::model()->ofAssignment($this->id)->forStudents($ids)->with('files')->findAll();
foreach ($exercises as $exercise) {
$id = $exercise->id;
if ($exercise && sizeof($exercise->files) > 0) {
$result['left'][] = $id;
continue;
// we won't delete exercises when files are uploaded
}
try {
$exercise->delete();
$result['removed'][] = $id;
} catch (Exception $e) {
$result['left'][] = $id;
// this should never happen
}
}
return $result;
}
示例5: loadModelByCode
public function loadModelByCode($code)
{
return $model = Exercise::model()->findByAttributes(array('code' => $code));
}
示例6: getExercises
public function getExercises()
{
return Exercise::model()->forStudent($this->id)->with('assignment')->findAll();
}