Skip to content

Commit

Permalink
feat/#113: 강의평가, 시험 정보 신고 기능 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jinukeu committed Jan 23, 2024
1 parent fe1d6a2 commit 885c9d1
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.suwiki.data.lectureevaluation.viewerreporter.datasource
interface RemoteExamReportDataSource {

suspend fun reportExam(
examIdx: Long,
content: String = "",
examIdx: Long,
content: String = "",
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.suwiki.core.model.lectureevaluation.exam.MyExamEvaluation
import com.suwiki.core.ui.extension.decodeFromUri
import com.suwiki.domain.lectureevaluation.editor.usecase.exam.PostExamEvaluationUseCase
import com.suwiki.domain.lectureevaluation.editor.usecase.exam.UpdateExamEvaluationUseCase
import com.suwiki.feature.lectureevaluation.editor.lectureevaluation.LectureEvaluationEditorSideEffect
import com.suwiki.feature.lectureevaluation.editor.navigation.EvaluationEditorRoute
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.toPersistentList
Expand Down Expand Up @@ -81,8 +80,11 @@ class ExamEvaluationEditorViewModel @Inject constructor(
return@intent
}

if (isEditMode) updateExamEvaluation()
else postExamEvaluation()
if (isEditMode) {
updateExamEvaluation()
} else {
postExamEvaluation()
}
}

private fun postExamEvaluation() = intent {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.suwiki.feature.lectureevaluation.editor.examevaluation

import com.suwiki.core.model.enums.ExamLevel
import com.suwiki.feature.lectureevaluation.editor.lectureevaluation.LectureEvaluationEditorSideEffect
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ fun ExamEvaluationEditorScreen(
Spacer(modifier = Modifier.height(14.dp))

SuwikiSelectionContainer(
title = uiState.selectedExamType?.ifEmpty { stringResource(R.string.word_choose_test_type) } ?: stringResource(R.string.word_choose_test_type),
title = uiState.selectedExamType?.ifEmpty { stringResource(R.string.word_choose_test_type) }
?: stringResource(R.string.word_choose_test_type),
onClick = onClickExamTypeButton,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.suwiki.feature.lectureevaluation.editor.lectureevaluation
import com.suwiki.core.model.enums.GradeLevel
import com.suwiki.core.model.enums.HomeworkLevel
import com.suwiki.core.model.enums.TeamLevel
import com.suwiki.feature.lectureevaluation.editor.examevaluation.ExamEvaluationEditorSideEffect
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ import com.suwiki.core.model.enums.GradeLevel
import com.suwiki.core.model.enums.HomeworkLevel
import com.suwiki.core.model.enums.TeamLevel
import com.suwiki.core.model.lectureevaluation.lecture.MyLectureEvaluation
import com.suwiki.core.model.user.User
import com.suwiki.core.ui.extension.decodeFromUri
import com.suwiki.domain.lectureevaluation.editor.usecase.lecture.PostLectureEvaluationUseCase
import com.suwiki.domain.lectureevaluation.editor.usecase.lecture.UpdateLectureEvaluationUseCase
import com.suwiki.domain.user.usecase.GetUserInfoUseCase
import com.suwiki.feature.lectureevaluation.editor.examevaluation.ExamEvaluationEditorSideEffect
import com.suwiki.feature.lectureevaluation.editor.navigation.EvaluationEditorRoute
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.flow.catch
import kotlinx.serialization.json.Json
import org.orbitmvi.orbit.Container
import org.orbitmvi.orbit.ContainerHost
Expand Down Expand Up @@ -84,8 +80,11 @@ class LectureEvaluationEditorViewModel @Inject constructor(
return@intent
}

if (isEditMode) updateLectureEvaluation()
else postLectureEvaluation()
if (isEditMode) {
updateLectureEvaluation()
} else {
postLectureEvaluation()
}
}

private fun postLectureEvaluation() = intent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.orbitmvi.orbit.syntax.simple.intent
import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
import org.orbitmvi.orbit.viewmodel.container
import timber.log.Timber
import javax.inject.Inject

@HiltViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,11 @@ import com.suwiki.core.designsystem.theme.Primary
import com.suwiki.core.designsystem.theme.SuwikiTheme
import com.suwiki.core.designsystem.theme.White
import com.suwiki.core.model.enums.LectureEvaluationTab
import com.suwiki.core.model.lectureevaluation.exam.MyExamEvaluation
import com.suwiki.core.model.lectureevaluation.lecture.MyLectureEvaluation
import com.suwiki.core.ui.extension.OnBottomReached
import com.suwiki.core.ui.extension.collectWithLifecycle
import com.suwiki.core.ui.extension.encodeToUri
import com.suwiki.core.ui.extension.suwikiClickable
import com.suwiki.feature.lectureevaluation.viewerreporter.R
import com.suwiki.feature.lectureevaluation.viewerreporter.detail.component.SuwikiReviewStatisticsContainer
import kotlinx.serialization.json.Json
import me.onebone.toolbar.CollapsingToolbarScaffold
import me.onebone.toolbar.ExperimentalToolbarApi
import me.onebone.toolbar.ScrollStrategy
Expand Down Expand Up @@ -227,7 +223,7 @@ fun LectureEvaluationDetailScreen(
semester = it.selectedSemester,
content = it.content,
rating = it.totalAvg,
onClickButton = { onClickLectureReportButton(it.id) }
onClickButton = { onClickLectureReportButton(it.id) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.lifecycle.ViewModel
import com.suwiki.core.model.enums.LectureEvaluationTab
import com.suwiki.core.model.exception.UserPointLackException
import com.suwiki.core.model.lectureevaluation.exam.MyExamEvaluation
import com.suwiki.core.model.lectureevaluation.lecture.LectureInfo
import com.suwiki.core.model.lectureevaluation.lecture.MyLectureEvaluation
import com.suwiki.core.ui.extension.encodeToUri
import com.suwiki.domain.lectureevaluation.viewerreporter.usecase.exam.BuyExamUseCase
Expand All @@ -20,7 +19,6 @@ import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.joinAll
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonPrimitive
import org.orbitmvi.orbit.Container
import org.orbitmvi.orbit.ContainerHost
import org.orbitmvi.orbit.syntax.simple.intent
Expand Down
1 change: 1 addition & 0 deletions feature/timetable/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ dependencies {
implementation(projects.domain.timetable)
implementation(libs.kotlinx.serialization.json)
implementation(libs.bundles.glance)
implementation(libs.compose.toolbar)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
Expand All @@ -31,6 +33,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -62,6 +65,9 @@ import com.suwiki.feature.timetable.openlecture.model.SchoolLevel
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.android.awaitFrame
import kotlinx.coroutines.launch
import me.onebone.toolbar.CollapsingToolbarScaffold
import me.onebone.toolbar.ScrollStrategy
import me.onebone.toolbar.rememberCollapsingToolbarScaffoldState
import org.orbitmvi.orbit.compose.collectAsState
import org.orbitmvi.orbit.compose.collectSideEffect

Expand Down Expand Up @@ -158,6 +164,8 @@ fun OpenLectureScreen(
) {
val context = LocalContext.current

val state = rememberCollapsingToolbarScaffoldState()

Column(
modifier = Modifier
.fillMaxSize()
Expand All @@ -169,62 +177,79 @@ fun OpenLectureScreen(
onClickTextButton = onClickCustomAdd,
)

Spacer(modifier = Modifier.size(12.dp))

Row(
modifier = Modifier.padding(horizontal = 24.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
FilterContainer(
filterName = stringResource(R.string.word_open_major),
value = uiState.selectedOpenMajor,
onClick = { onClickOpenMajorFilterContainer(uiState.selectedOpenMajor) },
)

FilterContainer(
filterName = stringResource(R.string.word_school_level),
value = stringResource(id = uiState.schoolLevel.stringResId),
onClick = onClickSchoolLevelFilterContainer,
)
}

SuwikiSearchBar(
modifier = Modifier.padding(top = 10.dp),
placeholder = stringResource(R.string.add_timetable_cell_search_bar_placeholder),
onClickSearchButton = onClickSearchButton,
value = uiState.searchValue,
onClickClearButton = onClickClearButton,
onValueChange = onValueChangeSearch,
)
CollapsingToolbarScaffold(
modifier = Modifier
.weight(1f),
state = state,
scrollStrategy = ScrollStrategy.EnterAlways,
toolbar = {
Spacer(
modifier = Modifier
.fillMaxWidth()
.height(32.dp),
)
Column(
modifier = Modifier.graphicsLayer {
alpha = state.toolbarState.progress
}
) {
Row(
modifier = Modifier.padding(horizontal = 24.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp),
) {
FilterContainer(
filterName = stringResource(R.string.word_open_major),
value = uiState.selectedOpenMajor,
onClick = { onClickOpenMajorFilterContainer(uiState.selectedOpenMajor) },
)

if (uiState.openLectureList.isEmpty()) {
EmptyText(
stringResource(R.string.word_empty_result),
)
}
FilterContainer(
filterName = stringResource(R.string.word_school_level),
value = stringResource(id = uiState.schoolLevel.stringResId),
onClick = onClickSchoolLevelFilterContainer,
)
}

LazyColumn(
modifier = Modifier
.fillMaxSize(),
contentPadding = PaddingValues(bottom = 24.dp),
state = listState,
) {
items(
items = uiState.openLectureList,
key = { it.id },
) { lectureEvaluation ->
with(lectureEvaluation) {
SuwikiClassInformationCard(
className = name,
professor = professorName,
cellInfo = originalCellList.toText(context),
grade = stringResource(id = R.string.word_num_school_level, grade),
classType = type,
openMajor = major,
onClick = { onClickClassInfoCard(this) },
onClickAdd = { onClickCellAdd(this) },
SuwikiSearchBar(
modifier = Modifier.padding(top = 10.dp),
placeholder = stringResource(R.string.add_timetable_cell_search_bar_placeholder),
onClickSearchButton = onClickSearchButton,
value = uiState.searchValue,
onClickClearButton = onClickClearButton,
onValueChange = onValueChangeSearch,
)
}
},
) {
if (uiState.openLectureList.isEmpty()) {
EmptyText(
stringResource(R.string.word_empty_result),
)
}

LazyColumn(
modifier = Modifier
.fillMaxSize(),
contentPadding = PaddingValues(bottom = 24.dp),
state = listState,
) {
items(
items = uiState.openLectureList,
key = { it.id },
) { lectureEvaluation ->
with(lectureEvaluation) {
SuwikiClassInformationCard(
className = name,
professor = professorName,
cellInfo = originalCellList.toText(context),
grade = stringResource(id = R.string.word_num_school_level, grade),
classType = type,
openMajor = major,
onClick = { onClickClassInfoCard(this) },
onClickAdd = { onClickCellAdd(this) },
)
}
}
}
}
}
Expand Down

0 comments on commit 885c9d1

Please sign in to comment.