Пример #1
0
 public function getMessage()
 {
     if ($this->_user->isLoggedIn()) {
         $task = new DBTask();
         $reply = new DBReply();
         $taskSubmit = new TaskSubmit();
         //$date = new Date();
         $date = strtotime('now');
         $date1 = $date + 24 * 3600;
         $taskArray = $task->findWithDateBetween($date, $date1);
         //在task里寻找截止时间在$date和$date+1的;
         if ($taskArray) {
             foreach ($taskArray as $key => $value) {
                 if (!$taskSubmit->findWithUserAndTask($this->_user->data()->id, $value->id)) {
                     //查找数据库里有没有改学生提交作业的记录
                     array_push($this->_calendarArray, $value);
                     $message = '';
                     if ($this->_user->data()->group == "S") {
                         if ($value->type == "H") {
                             $message = "您的实验尚未完成,该试验为" . $value->title;
                         } else {
                             if ($value->type == "E") {
                                 $message = "您的作业尚未完成,该作业为" . $value->title;
                             }
                         }
                         $array = array('type' => 'task', 'taskId' => $value->id, 'message' => $message);
                         array_push($this->_messageArray, $array);
                     }
                 }
             }
         }
         $replyArray = $reply->findWithIdNotRead($this->_user->data()->id);
         if ($replyArray) {
             foreach ($replyArray as $key => $value) {
                 # code...
                 $sender = $this->_user->find($value->sender)->data()->name;
                 $array = array('type' => 'post', 'replyId' => $value->id, 'postId' => $value->post_id, 'message' => $sender . "在论坛帖子中回复了你");
                 array_push($this->_replyArray, $value);
                 array_push($this->_messageArray, $array);
             }
         }
         return $this->_messageArray;
     } else {
         return false;
     }
 }
Пример #2
0
 ?>
             <tr>
              
                 <?php 
 echo "<td>{$user->find($value1->user_id)->data()->username}</td>";
 echo "<td>{$user->find($value1->user_id)->data()->name}</td>";
 $totalGrade = 0;
 $totalImportance = 0;
 foreach ($taskAll as $key => $value) {
     $imp = $value->importance;
     $totalImportance += $imp;
 }
 if ($totalImportance != 0) {
     foreach ($taskAll as $key => $value) {
         $imp = $value->importance;
         $taskS = $taskSubmit->findWithUserAndTask($value1->user_id, $value->id);
         $grade = 0;
         if ($taskS) {
             $grade = $taskS->score;
         }
         $totalGrade += $grade * $imp / $totalImportance;
         echo "<td>{$grade}</td>\n";
     }
     //$totalGrade/=count($taskAll);
     $totalGrade = intval($totalGrade);
 } else {
     foreach ($taskAll as $key => $value) {
         $imp = $value->importance;
         $taskS = $taskSubmit->findWithUserAndTask($value1->user_id, $value->id);
         $grade = 0;
         if ($taskS) {