Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sfcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush
sfcode
Commits
4303c873
Commit
4303c873
authored
Dec 10, 2020
by
Adarsh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comments servicees
parent
90b4f1ad
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2568 additions
and
1 deletion
+2568
-1
dc
dc
+2494
-0
src/app/file.service.ts
src/app/file.service.ts
+35
-0
src/app/problem.service.ts
src/app/problem.service.ts
+4
-0
src/app/question.service.ts
src/app/question.service.ts
+10
-1
src/app/run-code.service.ts
src/app/run-code.service.ts
+25
-0
No files found.
dc
0 → 100644
View file @
4303c873
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/app/file.service.ts
View file @
4303c873
/*! \file
This service file is used to implement different functionalities of file workspace like upload, save, create and delete
files and directories.
*/
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
File
}
from
'
./file
'
;
import
{
Observable
,
of
}
from
'
rxjs
'
;
...
...
@@ -10,6 +15,10 @@ import { User } from './user';
})
export
class
FileService
{
/*
Url variables to store the backend urls for post and get requests.
*/
saveUrl
=
'
http://localhost/sfcode/backend/filesave.php
'
;
uploadUrl
=
'
http://localhost/sfcode/backend/fileupload.php
'
;
fileListUrl
=
'
http://localhost/sfcode/backend/dir_tree.php
'
;
...
...
@@ -20,6 +29,10 @@ export class FileService {
constructor
(
private
http
:
HttpClient
)
{
}
/*
Temporary function to get files used for debugging.
*/
getFiles
():
Observable
<
File
[]
>
{
const
ret
:
File
[]
=
[];
...
...
@@ -38,28 +51,50 @@ export class FileService {
return
of
(
ret
);
}
/*
Function to upload a file to the database using file interface and a boolean whether it is an attempt to a question
or created in ide.
*/
upload
(
file
:
File
,
isAttempt
:
boolean
):
Observable
<
any
>
{
return
this
.
http
.
post
(
this
.
saveUrl
,
{
file
,
isAttempt
});
}
/*
Function to upload a file to the database using upload option, was used for debugging.
*/
upload2
(
file
):
Observable
<
any
>
{
const
formData
=
new
FormData
();
formData
.
append
(
'
file
'
,
file
,
file
.
name
);
return
this
.
http
.
post
(
this
.
uploadUrl
,
formData
);
}
/*
Function to delete a file from the database and server, by a post request, posting file, username and number of files .
*/
delete
(
file
:
any
,
isFile
:
boolean
,
username
:
string
,
nFiles
:
number
):
Observable
<
any
>
{
return
this
.
http
.
post
(
this
.
deleteUrl
,
{
file
,
isFile
,
username
,
nFiles
});
}
/*
Function to get files from the database and server, by a post request, posting username.
*/
getFileList
(
username
:
string
):
Observable
<
any
>
{
return
this
.
http
.
post
(
this
.
fileListUrl
,
{
username
});
}
/*
Function to get file's content from the database and server, by a post request, posting username and file's path.
*/
getFileContent
(
username
:
string
,
filepath
:
string
):
Observable
<
any
>
{
return
this
.
http
.
post
(
this
.
fileContentUrl
,
{
username
,
file_path
:
filepath
});
}
/*
Function to create a directory for a particular user on the server while posting username, directory name and it's path.
*/
createDirectory
(
username
:
string
,
dirname
:
string
,
path
:
string
):
Observable
<
any
>
{
console
.
log
(
username
,
dirname
,
path
);
return
this
.
http
.
post
(
this
.
createDirUrl
,
{
username
,
dirname
,
path
});
...
...
src/app/problem.service.ts
View file @
4303c873
/*! \file
This service file is used to get problems from a predefined const data structure and is used for debugging purposes only.
*/
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
Problem
}
from
'
./problem
'
;
import
{
Observable
,
of
}
from
'
rxjs
'
;
...
...
src/app/question.service.ts
View file @
4303c873
/*! \file
This service file is used to upload and get questions from the database.
*/
import
{
EventEmitter
,
Injectable
,
Output
}
from
'
@angular/core
'
;
import
{
map
}
from
'
rxjs/operators
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
...
...
@@ -15,11 +19,16 @@ export class QuestionService {
constructor
(
private
http
:
HttpClient
)
{
}
/*
This function is used to upload question from each user to database.
*/
uploadQues
(
ques
:
Question
):
Observable
<
any
>
{
// console.log(ques);
return
this
.
http
.
post
(
this
.
uploadUrl
,
ques
);
}
/*
This function is used to get questions from all user from database.
*/
getQues
():
Observable
<
Question
[]
>
{
return
this
.
http
.
get
<
Question
[]
>
(
this
.
getUrl
);
}
...
...
src/app/run-code.service.ts
View file @
4303c873
/*! \file
This service file is used to compile and execute file, and also to compile, execute and verify the code
written by user for compettition questions for correctness.
*/
import
{
Injectable
}
from
'
@angular/core
'
;
// import {Problem} from './problem';
import
{
Question
}
from
'
./question
'
;
...
...
@@ -17,10 +22,18 @@ export class RunCodeService {
constructor
(
private
httpClient
:
HttpClient
)
{
}
/*
This function is used to post the file data for compilation.
*/
compileFile
(
file
:
File
):
Observable
<
any
>
{
return
this
.
httpClient
.
post
(
this
.
baseUrl
+
'
compile.php
'
,
file
);
}
/*
This function is used to post the file data and custom input for execution.
*/
executeFile
(
file
:
File
,
input
:
string
):
Observable
<
any
>
{
return
this
.
httpClient
.
post
(
this
.
baseUrl
+
'
execute.php
'
,
{
file
,
...
...
@@ -28,6 +41,10 @@ export class RunCodeService {
});
}
/*
This function is used to verify the testcases while posting the file data and other relaated parameters to the backend.
*/
verifyTestcase
(
file
:
File
,
out
:
string
,
ind
:
number
,
isSubmit
:
number
):
Observable
<
any
>
{
return
this
.
httpClient
.
post
(
this
.
baseUrl
+
'
questions/check_output.php
'
,
{
title
:
file
.
filename
,
...
...
@@ -38,10 +55,18 @@ export class RunCodeService {
});
}
/*
This function is used to update the server about the result of user attempt to the question by a boolean.
*/
update
(
b
:
boolean
):
Observable
<
any
>
{
return
this
.
httpClient
.
put
(
this
.
baseUrl
+
'
update_correct.php
'
,
{
b
});
}
/*
This function is for debugging purposes.
*/
compileQuestionFile
(
ques
:
Question
,
code
:
string
[]):
Observable
<
any
>
{
if
(
Math
.
floor
(
Math
.
random
()
*
2
)
===
1
)
{
return
of
(
'
done
'
);
}
else
{
return
throwError
(
'
error
'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment