assessment.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import * as LocalizedStringsService from "../services/localizedStringsService";
  2. import { Config } from "../util/config";
  3. const LocalizedStrings = LocalizedStringsService.getInstance();
  4. const AssessmentConfig = {
  5. max_instruction_count: 350250,
  6. suspend_threshold: 200,
  7. };
  8. export class Assessment {
  9. constructor (ast_code, exerciseType, testCases, domConsole) {
  10. this.ast_code = ast_code;
  11. this.exerciseType = exerciseType;
  12. this.testCases = testCases;
  13. this.domConsole = domConsole;
  14. this.old_config = JSON.parse(JSON.stringify(Config));
  15. Config.setConfig(AssessmentConfig);
  16. }
  17. runTest () {
  18. // abstract
  19. }
  20. showErrorMessage (errorID, ...args) {
  21. this.domConsole.err(LocalizedStrings.getError(errorID, args));
  22. }
  23. showInfoMessage (msgID, ...args) {
  24. this.domConsole.info(LocalizedStrings.getMessage(msgID, args));
  25. }
  26. writeToConsole (channel, msgType, msgID, ...args) {
  27. let msg = LocalizedStrings.getString(msgID, msgType);
  28. msg = LocalizedStrings.processString(msg, args);
  29. this.domConsole.writeRawHTML(msg, channel);
  30. }
  31. }