-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend/course_admin] add additional course fields (#825)
- Loading branch information
Showing
6 changed files
with
165 additions
and
5 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
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,53 @@ | ||
""" | ||
Module definition for AdditionalField class | ||
-*- coding: utf-8 -*- | ||
This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for | ||
more information about the licensing of this file. | ||
""" | ||
from inginious.common.field_types import FieldTypes | ||
|
||
|
||
class AdditionalField: | ||
""" | ||
This class represent extra field that can be added to a course. | ||
""" | ||
|
||
def __init__(self, field_id, description, field_type): | ||
self._id = field_id | ||
self._description = description | ||
if field_type in [field.value for field in FieldTypes]: | ||
self._type = field_type | ||
else: | ||
raise Exception("Field type not correct") | ||
|
||
def __eq__(self, other): | ||
return self._id == other._id | ||
|
||
def __hash__(self): | ||
return hash(self._id) | ||
|
||
def get_id(self): | ||
""" | ||
:return: id of the additional field | ||
""" | ||
return self._id | ||
|
||
def get_description(self): | ||
""" | ||
:return: description of the additional field | ||
""" | ||
return self._description | ||
|
||
def get_type_name(self): | ||
"""" | ||
:return: type name of the additional field | ||
""" | ||
return FieldTypes(self._type).name | ||
|
||
def get_type(self): | ||
""" | ||
:return: type of the additional field | ||
""" | ||
return self._type |
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,18 @@ | ||
""" | ||
Module definition for FieldTypes class | ||
-*- coding: utf-8 -*- | ||
This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for | ||
more information about the licensing of this file. | ||
""" | ||
from enum import Enum | ||
|
||
|
||
class FieldTypes(Enum): | ||
""" | ||
A class used to represent a field type. Based on Enums. | ||
""" | ||
INTEGER = 1 | ||
STRING = 2 | ||
BOOLEAN = 3 |
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
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
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