FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
moodle-assignment-type_github/oauth.php at master · hit-moodle/moodle-assignment-type_github · GitHub
hit-moodle
moodle-assignment-type_github
Repository navigation
Code
Issues
1
(1)
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
moodle-assignment-type_github
/
oauth.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (45 loc) · 1.85 KB
Breadcrumbs
moodle-assignment-type_github
/
oauth.php
Copy path
File metadata and controls
58 lines (45 loc) · 1.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
require
(
"
../../../../config.php
"
);
require
(
"
assignment.class.php
"
);
$
id
=
required_param
(
'
id
'
,
PARAM_INT
);
// Course Module ID
$
code
=
required_param
(
'
code
'
,
PARAM_ALPHANUMEXT
);
if
(!
$
cm
=
get_coursemodule_from_id
(
'
assignment
'
,
$
id
)) {
print_error
(
'
invalidcoursemodule
'
);
}
if
(!
$
assignment
=
$
DB
->
get_record
(
"
assignment
"
,
array
(
"
id
"
=>
$
cm
->
instance
))) {
print_error
(
'
invalidid
'
,
'
assignment
'
);
}
if
(!
$
course
=
$
DB
->
get_record
(
"
course
"
,
array
(
"
id
"
=>
$
assignment
->
course
))) {
print_error
(
'
coursemisconf
'
,
'
assignment
'
);
}
require_login
(
$
course
->
id
,
false
,
$
cm
);
$
context
=
get_context_instance
(
CONTEXT_MODULE
,
$
cm
->
id
);
if
(!
has_capability
(
'
mod/assignment:view
'
,
$
context
)) {
print_error
(
'
cannotviewassignment
'
,
'
assignment
'
);
}
if
(!
has_capability
(
'
mod/assignment:grade
'
,
$
context
)) {
print_error
(
'
cannotviewassignment
'
,
'
assignment
'
);
}
if
(
$
assignment
->
assignmenttype
!=
'
github
'
) {
print_error
(
'
invalidtype
'
,
'
assignment
'
);
}
$
PAGE
->
set_url
(
'
/mod/assignment/type/github/oauth.php
'
,
array
(
'
id
'
=>
$
id
));
$
PAGE
->
set_title
(
get_string
(
'
githubreposettinglist
'
,
'
assignment_github
'
));
$
PAGE
->
set_heading
(
$
course
->
fullname
);
$
PAGE
->
set_context
(
$
context
);
$
PAGE
->
set_cm
(
$
cm
);
$
PAGE
->
requires
->
css
(
'
/mod/assignment/type/
'
.
$
assignment
->
assignmenttype
.
'
/styles.css
'
);
$
assignmentinstance
=
new
assignment_github
(
$
cm
->
id
,
$
assignment
,
$
cm
,
$
course
);
$
extra
=
$
assignmentinstance
->
get_extra_settings
();
if
(!
empty
(
$
extra
)) {
$
server
=
$
ASSIGNMENT_GITHUB
->
code
[
$
extra
->
type
];
$
git
=
new
git
(
$
course
->
id
,
$
assignment
->
id
);
$
service
=
$
git
->
get_api_service
(
$
server
);
$
access_token
=
$
service
->
exchange_access_token
(
$
code
);
if
(!
empty
(
$
access_token
)) {
$
extra
->
data2
=
$
access_token
;
$
DB
->
update_record
(
'
assignment_github_extra
'
,
$
extra
);
}
}
$
url
=
new
moodle_url
(
"
/mod/assignment/view.php?id=
{
$
cm
->
id
}"
);
redirect
(
$
url
);
Back
|
FazBrowse Home
|
New Git URL