Example #1
0
 /**
  * entrywarnings
  *
  * @param xxx $hotpot
  * @return xxx
  */
 public function entrywarnings($hotpot)
 {
     $warnings = array();
     $canstart = true;
     if (!$hotpot->can_preview()) {
         if ($error = $hotpot->require_subnet()) {
             // IP-address is not in allowable range
             $warnings[] = $error;
             $canstart = false;
         }
         if ($error = $hotpot->require_isopen()) {
             // hotpot is not (yet) open
             $warnings[] = $error;
             $canstart = false;
         }
         if ($error = $hotpot->require_notclosed()) {
             // hotpot is (already) closed
             $warnings[] = $error;
             $canstart = false;
         }
         if ($error = $hotpot->require_entrycm()) {
             // minimum grade for previous activity not satisfied
             $warnings[] = $error;
             $canstart = false;
         }
         if ($error = $hotpot->require_delay('delay1')) {
             // delay1 has not expired yet
             $warnings[] = $error;
             $canstart = false;
         }
         if ($error = $hotpot->require_delay('delay2')) {
             // delay2 has not expired yet
             $warnings[] = $error;
             $canstart = false;
         }
         if ($error = $hotpot->require_moreattempts(true)) {
             // maximum number of attempts reached
             $warnings[] = $error;
             $canstart = false;
         }
         if ($canstart) {
             if ($error = $hotpot->require_password()) {
                 // password not given yet
                 $warnings[] = $error;
                 $canstart = false;
             }
         }
     }
     // cache the boolean flags in case they are needed later - see $this->view_attempt_button()
     $hotpot->can_start($canstart);
     if (count($warnings)) {
         return $this->box(html_writer::alist($warnings), 'generalbox', 'hotpotwarnings');
     } else {
         return '';
     }
 }