
import json
import os


# Make this a class so we can pass conf_dir value. We want this so
# testings is easier.

class ProblemLibs:
    def __init__(self,conf_dir=os.path.expanduser('~')):
        self.conf_dir = conf_dir

    @classmethod
    def get_dir(cls):
        with open('/etc/mathdeck/mathdeckconf.json') as file:
                data = json.load(file)
        return data['prob_lib_dir']



import json
import os


# Make this a class so we can pass conf_dir value. We want this so
# testings is easier.

class ProblemLibs:
    """
    By default, mathdeck looks for the settings file in
    /etc/mathdeck/mathdeckconf.json. We can change where get_dir() looks
    for the settings file in tests
    """
    default_file = '/etc/mathdeck/mathdeckconf.json'
    default_lib_name ='main_lib'

    def __init__(self):
        pass

    @classmethod
    def get_dir(cls, settings_file = default_file, lib_name = default_lib_name):
        with open(settings_file) as file:
                data = json.load(file)
        return data["problem_libs"][lib_name]


Fix problem file importing bug
Fix problem file importing bug

  
  import json
  import os
  
  
  # Make this a class so we can pass conf_dir value. We want this so
  # testings is easier.
  
  class ProblemLibs:
-     def __init__(self,conf_dir=os.path.expanduser('~')):
-         self.conf_dir = conf_dir
+     """
+     By default, mathdeck looks for the settings file in
+     /etc/mathdeck/mathdeckconf.json. We can change where get_dir() looks
+     for the settings file in tests
+     """
+     default_file = '/etc/mathdeck/mathdeckconf.json'
+     default_lib_name ='main_lib'
+ 
+     def __init__(self):
+         pass
  
      @classmethod
-     def get_dir(cls):
-         with open('/etc/mathdeck/mathdeckconf.json') as file:
+     def get_dir(cls, settings_file = default_file, lib_name = default_lib_name):
+         with open(settings_file) as file:
                  data = json.load(file)
-         return data['prob_lib_dir']
+         return data["problem_libs"][lib_name]
  
  
Fix problem file importing bug
## Code Before:

import json
import os


# Make this a class so we can pass conf_dir value. We want this so
# testings is easier.

class ProblemLibs:
    def __init__(self,conf_dir=os.path.expanduser('~')):
        self.conf_dir = conf_dir

    @classmethod
    def get_dir(cls):
        with open('/etc/mathdeck/mathdeckconf.json') as file:
                data = json.load(file)
        return data['prob_lib_dir']


## Instruction:
Fix problem file importing bug
## Code After:

import json
import os


# Make this a class so we can pass conf_dir value. We want this so
# testings is easier.

class ProblemLibs:
    """
    By default, mathdeck looks for the settings file in
    /etc/mathdeck/mathdeckconf.json. We can change where get_dir() looks
    for the settings file in tests
    """
    default_file = '/etc/mathdeck/mathdeckconf.json'
    default_lib_name ='main_lib'

    def __init__(self):
        pass

    @classmethod
    def get_dir(cls, settings_file = default_file, lib_name = default_lib_name):
        with open(settings_file) as file:
                data = json.load(file)
        return data["problem_libs"][lib_name]

