FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
javascripting/problem.js at master · OWLOOKIT/javascripting · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
OWLOOKIT
/
javascripting
Public
forked from
workshopper/javascripting
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
javascripting
/
problem.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (38 loc) · 1.51 KB
Breadcrumbs
javascripting
/
problem.js
Copy path
File metadata and controls
52 lines (38 loc) · 1.51 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
var
path
=
require
(
'path'
)
;
var
getFile
=
require
(
'./get-file'
)
;
var
compare
=
require
(
'./compare-solution'
)
;
module
.
exports
=
function
createProblem
(
dirname
)
{
var
exports
=
{
}
;
var
problemName
=
dirname
.
split
(
path
.
sep
)
;
problemName
=
problemName
[
problemName
.
length
-
1
]
;
exports
.
init
=
function
(
workshopper
)
{
var
postfix
=
workshopper
.
lang
===
'en'
?
''
:
'_'
+
workshopper
.
lang
;
this
.
problem
=
getFile
(
path
.
join
(
dirname
,
'problem'
+
postfix
+
'.md'
)
)
;
this
.
solution
=
getFile
(
path
.
join
(
dirname
,
'solution'
+
postfix
+
'.md'
)
)
;
this
.
solutionPath
=
path
.
resolve
(
dirname
,
"../../solutions"
,
problemName
,
"index.js"
)
;
this
.
troubleshootingPath
=
path
.
join
(
dirname
,
'../../troubleshooting'
+
postfix
+
'.md'
)
;
}
exports
.
verify
=
function
(
args
,
cb
)
{
var
attemptPath
=
path
.
resolve
(
process
.
cwd
(
)
,
args
[
0
]
)
;
compare
(
this
.
solutionPath
,
attemptPath
,
function
(
match
,
obj
)
{
if
(
match
)
{
return
cb
(
true
)
;
}
if
(
!
obj
)
{
// An error occured, we've already printed an error
return
;
}
var
message
=
getFile
(
this
.
troubleshootingPath
)
;
message
=
message
.
replace
(
/
%
s
o
l
u
t
i
o
n
%
/
g
,
obj
.
solution
)
;
message
=
message
.
replace
(
/
%
a
t
t
e
m
p
t
%
/
g
,
obj
.
attempt
)
;
message
=
message
.
replace
(
/
%
d
i
f
f
%
/
g
,
obj
.
diff
)
;
message
=
message
.
replace
(
/
%
f
i
l
e
n
a
m
e
%
/
g
,
args
[
0
]
)
;
exports
.
fail
=
message
;
cb
(
false
)
;
}
.
bind
(
this
)
)
;
}
;
exports
.
run
=
function
(
args
)
{
require
(
path
.
resolve
(
process
.
cwd
(
)
,
args
[
0
]
)
)
;
}
;
return
exports
;
}
Back
|
FazBrowse Home
|
New Git URL