Пример #1
0
 public function not_accept()
 {
     $url = 'http://www.plurk.com/p/6esun8#response-1799208331';
     $annotation = $this->annotation->find('annotation_id', 1017);
     $annotation = new Annotation(1017);
     $original_annotation_id = $annotation->get_id();
     $recommend = new Annotation_recommend();
     $recommend->set_webpage($url);
     $recommend->set_recommended($annotation);
     $recommend->update();
     $annotation = new Annotation(1017);
     $recommend = $annotation->get_recommend();
     //-----------------------------------------------
     $length = $annotation->get_scope_length();
     $recommend = $annotation->get_recommend();
     $annotation = $recommend->set_accept(FALSE);
     $length = $annotation->get_scope_length();
     $this->unit->run($annotation->get_scope_length(), $length, '拒絕推薦之後,由於並沒有改變標註,所以長度還是一樣');
     $this->unit->run($annotation->get_id(), $original_annotation_id, '拒絕推薦之後,這個標註應該跟上面的一樣');
     $recommend = $annotation->get_recommend();
     $this->unit->run($recommend, NULL, '拒絕推薦之後,標註就沒有推薦了');
     $annotation = $this->annotation->find('annotation_id', 1017);
     $this->unit->run($annotation->get_id(), 'is_int', '拒絕推薦之後,原本的標註仍在');
     //        $this->unit->run($test_result
     //                , $expected_result
     //                , $test_name);
     //context_complete();
     unit_test_report($this, __METHOD__);
 }
Пример #2
-1
 /**
  * 設定推薦
  * @param Annotation $annotation
  * @return \Annotation_tutor
  */
 public function setup_recommend(Annotation $annotation)
 {
     //test_msg('Annotation_tutor->setup_recommend()', 1);
     $threshold = $this->_get_recommended_threshold();
     $score = $this->_get_integrated_score($annotation);
     //test_msg('Annotation_tutor->setup_recommend()', 2);
     if ($score < $threshold) {
         //test_msg('Annotation_tutor->setup_recommend()', 3);
         //如果分數到達門檻,才進行推薦,否則不作推薦
         $recommend_annotation = $this->_find_recommend_annotation($annotation);
         $this->_CI_load('library', 'recommend/Annotation_recommend', 'annotation_recommend');
         $cond = array('recommended_annotation_id' => $annotation->get_id(), 'recommended_webpage_id' => $this->webpage->get_id());
         $recommend = $this->CI->annotation_recommend->find($cond);
         //test_msg('Annotation_tutor->setup_recommend()', 4);
         if (is_null($recommend)) {
             $recommend = new Annotation_recommend();
             $recommend->set_webpage($this->webpage);
             $recommend->set_recommended($annotation);
         }
         //test_msg('Annotation_tutor->setup_recommend()', 5);
         if (isset($recommend_annotation)) {
             $recommend->set_recommend_by($recommend_annotation);
         }
         //test_msg('Annotation_tutor->setup_recommend() 6', 6);
         // @TODO #170 20140410 這個步驟會出錯
         $recommend->update();
         //加入通知
         $trigger_resource = $annotation;
         $association_user = $annotation->get_user();
         //test_msg('Annotation_tutor->setup_recommend()', 7);
         $this->_CI_load('library', 'kals_actor/Notification_recommended', 'ntification_recommended');
         $notification = $this->CI->ntification_recommended->create_notification($association_user, $trigger_resource);
         if (is_null($notification)) {
             handle_error($this->lang->line('notification.recommend.create_notification.exception'));
         }
         //test_msg('Annotation_tutor->setup_recommend()', 8);
         $annotation->set_recommend($recommend);
         //test_msg('Annotation_tutor->setup_recommend()', 9);
     }
     return $this;
 }