-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured code to take in the arguments instead of hardcoded paths.
- Loading branch information
Showing
3 changed files
with
130 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
from configobj import ConfigObj, Section | ||
|
||
def load_questions_file(f_name): | ||
obj = ConfigObj(f_name, interpolation=True) | ||
f_name = f_name.split("/") | ||
f_name = f_name[len(f_name)-1] | ||
return obj, load_questions(obj, f_name) | ||
|
||
def load_questions(obj, parent): | ||
qList = {} | ||
for c in obj: | ||
item = obj[c] | ||
if "question" in item: | ||
qList[parent + "/" + c] = item | ||
elif isinstance(item, Section): | ||
qList.update(load_questions(item, parent + "/" + c)) | ||
return qList | ||
|
||
def get_question(questions, key): | ||
return questions[key] | ||
|
||
def update_question(question, key, value): | ||
question[key] = value | ||
|
||
def save_changes(f_name, obj): | ||
obj.write(open(f_name, "wb")) | ||
|
||
if __name__ == "__main__": | ||
obj, questions = load_questions_file("csci320-2191/questionPool/chapter1.txt") | ||
question = get_question(questions, 'chapter1.txt/File System') | ||
update_question( question, 'points', 100) | ||
save_changes('test.txt', obj) | ||
|
||
#!/usr/bin/env python3 | ||
from configobj import ConfigObj, Section | ||
import os | ||
|
||
root_path = "../questions/" | ||
questionPool_path = "/questionPool/" | ||
|
||
|
||
def get_courses(): | ||
courses = [name for name in os.listdir(root_path) | ||
if os.path.isdir(os.path.join(root_path, name))] | ||
courses.sort() | ||
return courses | ||
|
||
def get_questions_files(course): | ||
files = os.listdir(root_path+course+questionPool_path) | ||
files.sort() | ||
return str(files).strip('[]') | ||
|
||
|
||
def load_questions_file(course, question_file): | ||
f_name = root_path + course + questionPool_path + question_file | ||
obj = ConfigObj(f_name, interpolation=True) | ||
f_name = f_name.split("/") | ||
f_name = f_name[len(f_name)-1] | ||
return obj, load_questions(obj, f_name) | ||
|
||
def load_questions(obj, parent): | ||
qList = {} | ||
for c in obj: | ||
item = obj[c] | ||
if "question" in item: | ||
qList[parent + "/" + c] = item | ||
elif isinstance(item, Section): | ||
qList.update(load_questions(item, parent + "/" + c)) | ||
return qList | ||
|
||
def get_question(questions, file, title): | ||
key = file+"/"+title | ||
return questions[key] | ||
|
||
def update_question(question, key, value): | ||
question[key] = value | ||
|
||
def save_changes(f_name, obj): | ||
obj.write(open(f_name, "wb")) | ||
|
||
if __name__ == "__main__": | ||
if not os._exists("../questions/"): | ||
root_path = "./questions/" | ||
obj, questions = load_questions_file("csci320-2191", "chapter1.txt") | ||
question = get_question(questions, 'chapter1.txt', 'File System') | ||
update_question( question, 'points', 100) | ||
save_changes('test.txt', obj) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
[File System] | ||
type = LongAnswer | ||
points = 100 | ||
question = What are 3 advantages of using a database system over a file system? | ||
solution = "loose coupling between application and data. Facilities provided for query and retrieval. More efficient, consistency, and easier maintenance" | ||
|
||
[Conceptual Data Model] | ||
maxQuestions = 1 | ||
[[1]] | ||
type = LongAnswer | ||
points = 3 | ||
question = What is the purpose of the conceptual data model. Who does it benefit and what artifacts are created? | ||
solution = The conceptual data model is used to share information between the business and development teams. The represent the business needs are an ER diagram is usually produced. | ||
[[2]] | ||
type = shortAnswer | ||
points = 3 | ||
question = "Ideally, what are the 3 data model types (layers)" | ||
solutions = Internal, Logical, External | ||
|
||
[KPIs] | ||
type = LongAnswer | ||
points = 3 | ||
question = What are the three key performance indicators of a database? | ||
solution = "Response time, throughput rate, space utilization" | ||
|
||
[Elements of a DB system] | ||
type = multipleChoice | ||
points = 2 | ||
question = Which is not an element of a database system | ||
correctAnswer = Four Layer Model | ||
wrongAnswers = Catalog, Users, Data Model | ||
|
||
[Data Independence] | ||
type = multipleChoice | ||
points = 2 | ||
question = What is the term used to describe when the physical model need not change when the logical model does? | ||
correctAnswer = Data Independence | ||
wrongAnswers = Model Independence, Physical Isolation, Logical Isolation | ||
|
||
[XML] | ||
type = TF | ||
question = XML is considered semi-structured data | ||
solution = true | ||
|
||
|
||
[DDL] | ||
type = shortAnswer | ||
question = What DB language is used to create the structure of the database | ||
solution = DDL | ||
|
||
[Catalog] | ||
type = shortAnswer | ||
question = What piece of your database (DBMS) holds the metadata for your system? | ||
solution = Catalog | ||
|
||
[ACID] | ||
type = shortAnswer | ||
points = 4 | ||
question = What are the properties of an ACID database (just name them) | ||
solutions = Atomic, Consistent, Isolation, Durable | ||
|
||
[Data Model vs Instance] | ||
maxQuestions = 1 | ||
[[Model]] | ||
type = TF | ||
question = A snapshot of your data at a given time is a data model | ||
solution = False | ||
[[Instance]] | ||
type = TF | ||
question = A snapshot of your data at a given time is a data instance | ||
solution = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters