|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Models\Submission; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
6
|
|
|
use Illuminate\Support\Facades\DB; |
|
7
|
|
|
use App\Models\CompilerModel; |
|
8
|
|
|
|
|
9
|
|
|
class StatusModel extends Model |
|
10
|
|
|
{ |
|
11
|
|
|
protected $tableName="submission"; |
|
12
|
|
|
protected $extractModels=[ |
|
13
|
|
|
"SubmissionModel"=>null |
|
14
|
|
|
]; |
|
15
|
|
|
|
|
16
|
|
|
public function __construct($submissionModel) |
|
17
|
|
|
{ |
|
18
|
|
|
$this->extractModels["SubmissionModel"]=$submissionModel; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function getJudgeStatus($sid, $uid) |
|
22
|
|
|
{ |
|
23
|
|
|
$status=$this->extractModels["SubmissionModel"]->basic($sid); |
|
|
|
|
|
|
24
|
|
|
if (empty($status)) { |
|
25
|
|
|
return []; |
|
26
|
|
|
} |
|
27
|
|
|
if ($status["share"]==1 && $status["cid"]) { |
|
28
|
|
|
$end_time=strtotime(DB::table("contest")->where(["cid"=>$status["cid"]])->select("end_time")->first()["end_time"]); |
|
29
|
|
|
if (time()<$end_time) { |
|
30
|
|
|
$status["solution"]=null; |
|
31
|
|
|
$status['compile_info']="You don't have the permission to view this compile info."; |
|
32
|
|
|
} |
|
33
|
|
|
} |
|
34
|
|
|
if ($status["share"]==0 && $status["uid"]!=$uid) { |
|
35
|
|
|
$status["solution"]=null; |
|
36
|
|
|
$status['compile_info']="You don't have the permission to view this compile info."; |
|
37
|
|
|
} |
|
38
|
|
|
$compilerModel=new CompilerModel(); |
|
39
|
|
|
$status["lang"]=$compilerModel->detail($status["coid"])["lang"]; |
|
40
|
|
|
$status["owner"]=$uid==$status["uid"]; |
|
41
|
|
|
return $status; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function downloadCode($sid, $uid) |
|
45
|
|
|
{ |
|
46
|
|
|
$status=DB::table($this->tableName)->where(['sid'=>$sid])->first(); |
|
47
|
|
|
if (empty($status) || ($status["share"]==0 && $status["uid"]!=$uid)) { |
|
48
|
|
|
return []; |
|
49
|
|
|
} |
|
50
|
|
|
$lang=DB::table("compiler")->where(['coid'=>$status["coid"]])->first()["lang"]; |
|
51
|
|
|
$curLang=isset($this->extractModels["SubmissionModel"]->langConfig[$lang]) ? $this->extractModels["SubmissionModel"]->langConfig[$lang] : $this->extractModels["SubmissionModel"]->langConfig["plaintext"]; |
|
52
|
|
|
return [ |
|
53
|
|
|
"content"=>$status["solution"], |
|
54
|
|
|
"name"=>$status["submission_date"].$curLang["extensions"][0], |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getProblemStatus($pid, $uid, $cid=null) |
|
59
|
|
|
{ |
|
60
|
|
|
if ($cid) { |
|
61
|
|
|
$end_time=strtotime(DB::table("contest")->where(["cid"=>$cid])->select("end_time")->first()["end_time"]); |
|
62
|
|
|
// Get the very first AC record |
|
63
|
|
|
$ac=DB::table($this->tableName)->where([ |
|
64
|
|
|
'pid'=>$pid, |
|
65
|
|
|
'uid'=>$uid, |
|
66
|
|
|
'cid'=>$cid, |
|
67
|
|
|
'verdict'=>'Accepted' |
|
68
|
|
|
])->where("submission_date", "<", $end_time)->orderBy('submission_date', 'desc')->first(); |
|
69
|
|
|
if (empty($ac)) { |
|
70
|
|
|
$pac=DB::table($this->tableName)->where([ |
|
71
|
|
|
'pid'=>$pid, |
|
72
|
|
|
'uid'=>$uid, |
|
73
|
|
|
'cid'=>$cid, |
|
74
|
|
|
'verdict'=>'Partially Accepted' |
|
75
|
|
|
])->where("submission_date", "<", $end_time)->orderBy('submission_date', 'desc')->first(); |
|
76
|
|
|
return empty($pac) ? DB::table($this->tableName)->where(['pid'=>$pid, 'uid'=>$uid, 'cid'=>$cid])->where("submission_date", "<", $end_time)->orderBy('submission_date', 'desc')->first() : $pac; |
|
77
|
|
|
} else { |
|
78
|
|
|
return $ac; |
|
79
|
|
|
} |
|
80
|
|
|
} else { |
|
81
|
|
|
$ac=DB::table($this->tableName)->where([ |
|
82
|
|
|
'pid'=>$pid, |
|
83
|
|
|
'uid'=>$uid, |
|
84
|
|
|
'cid'=>$cid, |
|
85
|
|
|
'verdict'=>'Accepted' |
|
86
|
|
|
])->orderBy('submission_date', 'desc')->first(); |
|
87
|
|
|
return empty($ac) ? DB::table($this->tableName)->where(['pid'=>$pid, 'uid'=>$uid, 'cid'=>$cid])->orderBy('submission_date', 'desc')->first() : $ac; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.