-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update if exercise have testcase
- Loading branch information
Showing
4 changed files
with
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package models | ||
|
||
import ( | ||
"encoding/json" | ||
"time" | ||
|
||
"github.com/google/uuid" | ||
) | ||
|
||
type LabExercise struct { | ||
ExerciseID uuid.UUID `gorm:"type:varchar(36);primaryKey;column:exercise_id"` | ||
ChapterID *uuid.UUID `gorm:"type:varchar(36);column:chapter_id"` | ||
Level *string `gorm:"type:enum('0','1','2','3','4','5','6')"` | ||
Name *string `gorm:"type:varchar(1024)"` | ||
Content *string `gorm:"type:mediumtext"` | ||
Testcase string `gorm:"type:enum('NO_INPUT','YES','UNDEFINED');not null;default:'NO_INPUT'"` | ||
Sourcecode *string `gorm:"type:varchar(50)"` | ||
FullMark int `gorm:"type:int;not null;default:10"` | ||
AddedDate time.Time `gorm:"type:datetime;not null;default:CURRENT_TIMESTAMP"` | ||
LastUpdate *time.Time `gorm:"type:datetime;default:CURRENT_TIMESTAMP"` | ||
UserDefinedConstraints *json.RawMessage `gorm:"type:json"` | ||
SuggestedConstraints *json.RawMessage `gorm:"type:json"` | ||
AddedBy *string `gorm:"type:varchar(40)"` | ||
CreatedBy *uuid.UUID `gorm:"type:varchar(36)"` | ||
} | ||
|
||
func (LabExercise) TableName() string { | ||
return "lab_exercises" | ||
} |
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,25 @@ | ||
package repositories | ||
|
||
import ( | ||
"github.com/Project-IPCA/ipca-worker-go-v2/models" | ||
"github.com/google/uuid" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type LabExerciseRepository struct { | ||
DB *gorm.DB | ||
} | ||
|
||
func NewLabExerciseRePository(db *gorm.DB) *LabExerciseRepository { | ||
return &LabExerciseRepository{ | ||
DB: db, | ||
} | ||
} | ||
|
||
func (labExerciseRepo *LabExerciseRepository) GetLabExerciseById(labExercise *models.LabExercise,exerciseId uuid.UUID) { | ||
labExerciseRepo.DB.Where("exercise_id",exerciseId).Find(labExercise) | ||
} | ||
|
||
func (labExerciseRepo *LabExerciseRepository) UpdateExerciseTestcaseEnum(labExercise *models.LabExercise,testcaseEnum string) { | ||
labExerciseRepo.DB.Model(labExercise).Update("testcase" , testcaseEnum) | ||
} |
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