Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: accept javascript programming language #546

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions judgels-backends/judgels-grader-app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ENV RUSTUP_HOME /usr
ENV XDG_CACHE_HOME /tmp
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
ENV PATH $JAVA_HOME/bin:$PATH
ENV NODE_VERSION=18.0.0
ENV NVM_DIR=/root/.nvm

RUN apt-get update \
&& apt-get -y --no-install-recommends install software-properties-common gpg-agent \
Expand All @@ -40,6 +42,9 @@ RUN apt-get update \
&& ln -s /usr/bin/gcc-11 /usr/bin/gcc \
&& ln -s /usr/bin/g++-11 /usr/bin/g++ \
&& curl -sSf https://sh.rustup.rs/ | bash -s -- -y -q --default-toolchain=1.57.0 \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
kadeksuryam marked this conversation as resolved.
Show resolved Hide resolved
&& . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} \
&& cp $NVM_DIR/versions/node/v${NODE_VERSION}/bin/node /usr/bin/ \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /judgels/grader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import judgels.gabriel.languages.cpp.CppGradingLanguage;
import judgels.gabriel.languages.go.GoGradingLanguage;
import judgels.gabriel.languages.java.JavaGradingLanguage;
import judgels.gabriel.languages.javascript.JavascriptNode18GradingLanguage;
import judgels.gabriel.languages.pascal.PascalGradingLanguage;
import judgels.gabriel.languages.python.PyPy3GradingLanguage;
import judgels.gabriel.languages.python.Python3GradingLanguage;
Expand All @@ -33,6 +34,7 @@ public class GradingLanguageRegistry {
new PyPy3GradingLanguage(),
new Python3GradingLanguage(),
new Rust2021GradingLanguage(),
new JavascriptNode18GradingLanguage(),
new OutputOnlyGradingLanguage());

private static final List<GradingLanguage> VISIBLE_LANGUAGES = LANGUAGES.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package judgels.gabriel.languages.javascript;

import com.google.common.collect.ImmutableList;
import java.util.List;
import judgels.gabriel.api.GradingLanguage;

public class JavascriptNode18GradingLanguage implements GradingLanguage {
kadeksuryam marked this conversation as resolved.
Show resolved Hide resolved
@Override
public String getName() {
return "Javascript (Node.js 18)";
kadeksuryam marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public boolean isVisible() {
return true;
}

@Override
public List<String> getAllowedExtensions() {
return ImmutableList.of("js");
}

@Override
public List<String> getCompilationCommand(String sourceFilename, String... sourceFilenames) {
return ImmutableList.of("/bin/true");
}

@Override
public String getExecutableFilename(String sourceFilename) {
return sourceFilename;
}

@Override
public List<String> getExecutionCommand(String sourceFilename) {
return ImmutableList.of("/usr/bin/node", sourceFilename);
}
}
5 changes: 5 additions & 0 deletions judgels-client/src/modules/api/gabriel/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const gradingLanguageNamesMap = {
Python3: 'Python 3',
PyPy3: 'PyPy 3',
Rust2021: 'Rust 2021',
JavascriptNode18: 'Javascript (Node.js 18)',
kadeksuryam marked this conversation as resolved.
Show resolved Hide resolved
OutputOnly: '-',
};

Expand All @@ -28,6 +29,7 @@ export const gradingLanguageFamiliesMap = {
Python3: 'Python',
PyPy3: 'Python',
Rust2021: 'Rust',
JavascriptNode18: 'Javascript',
};

export const gradingLanguageFilenameExtensionsMap = {
Expand All @@ -41,6 +43,7 @@ export const gradingLanguageFilenameExtensionsMap = {
Python3: ['py'],
PyPy3: ['py'],
Rust2021: ['rs'],
JavascriptNode18: ['js'],
OutputOnly: ['zip'],
};

Expand All @@ -55,6 +58,7 @@ export const gradingLanguageSyntaxHighlighterValueMap = {
Python3: 'python',
PyPy3: 'python',
Rust2021: 'rust',
JavascriptNode18: 'javascript',
OutputOnly: '',
};

Expand All @@ -69,6 +73,7 @@ export const gradingLanguageEditorSubmissionFilenamesMap = {
Python3: 'solution.py',
PyPy3: 'solution.py',
Rust2021: 'solution.rs',
JavascriptNode18: 'solution.js',
};

export const gradingLanguageEditorSubmissionHintsMap = {
Expand Down